From 6f23cae3e914b117425ed033eff839a07a092638 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Thu, 8 Feb 2018 10:00:18 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30873 --- client/MCTool/MCTool.csproj.vspscc | 10 + ...studio.json => -configuration-studio.json} | 0 ...ration-sxs.json => configuration-sxs.json} | 0 client/Maestro/Configuration/global.json | 4 +- client/Maestro/Maestro.csproj | 4 +- client/Maestro/MaestroForm.Metadata.cs | 24 ++ client/Maestro/Program.cs | 14 + client/Maestro/Properties/AssemblyInfo.cs | 4 +- client/Maestro/Sources/CreatedFileMonitor.cs | 14 +- client/Maestro/Sources/FileSystemSource.cs | 40 ++- client/Maestro/nlog.config | 8 +- .../MaestroShared/Commons/PatternNameMaker.cs | 4 + .../Configuration/ConfigurationInfo.cs | 1 + .../MaestroShared/Metadata/ArchiveMetadata.cs | 2 + .../Targets/UNCTargetProcessor.cs | 3 + .../MetadataSelector.csproj.vspscc | 10 + server/-configuration/scheduledjobs.json | 12 + .../import-morpheus-missing-materials.xml | 25 ++ .../ImportMORPHEUSMissingMaterialsStep.java | 248 ++++++++++++++++++ .../user.jobengine.osgi.server/WEB-INF/zk.xml | 3 + .../pages/index.zul | 1 + .../pages/joblist.zul | 2 +- .../pages/missingmaterials.zul | 45 ++++ .../src/user/jobengine/server/JobEngine.java | 9 +- .../server/scheduler/ScheduledJob.java | 6 + .../jobengine/server/steps/EscortFiles.java | 8 +- .../zk/model/BasicDBObjectConverter.java | 29 ++ .../zk/model/MissingMaterialsModel.java | 118 +++++++++ .../jobengine/zk/util/LifeCycleListener.java | 54 ++++ 29 files changed, 678 insertions(+), 24 deletions(-) create mode 100644 client/MCTool/MCTool.csproj.vspscc rename client/Maestro/Configuration/{configuration-studio.json => -configuration-studio.json} (100%) rename client/Maestro/Configuration/{-configuration-sxs.json => configuration-sxs.json} (100%) create mode 100644 client/MetadataSelector/MetadataSelector.csproj.vspscc create mode 100644 server/user.jobengine.executors/jobtemplates/import-morpheus-missing-materials.xml create mode 100644 server/user.jobengine.executors/src/user/jobengine/server/steps/ImportMORPHEUSMissingMaterialsStep.java create mode 100644 server/user.jobengine.osgi.server/pages/missingmaterials.zul create mode 100644 server/user.jobengine.osgi.server/src/user/jobengine/zk/model/BasicDBObjectConverter.java create mode 100644 server/user.jobengine.osgi.server/src/user/jobengine/zk/model/MissingMaterialsModel.java create mode 100644 server/user.jobengine.osgi.server/src/user/jobengine/zk/util/LifeCycleListener.java diff --git a/client/MCTool/MCTool.csproj.vspscc b/client/MCTool/MCTool.csproj.vspscc new file mode 100644 index 00000000..feffdeca --- /dev/null +++ b/client/MCTool/MCTool.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/client/Maestro/Configuration/configuration-studio.json b/client/Maestro/Configuration/-configuration-studio.json similarity index 100% rename from client/Maestro/Configuration/configuration-studio.json rename to client/Maestro/Configuration/-configuration-studio.json diff --git a/client/Maestro/Configuration/-configuration-sxs.json b/client/Maestro/Configuration/configuration-sxs.json similarity index 100% rename from client/Maestro/Configuration/-configuration-sxs.json rename to client/Maestro/Configuration/configuration-sxs.json diff --git a/client/Maestro/Configuration/global.json b/client/Maestro/Configuration/global.json index 11883859..69426439 100644 --- a/client/Maestro/Configuration/global.json +++ b/client/Maestro/Configuration/global.json @@ -2,7 +2,7 @@ "minimizeToTray": false, "userDomain": { "address": "10.10.254.11", - "userName": "echotest", - "password": "F3QcfkSEW7hq+FcEraq9xv4UdHHeVoOh7jBH1G1k9SzEayTXyiT4WQ7XKtBO/ygnCpRU97AXoKXKoqXIGP8QlVkFurRqwzo8mywEb1q2VW7dUjkJcLFtLDkqQjM39+N9" + "-userName": "echotest", + "-password": "F3QcfkSEW7hq+FcEraq9xv4UdHHeVoOh7jBH1G1k9SzEayTXyiT4WQ7XKtBO/ygnCpRU97AXoKXKoqXIGP8QlVkFurRqwzo8mywEb1q2VW7dUjkJcLFtLDkqQjM39+N9" } } diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index 2ec0bc5a..9a9b1fd7 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -324,10 +324,10 @@ PreserveNewest - + Always - + Always diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index 33883632..dec1fb4e 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -197,17 +197,41 @@ namespace Maestro { case MetadataType.None: case MetadataType.MediaCube: result = GetMediaCubeMetadata(); + result.mediaType = "Generic"; break; case MetadataType.OctopusStory: case MetadataType.OctopusPlaceHolder: result = GetOctopusMetadata(metadataType); + result.mediaType = "Octopus nyersanyag"; break; case MetadataType.TrafficMaterial: + result = GetTrafficMetadata(metadataType); + result.mediaType = "Műsor"; + break; case MetadataType.TrafficPromo: + result = GetTrafficMetadata(metadataType); + result.mediaType = "Promo"; + break; case MetadataType.TrafficAD: result = GetTrafficMetadata(metadataType); + result.mediaType = "Reklám"; break; } + + if (!String.IsNullOrWhiteSpace(SelectedSource.Prefix) && "Generic".Equals(result.mediaType)) { + metadataType = MetadataTypeUtil.Guess(SelectedSource.Prefix); + switch (metadataType) { + case MetadataType.TrafficMaterial: + result.mediaType = "Műsor nyersanyag"; + break; + case MetadataType.TrafficPromo: + result.mediaType = "Promo nyersanyag"; + break; + case MetadataType.TrafficAD: + result.mediaType = "Reklám nyersanyag"; + break; + } + } Cursor.Current = Cursors.Default; return result; } diff --git a/client/Maestro/Program.cs b/client/Maestro/Program.cs index b1913c4c..a8e67306 100644 --- a/client/Maestro/Program.cs +++ b/client/Maestro/Program.cs @@ -12,6 +12,7 @@ using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Security.AccessControl; +using System.Security.Permissions; using System.Security.Principal; using System.Threading; using System.Threading.Tasks; @@ -26,6 +27,7 @@ namespace Maestro { /// The main entry point for the application. /// [STAThread] + [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)] static void Main() { string appGuid = ((GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value.ToString(); string userName = WindowsIdentity.GetCurrent().Name; @@ -53,6 +55,14 @@ namespace Maestro { if (hasHandle || enableInstance) { TrayApplicationContext context = null; try { + Application.ThreadException += (s,e) => { + logger.Error(e); + MessageBox.Show(new Form() { TopMost = true }, e.Exception?.Message); + }; + AppDomain.CurrentDomain.UnhandledException += (s, e) => { + logger.Error(e); + MessageBox.Show(new Form() { TopMost = true }, ((Exception)e.ExceptionObject).Message); + }; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); context = new TrayApplicationContext(); @@ -73,6 +83,10 @@ namespace Maestro { } } } + + private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { + throw new NotImplementedException(); + } } public class TrayApplicationContext : ApplicationContext { diff --git a/client/Maestro/Properties/AssemblyInfo.cs b/client/Maestro/Properties/AssemblyInfo.cs index 6f5109cc..77b1304d 100644 --- a/client/Maestro/Properties/AssemblyInfo.cs +++ b/client/Maestro/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.7.0")] -[assembly: AssemblyFileVersion("2.0.7.0")] +[assembly: AssemblyVersion("2.0.7.3")] +[assembly: AssemblyFileVersion("2.0.7.3")] diff --git a/client/Maestro/Sources/CreatedFileMonitor.cs b/client/Maestro/Sources/CreatedFileMonitor.cs index d74f371d..c37f02c6 100644 --- a/client/Maestro/Sources/CreatedFileMonitor.cs +++ b/client/Maestro/Sources/CreatedFileMonitor.cs @@ -1,4 +1,5 @@ using NLog; +using System; using System.ComponentModel; using System.IO; using System.Threading; @@ -19,8 +20,17 @@ namespace Maestro.Sources { return true; } } - catch (IOException) { - return false; + catch (Exception e) { + logger.Error(e); + try { + using (FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.None)) { + return true; + } + } + catch (Exception e1) { + logger.Error(e1); + return false; + } } } diff --git a/client/Maestro/Sources/FileSystemSource.cs b/client/Maestro/Sources/FileSystemSource.cs index 3a380fba..5f95d306 100644 --- a/client/Maestro/Sources/FileSystemSource.cs +++ b/client/Maestro/Sources/FileSystemSource.cs @@ -23,7 +23,8 @@ namespace Maestro.Sources { private List cache; private BackgroundWorker pathWatcherWorker = new BackgroundWorker(); private string rootPath; - FileSystemWatcher watcher; + private FileSystemWatcher watcher; + private Object lck = new Object(); public DataGridViewColumn[] Columns { get { @@ -143,11 +144,15 @@ namespace Maestro.Sources { if (Path.Equals(path)) return false; Path = path == null ? rootPath : path; + Reset(); + logger.Trace("Exit"); + return true; + } + + private void Reset() { Clear(); cache = null; Shutdown(); - logger.Trace("Exit"); - return true; } public FileSystemSource(Control parent, IMessageBus messageBus, bool playerEnabled, string fileExtensionFilter) { @@ -269,7 +274,22 @@ namespace Maestro.Sources { } public void OnError(object sender, ErrorEventArgs e) { - logger.Error(e.GetException()); + logger.Error(e); + parent.SafeCall(() => Reset()); + } + + private FileSourceItem getItemByName(string name) { + if (name == null) + return null; + FileSourceItem result = null; + try { + lock (lck) { + result = this.Where(x => name.Equals(x.Name)).FirstOrDefault(); + } + } catch (Exception e) { + logger.Error(e); + } + return result; } public void OnRenamed(object sender, RenamedEventArgs e) { @@ -281,7 +301,7 @@ namespace Maestro.Sources { FileInfo fiNew = new FileInfo(e.FullPath); if (fiOld.Extension.Equals(fiNew.Extension)) { logger.Debug("File rename"); - var item = this.Where(x => x.Name == e.OldName).FirstOrDefault(); + var item = getItemByName(e.OldName); if (item == null || !item.CanHandle(acceptableExtensions)) return; parent.SafeCall(() => { @@ -298,7 +318,9 @@ namespace Maestro.Sources { if (newItem.CanHandle(acceptableExtensions)) SafeCreateItem(newItem); - var item = this.Where(x => x.Name == e.OldName).FirstOrDefault(); + var item = getItemByName(e.OldName); + if (item == null) + return; SafeDeleteItem(item); } logger.Trace("Exit"); @@ -309,7 +331,7 @@ namespace Maestro.Sources { return; logger.Trace("Entry"); //logger.Debug("{0} {1}", e.ChangeType, e.Name); - var item = this.Where(x => x.Name == e.Name).FirstOrDefault(); + var item = getItemByName(e.Name); if (item == null || !item.CanHandle(acceptableExtensions)) return; logger.Debug("File change"); @@ -324,6 +346,8 @@ namespace Maestro.Sources { logger.Trace("Exit"); } + + private void OnCreated(object sender, FileSystemEventArgs e) { if (!String.IsNullOrEmpty(filter)) return; @@ -349,7 +373,7 @@ namespace Maestro.Sources { return; logger.Trace("Entry"); logger.Debug("{0} {1}", e.ChangeType, e.Name); - FileSourceItem item = this.Where(i => i.Name.Equals(e.Name)).FirstOrDefault(); + var item = getItemByName(e.Name); if (item == null || !item.CanHandle(acceptableExtensions)) return; SafeDeleteItem(item); diff --git a/client/Maestro/nlog.config b/client/Maestro/nlog.config index d5a005aa..70d5e798 100644 --- a/client/Maestro/nlog.config +++ b/client/Maestro/nlog.config @@ -5,8 +5,12 @@ - - + + diff --git a/client/MaestroShared/Commons/PatternNameMaker.cs b/client/MaestroShared/Commons/PatternNameMaker.cs index bd17c626..859e1b45 100644 --- a/client/MaestroShared/Commons/PatternNameMaker.cs +++ b/client/MaestroShared/Commons/PatternNameMaker.cs @@ -10,6 +10,7 @@ namespace MaestroShared.Commons { private const string SOURCESTARTID_PATTERN = "[^0-9]"; private const string PATTERN_TARGETNAME = "%TARGETNAME%"; private const string PATTERN_USERNAME = "%USERNAME%"; + private const string PATTERN_COMPUTERNAME = "%COMPUTERNAME%"; private const string PATTERN_ID = "%ID%"; private const string PATTERN_IDROOT = "%IDROOT%"; private const string PATTERN_SOURCENAME = "%SOURCENAME%"; @@ -65,6 +66,9 @@ namespace MaestroShared.Commons { if (!String.IsNullOrEmpty(userName)) result = result.Replace(PATTERN_USERNAME, userName); + if (!String.IsNullOrEmpty(Environment.MachineName)) + result = result.Replace(PATTERN_COMPUTERNAME, Environment.MachineName); + if (!String.IsNullOrEmpty(text)) result = result.Replace(PATTERN_TEXT, Normalize(text)); return result; diff --git a/client/MaestroShared/Configuration/ConfigurationInfo.cs b/client/MaestroShared/Configuration/ConfigurationInfo.cs index 5092c81b..f273ac68 100644 --- a/client/MaestroShared/Configuration/ConfigurationInfo.cs +++ b/client/MaestroShared/Configuration/ConfigurationInfo.cs @@ -115,6 +115,7 @@ namespace MaestroShared.Configuration { public bool NexioServer { get; set; } public string NexioFileExistsMessage { get; set; } public string Agency { get; set; } + public string PopupMessage { get; set; } } public class Connection { diff --git a/client/MaestroShared/Metadata/ArchiveMetadata.cs b/client/MaestroShared/Metadata/ArchiveMetadata.cs index fb4585e4..097165b9 100644 --- a/client/MaestroShared/Metadata/ArchiveMetadata.cs +++ b/client/MaestroShared/Metadata/ArchiveMetadata.cs @@ -15,8 +15,10 @@ namespace MaestroShared.Metadata { public string mediaHouseId { get; set; } public string mediaTitle { get; set; } public string mediaDescription { get; set; } + [JsonIgnore] public bool ok { get; set; } public string userName { get; set; } + public string mediaType { get; set; } public override string ToString() { return JsonConvert.SerializeObject(this, Formatting.Indented); diff --git a/client/MaestroShared/Targets/UNCTargetProcessor.cs b/client/MaestroShared/Targets/UNCTargetProcessor.cs index db2a191d..4692c005 100644 --- a/client/MaestroShared/Targets/UNCTargetProcessor.cs +++ b/client/MaestroShared/Targets/UNCTargetProcessor.cs @@ -59,6 +59,9 @@ namespace MaestroShared.Targets { userName = parameters.UserName }; Label = parameters.TargetConfig.Label; + string popupMessage = parameters.TargetConfig?.PopupMessage; + if (popupMessage != null && popupMessage.Length > 0) + MsgBox.Info(popupMessage); } protected virtual void BeforeExecute() { diff --git a/client/MetadataSelector/MetadataSelector.csproj.vspscc b/client/MetadataSelector/MetadataSelector.csproj.vspscc new file mode 100644 index 00000000..feffdeca --- /dev/null +++ b/client/MetadataSelector/MetadataSelector.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/server/-configuration/scheduledjobs.json b/server/-configuration/scheduledjobs.json index bda37e10..953a3db7 100644 --- a/server/-configuration/scheduledjobs.json +++ b/server/-configuration/scheduledjobs.json @@ -1,5 +1,17 @@ {"joblist":[ { + "active": false, + "name" : "MORPHEUS 'missing materials' importálása", + "template": "import-morpheus-missing-materials.xml", + "executeimmediate": false, + "cronexpression": "0 0 0/1 1/1 * ? *", + "parameters": [ + {"name": "csvFilePath", "value": "c:/temp/morpheus", "type": "java.lang.String"}, + {"name": "processedFolder", "value": "DONE", "type": "java.lang.String"}, + {"name": "targetPath", "value": "\\\\10.10.1.100\\BRAAVOS\\ARCHIVE_RESTORE", "type": "java.lang.String"} + ] + }, + { "active": false, "name" : "Felhasználói archiválás", "template": "archive-ondemand.xml", diff --git a/server/user.jobengine.executors/jobtemplates/import-morpheus-missing-materials.xml b/server/user.jobengine.executors/jobtemplates/import-morpheus-missing-materials.xml new file mode 100644 index 00000000..c339f067 --- /dev/null +++ b/server/user.jobengine.executors/jobtemplates/import-morpheus-missing-materials.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/ImportMORPHEUSMissingMaterialsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/ImportMORPHEUSMissingMaterialsStep.java new file mode 100644 index 00000000..17c1249e --- /dev/null +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/ImportMORPHEUSMissingMaterialsStep.java @@ -0,0 +1,248 @@ +package user.jobengine.server.steps; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.ibm.nosql.json.api.BasicDBObject; +import com.ibm.nosql.json.api.DB; +import com.ibm.nosql.json.api.DBCollection; +import com.ibm.nosql.json.api.DBObject; +import com.ibm.nosql.json.api.QueryBuilder; + +import user.commons.IEntityBase; +import user.commons.nosql.NoSQLUtils; +import user.jobengine.db.IItemManager; +import user.jobengine.db.MediaFile; +import user.jobengine.db.MediaFileDAO; +import user.jobengine.server.IJobEngine; +import user.jobengine.server.IJobRuntime; + +public class ImportMORPHEUSMissingMaterialsStep extends JobStep { + private static final String STATUS = "Status"; + private static final String IMPORTED = "Imported"; + private static final Logger logger = LogManager.getLogger(); + private static final String MATERIAL_ID = "Material ID"; + private static final String CHANNEL = "Channel"; + private static final String TIME_TO_AIR = "Time to Air"; + private static final String DURATION = "Duration"; + private static final String TITLE = "Title"; + private static final String DEVICE_ID = "Device ID"; + private static final String REASON = "Reason"; + private static final String COLLECTION_NAME = "missing_materials"; + + private static final String CSV_EXT = ".csv"; + private static final String MXF_EXT = ".MXF"; + private MediaFileDAO dao; + private String processedFolder; + private DB db; + private String targetPath; + private IJobRuntime jobRuntime; + private int overall; + private int current; + + private Map buildMetadataMap(Path csvFilePath, String[] data) throws Exception { + Map result = new HashMap<>(); + List dataList = Arrays.asList(data); + storeMetadataPosition(csvFilePath, dataList, MATERIAL_ID, result); + storeMetadataPosition(csvFilePath, dataList, CHANNEL, result); + storeMetadataPosition(csvFilePath, dataList, TIME_TO_AIR, result); + storeMetadataPosition(csvFilePath, dataList, DURATION, result); + storeMetadataPosition(csvFilePath, dataList, TITLE, result); + storeMetadataPosition(csvFilePath, dataList, DEVICE_ID, result); + storeMetadataPosition(csvFilePath, dataList, REASON, result); + return result; + } + + @StepEntry + public Object[] execute(String sourceCSVPath, String processedFolder, String targetPath, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { + this.jobRuntime = jobRuntime; + setAndCheck(sourceCSVPath, processedFolder, targetPath, jobEngine); + + List filePaths = new ArrayList<>(); + try (DirectoryStream directoryStream = Files.newDirectoryStream(Paths.get(sourceCSVPath))) { + for (Path path : directoryStream) { + filePaths.add(path); + } + + processPathItems(filePaths); + } catch (Exception e) { + logger.catching(e); + logger.error(jobRuntime.getMarker(), "Hiba a végrehajtás során. A rendszer üzenete: {}", e.getMessage()); + } + return null; + } + + private void moveProcessedCSV(Path csvFilePath) throws IOException { + EscortFiles.ensureUNCFolder(csvFilePath.getParent().toString(), processedFolder); + String fileName = csvFilePath.getFileName() + "." + EscortFiles.composeKillDate(0); + Path targetPath = Paths.get(csvFilePath.getParent().toString(), processedFolder, fileName); + Files.move(csvFilePath, targetPath); + } + + private void processLine(String[] data, Map metadatas) throws Exception { + String channel = data[metadatas.get(CHANNEL)]; + String timeToAir = data[metadatas.get(TIME_TO_AIR)]; + String duration = data[metadatas.get(DURATION)]; + String materialID = data[metadatas.get(MATERIAL_ID)]; + String title = data[metadatas.get(TITLE)]; + String deviceID = data[metadatas.get(DEVICE_ID)]; + String reason = data[metadatas.get(REASON)]; + + DBObject query = QueryBuilder.start().and(QueryBuilder.start(MATERIAL_ID).is(materialID).get(), QueryBuilder.start(TIME_TO_AIR).is(timeToAir).get()) + .get(); + DBCollection collection = db.getCollection(COLLECTION_NAME); + BasicDBObject existingObject = (BasicDBObject) collection.findOne(query); + if (existingObject != null) { + logger.warn(jobRuntime.getMarker(), "Az '{}' anyag már feldolgozásra került az {} időpontban.", materialID, existingObject.getDate(IMPORTED)); + return; + } + + BasicDBObject dbObject = new BasicDBObject(IMPORTED, new Date()); + dbObject.put(CHANNEL, channel); + dbObject.put(TIME_TO_AIR.replace(" ", ""), timeToAir); + dbObject.put(DURATION, duration); + dbObject.put(MATERIAL_ID.replace(" ", ""), materialID); + dbObject.put(TITLE, title); + dbObject.put(DEVICE_ID.replace(" ", ""), deviceID); + dbObject.put(REASON, reason); + + String fileName = materialID + MXF_EXT; + if (Files.exists(Paths.get(targetPath, fileName))) { + logger.warn(jobRuntime.getMarker(), "Az '{}' anyag már be van töltve.", materialID); + dbObject.put(STATUS, "SKIPPED"); + } else { + List medias = dao.getByHouseId(fileName); + if (medias == null || medias.size() == 0) { + logger.warn(jobRuntime.getMarker(), "Az '{}' anyag nem található az archívumban.", materialID); + dbObject.put(STATUS, "UNAVAILABLE"); + } else if (medias.size() > 1) { + logger.warn(jobRuntime.getMarker(), "Az '{}' anyagból egynél több található az archívumban.", materialID); + dbObject.put(STATUS, "MULTIPLE"); + } else { + logger.info(jobRuntime.getMarker(), "Az '{}' anyag megtalálható az archívumban.", materialID); + dbObject.put(STATUS, "RESTORABLE"); + } + + } + + collection.insert(dbObject); + } + + // Channel,Time to Air,Duration,Material ID,Title,Device ID,Reason, + // TX02,10-JAN-2018 13:25:21:08,00:05:00:00,M009572A,Tiéd a pálya/26. - 1. seg - Eredeti ** mc ,ICELE-02,On Domain (ISILON, ICELE-01, ICELE-05) , + private void processMissingMaterialCSV(Path csvFilePath, List lines) throws Exception { + if (lines == null | lines.size() == 0) { + return; + } + + Map metadatas = null; + for (int i = 0; i < lines.size(); i++) { + String line = lines.get(i); + if (line == null) + continue; + String[] data = line.split(","); + if (i == 0) + metadatas = buildMetadataMap(csvFilePath, data); + else + processLine(data, metadatas); + + current++; + setProgress(current * 100 / overall); + } + + } + + private void processPathItem(Path csvFilePath, List lines) { + File csvFile = csvFilePath.toFile(); + + try { + processMissingMaterialCSV(csvFilePath, lines); + moveProcessedCSV(csvFilePath); + } catch (Exception e) { + logger.catching(e); + logger.error(jobRuntime.getMarker(), "A {} MORPHEUS állomány mozgatásakor hiba történt. A rendszer hibaüzenete: {}.", csvFile.getName(), + e.getMessage()); + } + } + + private void processPathItems(List filePaths) throws IOException { + overall = 0; + Map> contents = new HashMap<>(); + for (Path filePath : filePaths) { + File csvFile = filePath.toFile(); + if (csvFile.isDirectory() || !csvFile.getName().toLowerCase().endsWith(CSV_EXT.toLowerCase())) + continue; + List lines = Files.readAllLines(filePath, Charset.forName("UTF-8")); + overall += lines.size(); + contents.put(filePath, lines); + } + + Set csvPaths = contents.keySet(); + for (Path csvPath : csvPaths) { + processPathItem(csvPath, contents.get(csvPath)); + } + } + + private void setAndCheck(String sourcePath, String processedFolder, String targetPath, IJobEngine jobEngine) { + if (jobEngine == null) { + logger.error(jobRuntime.getMarker(), "Az folyamatkezelő réteg nem elérhető."); + throw new NullPointerException("Internal error, missing JobEngine reference."); + } + + IItemManager manager = jobEngine.getItemManager(); + if (manager == null) { + logger.error(jobRuntime.getMarker(), "Az adatbáziskezelő réteg nem elérhető."); + throw new NullPointerException("Internal error, missing ItemManager reference."); + } + dao = (MediaFileDAO) manager.getBaseDAO(MediaFile.class); + if (dao == null) { + logger.error(jobRuntime.getMarker(), "Az adatbáziskezelő réteg MediaFile kezelöje nem elérhető."); + throw new NullPointerException("Internal error, missing MediaFile DAO reference."); + } + if (sourcePath == null) { + logger.error(jobRuntime.getMarker(), "A folyamat 'sourcePath' bemeneti paramétere üres."); + throw new NullPointerException("System is not configured properly, 'sourcePath' input parameter missing."); + } + if (processedFolder == null) { + logger.error(jobRuntime.getMarker(), "A folyamat 'processedFolder' bemeneti paramétere üres."); + throw new NullPointerException("System is not configured properly, 'processedFolder' input parameter missing."); + } + this.processedFolder = processedFolder; + + if (targetPath == null) { + logger.error(jobRuntime.getMarker(), "A folyamat 'targetPath' bemeneti paramétere üres."); + throw new NullPointerException("System is not configured properly, 'targetPath' input parameter missing."); + } + this.targetPath = targetPath; + + db = NoSQLUtils.getNoSQLDB(); + if (db == null) { + logger.error(jobRuntime.getMarker(), "Sikertelen kapcsolódás a NoSQL adatbázishoz."); + throw new NullPointerException("Can not connect to NoSQL database."); + } + + } + + private void storeMetadataPosition(Path csvFilePath, List dataList, String name, Map metadatas) throws Exception { + int pos = dataList.indexOf(name); + if (pos < 0) + throw new Exception(String.format("A '%s' MORPHEUS állományban nem található a '%s' mező.", csvFilePath.getFileName(), MATERIAL_ID)); + metadatas.put(name, pos); + } + +} diff --git a/server/user.jobengine.osgi.server/WEB-INF/zk.xml b/server/user.jobengine.osgi.server/WEB-INF/zk.xml index f2bcef43..1e4646e6 100644 --- a/server/user.jobengine.osgi.server/WEB-INF/zk.xml +++ b/server/user.jobengine.osgi.server/WEB-INF/zk.xml @@ -25,5 +25,8 @@ ZK performance monitor org.zkoss.performance.monitor.PerformanceMeter + + user.jobengine.zk.util.LifeCycleListener + \ No newline at end of file diff --git a/server/user.jobengine.osgi.server/pages/index.zul b/server/user.jobengine.osgi.server/pages/index.zul index 7f68e668..3859e8bd 100644 --- a/server/user.jobengine.osgi.server/pages/index.zul +++ b/server/user.jobengine.osgi.server/pages/index.zul @@ -1,4 +1,5 @@ +