From 155bb81b38e2e998e940e596d4fc2678f8326525 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Fri, 8 Dec 2017 16:10:27 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30795 --- client/MCTool/App.config | 6 ++ client/MCTool/MCTool.csproj | 56 +++++++++++ client/MCTool/Program.cs | 27 ++++++ client/MCTool/Properties/AssemblyInfo.cs | 36 +++++++ .../Configuration/-configuration-editor.json | 4 +- ...studio.json => -configuration-studio.json} | 0 ...ration-nle.json => configuration-nle.json} | 0 client/Maestro/Maestro.csproj | 4 +- client/Maestro/MaestroForm.Source.cs | 18 +++- client/MediaCube.sln | 19 +++- client/OctopusClient/OctopusIDSelector.cs | 4 + .../run-mediacube-server-bsh.launch | 2 +- server/-product/log4j2.xml | 2 +- .../config/scheduledjobs.json | 10 ++ .../server/steps/ArchiveListBuilderStep.java | 4 +- .../steps/CleanupMountedLocationStep.java | 4 +- .../CopyForArchiveNEXIOMaterialsStep.java | 97 +++++++++++++------ .../nexio/NexioClipEventDispatcher.java | 15 ++- .../src/user/commons/octopus/IOctopusAPI.java | 2 + .../src/user/commons/octopus/OctopusAPI.java | 11 +++ .../commons/octopus/OctopusDataMiner.java | 27 +++--- server/user.jobengine.osgi.db/sql/cleanup.sql | 38 ++++++++ .../pages/joblist.zul | 21 ++-- .../pages/search_items.zul | 4 +- .../src/user/jobengine/server/JobEngine.java | 6 +- .../user/jobengine/zk/model/JobListModel.java | 4 +- .../zk/model/StatisticsComposer.java | 4 +- 27 files changed, 352 insertions(+), 73 deletions(-) create mode 100644 client/MCTool/App.config create mode 100644 client/MCTool/MCTool.csproj create mode 100644 client/MCTool/Program.cs create mode 100644 client/MCTool/Properties/AssemblyInfo.cs rename client/Maestro/Configuration/{configuration-studio.json => -configuration-studio.json} (100%) rename client/Maestro/Configuration/{-configuration-nle.json => configuration-nle.json} (100%) create mode 100644 server/user.jobengine.osgi.db/sql/cleanup.sql diff --git a/client/MCTool/App.config b/client/MCTool/App.config new file mode 100644 index 00000000..00bfd114 --- /dev/null +++ b/client/MCTool/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/client/MCTool/MCTool.csproj b/client/MCTool/MCTool.csproj new file mode 100644 index 00000000..4c76c7ee --- /dev/null +++ b/client/MCTool/MCTool.csproj @@ -0,0 +1,56 @@ + + + + + Debug + AnyCPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179} + Exe + MCTool + MCTool + v4.6.1 + 512 + true + SAK + SAK + SAK + SAK + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/client/MCTool/Program.cs b/client/MCTool/Program.cs new file mode 100644 index 00000000..f359f5cb --- /dev/null +++ b/client/MCTool/Program.cs @@ -0,0 +1,27 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; + +namespace MCTool { + class Program { + static void Main(string[] args) { + string source = "file://10.10.1.27/mclowres/www/video"; + string destination = "file://10.10.1.100/BRAAVOS/ARCHIVE"; + var sFiles = Directory.EnumerateFiles(new Uri(source).LocalPath, "*.mp4"); + var dFiles = Directory.EnumerateFiles(new Uri(destination).LocalPath, "*.MXF"); + + var diff = dFiles.Where(s => { + string name = Path.GetFileNameWithoutExtension(s) + ".mp4"; + string lookup = new Uri(Path.Combine(source, name)).LocalPath; + bool result = !source.Contains(lookup); + if (result) + Debug.WriteLine(name); + return result; + }); + + Console.WriteLine("Diff " + diff.Count()); + Console.ReadLine(); + } + } +} diff --git a/client/MCTool/Properties/AssemblyInfo.cs b/client/MCTool/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..76a6a44c --- /dev/null +++ b/client/MCTool/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("MCTool")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MCTool")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a64adb88-2cc4-4e46-bc53-643e2c49e179")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/client/Maestro/Configuration/-configuration-editor.json b/client/Maestro/Configuration/-configuration-editor.json index 1ea79085..34015f55 100644 --- a/client/Maestro/Configuration/-configuration-editor.json +++ b/client/Maestro/Configuration/-configuration-editor.json @@ -1,6 +1,6 @@ { "title": "Szerkesztő", - "active": false, + "active": true, "startInTray": false, "enableCustomMetadataId": true, "player": { @@ -12,7 +12,7 @@ "$type": "UNCSource", "filter": "avi,wav,mxf", "local": { - "address": "file://c:/x" + "address": "file://10.10.1.100/BRAAVOS/OCTOPUS" } }, "metadatas": [ 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-nle.json b/client/Maestro/Configuration/configuration-nle.json similarity index 100% rename from client/Maestro/Configuration/-configuration-nle.json rename to client/Maestro/Configuration/configuration-nle.json diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index c21783fc..0f5f0ecd 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -279,7 +279,7 @@ Always - + Always @@ -324,7 +324,7 @@ Always - + Always diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index 42eb5ef9..96e9d7c8 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -189,6 +189,7 @@ namespace Maestro { HideFolders(); btnShowFolders.CheckState = CheckState.Unchecked; } else { + ResetSourceSearch(); ShowFolders(); btnShowFolders.CheckState = CheckState.Checked; } @@ -426,6 +427,10 @@ namespace Maestro { } private void picClearFilter_Click(object sender, EventArgs e) { + ResetSourceSearch(); + } + + private void ResetSourceSearch() { txtSourceFilter.Text = null; bindingSource.Filter = null; SelectedSource = null; @@ -434,8 +439,17 @@ namespace Maestro { private void txtSourceFilter_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode != Keys.Return) return; - bindingSource.Filter = txtSourceFilter.Text; - SelectedSource = null; + + if (btnShowFolders.CheckState == CheckState.Checked) { + SearchFolders(); + } else { + bindingSource.Filter = txtSourceFilter.Text; + SelectedSource = null; + } + } + + private void SearchFolders() { + throw new NotImplementedException(); } private void textSelectedSource_KeyDown(object sender, KeyEventArgs e) { diff --git a/client/MediaCube.sln b/client/MediaCube.sln index 806f4aaf..4698632c 100644 --- a/client/MediaCube.sln +++ b/client/MediaCube.sln @@ -24,6 +24,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaestroShared", "MaestroSha EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MetadataSelector", "MetadataSelector\MetadataSelector.csproj", "{8CB8266D-2229-47E2-B06D-54FDE82CBDC4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MCTool", "MCTool\MCTool.csproj", "{A64ADB88-2CC4-4E46-BC53-643E2C49E179}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -166,6 +168,18 @@ Global {8CB8266D-2229-47E2-B06D-54FDE82CBDC4}.Release|x64.Build.0 = Release|Any CPU {8CB8266D-2229-47E2-B06D-54FDE82CBDC4}.Release|x86.ActiveCfg = Release|Any CPU {8CB8266D-2229-47E2-B06D-54FDE82CBDC4}.Release|x86.Build.0 = Release|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Debug|x64.ActiveCfg = Debug|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Debug|x64.Build.0 = Debug|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Debug|x86.ActiveCfg = Debug|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Debug|x86.Build.0 = Debug|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Release|Any CPU.Build.0 = Release|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Release|x64.ActiveCfg = Release|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Release|x64.Build.0 = Release|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Release|x86.ActiveCfg = Release|Any CPU + {A64ADB88-2CC4-4E46-BC53-643E2C49E179}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -174,7 +188,7 @@ Global SolutionGuid = {8F7E7365-1678-4775-B9E4-B3993FC028E2} EndGlobalSection GlobalSection(TeamFoundationVersionControl) = preSolution - SccNumberOfProjects = 12 + SccNumberOfProjects = 13 SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} SccTeamFoundationServer = https://tfs.userrendszerhaz.hu/tfs/defaultcollection SccLocalPath0 = . @@ -211,5 +225,8 @@ Global SccProjectUniqueName11 = MetadataSelector\\MetadataSelector.csproj SccProjectName11 = MetadataSelector SccLocalPath11 = MetadataSelector + SccProjectUniqueName12 = MCTool\\MCTool.csproj + SccProjectName12 = MCTool + SccLocalPath12 = MCTool EndGlobalSection EndGlobal diff --git a/client/OctopusClient/OctopusIDSelector.cs b/client/OctopusClient/OctopusIDSelector.cs index b2b6917a..819574e9 100644 --- a/client/OctopusClient/OctopusIDSelector.cs +++ b/client/OctopusClient/OctopusIDSelector.cs @@ -103,6 +103,10 @@ namespace OctopusClient { } else label = String.Format($"{parentStoryID} {story.Name}"); + logger.Debug("Adding story {0} {1}", parentStoryID, label); + if ("21519676".Equals(parentStoryID)) { + logger.Debug(":"); + } TreeNode storyNode = treeOctopus.Nodes.Add(parentStoryID, label); storyNode.Tag = story; diff --git a/server/-configuration/run-mediacube-server-bsh.launch b/server/-configuration/run-mediacube-server-bsh.launch index d0240306..f957593d 100644 --- a/server/-configuration/run-mediacube-server-bsh.launch +++ b/server/-configuration/run-mediacube-server-bsh.launch @@ -19,7 +19,7 @@ - + diff --git a/server/-product/log4j2.xml b/server/-product/log4j2.xml index f81b90af..91345a08 100644 --- a/server/-product/log4j2.xml +++ b/server/-product/log4j2.xml @@ -47,7 +47,7 @@ - + diff --git a/server/user.jobengine.executors/config/scheduledjobs.json b/server/user.jobengine.executors/config/scheduledjobs.json index df57e526..f12581bd 100644 --- a/server/user.jobengine.executors/config/scheduledjobs.json +++ b/server/user.jobengine.executors/config/scheduledjobs.json @@ -65,6 +65,16 @@ ] }, { + "active": false, + "name" : "Lejárt ISISLON/ARCHIVE_TEMP anyagok törlése", + "template": "delete-materials.xml", + "executeimmediate": true, + "cronexpression": "0 0 0/1 1/1 * ? *", + "parameters": [ + {"name": "sourcePath", "value": "/mnt/ISILON/ARCHIVE_TEMP", "type": "java.lang.String"} + ] + }, + { "active": false, "name" : "NEXIO anyagok törlése", "template": "delete-nexio-materials.xml", diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/ArchiveListBuilderStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/ArchiveListBuilderStep.java index 7b78de79..0f5e7f11 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/ArchiveListBuilderStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/ArchiveListBuilderStep.java @@ -55,7 +55,6 @@ public class ArchiveListBuilderStep extends JobStep { result.setMediaHouseId(getMetadata(dbObject, MEDIA_HOUSEID)); result.setMediaTitle(getMetadata(dbObject, MEDIA_TITLE)); result.setMediaDescription(getMetadata(dbObject, MEDIA_DESCRIPTION)); - result.setMediaFile(mediaFilePath.toString()); result.setCatchedFile(catchedFilePath.toString()); @@ -63,6 +62,7 @@ public class ArchiveListBuilderStep extends JobStep { logger.catching(e); return null; } + return result; } @@ -92,6 +92,8 @@ public class ArchiveListBuilderStep extends JobStep { } } } + logger.info(getMarker(), "Az archiváló folyamat {} új anyagot érzékelt.", archiveList == null ? 0 : archiveList.size()); + return new Object[] { archiveList }; } diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CleanupMountedLocationStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CleanupMountedLocationStep.java index 88f20501..a0c63645 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/CleanupMountedLocationStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CleanupMountedLocationStep.java @@ -43,8 +43,8 @@ public class CleanupMountedLocationStep extends JobStep implements FileVisitor

{ count[0]++; - if (p.getFileName().toString().toLowerCase().equals(PROJECTFOLDER.toLowerCase())) - specialCount[0]++; + // if (p.getFileName().toString().toLowerCase().equals(PROJECTFOLDER.toLowerCase())) + // specialCount[0]++; if (p.getFileName().toString().toLowerCase().equals(STATUSFOLDER.toLowerCase())) specialCount[0]++; diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java index 17c1a655..115accfd 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java @@ -3,6 +3,7 @@ package user.jobengine.server.steps; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.util.ArrayList; import java.util.Calendar; import java.util.List; @@ -28,6 +29,19 @@ import user.jobengine.server.JobEngineException; import user.jobengine.server.steps.MetadataTypeDetector.MetadataType; public class CopyForArchiveNEXIOMaterialsStep extends JobStep { + private class StoryArchive { + private String mediaHouseId; + private String mediaTitle; + private String mediaDesc; + private List fileNames; + + public void addFile(String fileName) { + if (fileNames == null) + fileNames = new ArrayList<>(); + fileNames.add(fileName); + } + } + private static final String MXFEXT = ".MXF"; private static final Logger logger = LogManager.getLogger(); private static final String NEXIOCLIPS = "nexioclips"; @@ -38,6 +52,7 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { private StoreUri targetUri; private OctopusAPI octopusAPI; private IItemManager manager; + private DB db; private int check(int value, String name) { @@ -67,66 +82,92 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { setAndCheck(nexioPort, nexioUserName, nexioPassword, archiveFtp, archiveUserName, archivePassword, jobEngine); octopusAPI = new OctopusAPI(); Calendar scheduledDate = Calendar.getInstance(); - scheduledDate.add(Calendar.DAY_OF_YEAR, -1 * daysBeforeNow); + // scheduledDate.add(Calendar.DAY_OF_YEAR, -1 * daysBeforeNow); List rundowns = octopusAPI.getRundowns(scheduledDate.getTime()); if (rundowns == null) { logger.warn(getMarker(), "Nem található adástükör a {} napra.", CalendarUtils.toDateString(scheduledDate)); return null; } - try { - int index = 1; - for (DBObject r : rundowns) { - setProgress(index * 100 / rundowns.size()); - processRundow(r); - index++; + int index = 1; + + List> rundownArchives = null; + for (DBObject r : rundowns) { + setProgress(index * 100 / rundowns.size()); + try { + List storyArchive = processRundow(r); + if (storyArchive.size() > 0) { + if (rundownArchives == null) + rundownArchives = new ArrayList<>(); + rundownArchives.add(storyArchive); + } + } catch (Exception e) { + logger.catching(e); + logger.error(getMarker(), + "A {} tükör archiválása nem lehetséges, mert a annak ellenőrzése hibát jelzett. A rendszer üzenete: " + e.getMessage()); } - } catch (Exception e) { - logger.catching(e); - logger.error(getMarker(), e.getMessage()); - throw e; + index++; } return null; } - private void processMosObject(BasicDBObject rundown, BasicDBObject story, BasicDBObject mosObject) throws Exception { + private String processMosObject(BasicDBObject rundown, BasicDBObject story, BasicDBObject mosObject) throws Exception { String mosID = mosObject.getString(IOctopusAPI.OBJ_ID); if (MetadataTypeDetector.GuessMetadataType(mosID) != MetadataType.OCTOPUSPLACEHOLDER) { logger.warn("Skipping MOS object {}", mosID); - return; + return null; } - DBCollection clips = db.getCollection(NEXIOCLIPS); DBObject clip = clips.findOne(new BasicDBObject(LONGNAMEID, mosID)); if (clip == null) { logger.info("File NOT exists {}", mosID); - throw new Exception("Not exists"); + throw new Exception(String.format("File NOT exists %s")); } else { logger.info("File exists {}", mosID); } - - BasicDBObject metadata = createMetadata(rundown, story, mosObject); + return mosID + MXFEXT; } - private void processRundow(DBObject r) throws Exception { + private List processRundow(DBObject r) throws Exception { + //storyArchive = new ArrayList<>(); BasicDBObject rundown = (BasicDBObject) r; long rundownID = rundown.getLong(ID); - logger.info("Processing rundown {}", rundownID); - List stories = octopusAPI.getRundownStories(rundownID); + logger.info("Processing rundown {} {}", rundownID, rundown.getString(IOctopusAPI.NAME)); + List stories = octopusAPI.getRundownFullStories(rundownID); if (stories == null) - return; - for (DBObject s : stories) - processStory(rundown, s); + return null; + List storyArchives = null; + for (DBObject s : stories) { + StoryArchive storyArchive = processStory(rundown, s); + if (storyArchive == null) + continue; + if (storyArchives == null) + storyArchives = new ArrayList<>(); + storyArchives.add(storyArchive); + } + return storyArchives; } - private void processStory(BasicDBObject rundown, DBObject s) throws Exception { + private StoryArchive processStory(BasicDBObject rundown, DBObject s) throws Exception { BasicDBObject story = (BasicDBObject) s; String parentStoryID = story.getString(IOctopusAPI.PARENT_STORY_ID); - logger.info("Processing story {}", parentStoryID); + if (StringUtils.isBlank(parentStoryID)) { + logger.warn("Story parentStoryID is null: {}", story.toPrettyString(null)); + return null; + } else + logger.info("Processing story {}", parentStoryID); List mosObjects = NoSQLUtils.asList(story, IOctopusAPI.MOS_OBJECTS); if (mosObjects == null) - return; - for (BasicDBObject mosObject : mosObjects) - processMosObject(rundown, story, mosObject); + return null; + StoryArchive storyArchive = null; + for (BasicDBObject mosObject : mosObjects) { + String fileName = processMosObject(rundown, story, mosObject); + if (fileName == null) + continue; + if (storyArchive == null) + storyArchive = new StoryArchive(); + storyArchive.addFile(fileName); + } + return null; } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java index 007b6f6e..05063f39 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/nexio/NexioClipEventDispatcher.java @@ -287,14 +287,14 @@ public class NexioClipEventDispatcher implements ClipEventListener { } /* - + int c = connection.read(buffer, 0, 2); //2 bytes hosszan az idokozben hozzaadott id-k szamossaga if (c < 2) { throw new ProtocolException("c, 2, 2"); } //MSB, LSB - + return nofIds; */ return ret; @@ -365,9 +365,14 @@ public class NexioClipEventDispatcher implements ClipEventListener { collection.save(clip); onUpdate(clip); } - } else { - logger.error("Not found {}, XID based clip is {}", id, clipForName.toPrettyString(null)); - } + } else if (clipForName != null) { + clip.put("_id", clipForName.get("_id")); + if (!clip.equals(clipForName)) { + collection.save(clip); + onUpdate(clip); + } + } else + logger.error("Clip not found {} {}", id, xid); } } diff --git a/server/user.jobengine.osgi.commons/src/user/commons/octopus/IOctopusAPI.java b/server/user.jobengine.osgi.commons/src/user/commons/octopus/IOctopusAPI.java index 69d3e8d4..e9951179 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/octopus/IOctopusAPI.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/octopus/IOctopusAPI.java @@ -40,6 +40,8 @@ public interface IOctopusAPI { static final String STORYID = "storyId"; static final String FORMAT = "format"; + List getRundownFullStories(long id); + List getRundowns(Date scheduledDate); List getRundownsByParentStoryID(String storyID); diff --git a/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusAPI.java b/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusAPI.java index 595fd762..3ed09ab8 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusAPI.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusAPI.java @@ -71,6 +71,17 @@ public class OctopusAPI implements IOctopusAPI { return result; } + @Override + public List getRundownFullStories(long id) { + List result = null; + DBCollection collection = db.getCollection(STORY_COLLECTION); + DBCursor find = collection.find(new BasicDBObject(REF_RUNDOWN, new BasicDBObject($ELEMMATCH, new BasicDBObject(ID, id)))) + .sort(new BasicDBObject("name", 1)); + if (find.hasNext()) + result = find.toArray(); + return result; + } + @Override public List getRundowns(Date scheduledDate) { List result = null; diff --git a/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusDataMiner.java b/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusDataMiner.java index 3f57fb48..1d92376d 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusDataMiner.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusDataMiner.java @@ -46,7 +46,8 @@ public class OctopusDataMiner implements Runnable { private static final String FIELDS_STORIES = "stories,Story.modified,Story.name,Story.id,Story.mosObjects,Story.script,Story.type,Story.format,Story.customColumns,CustomColumn.label,CustomColumn.value"; private static final String FIELDS_SLUGS = "slugs,Slug.story,Slug.position,Story.name,Story.id,Story.modified,Story.mosObjects,Story.script,Story.type,Story.format,Story.customColumns,CustomColumn.label,CustomColumn.value"; private static final String FIELDS_RUNDOWN_LIST = "id,name,modified,scheduledStart,rundownType,RundownType.name,slugs,Slug.storyId,Slug.position"; - private static final String FIELDS_STORY_FOLDER_LIST = "id,name,modified,stories,Story.id"; + // private static final String FIELDS_STORY_FOLDER_LIST = "id,name,modified,stories,Story.id"; + private static final String FIELDS_STORY_FOLDER_LIST = "id,name,modified"; private static final String RUNDOWN = "Rundown"; private static final String OCTOPUS_DEVICE_NAME = "Octopus-Device-Name"; private static final String OCTOPUS_DEVICE_ID = "Octopus-Device-Id"; @@ -538,7 +539,9 @@ public class OctopusDataMiner implements Runnable { Response response = query(String.format("%s/", RUNDOWN) + id, fields).get(); String json = response.readEntity(String.class); BasicDBObject resultObject = (BasicDBObject) JSONUtil.jsonToDbObject(json); - if (resultObject != null) + if (resultObject == null) + logger.error("Rundown {} is not available", id); + else result = NoSQLUtils.asDBObject(resultObject, RESULT); logger.trace(EXIT); return result; @@ -667,15 +670,17 @@ public class OctopusDataMiner implements Runnable { String name = rundown.containsKey(IOctopusAPI.NAME) ? rundown.getString(IOctopusAPI.NAME) : null; logger.debug("Storing rundown {} {}", name, rundown.get(IOctopusAPI.SCHEDULED_START)); BasicDBObject rundownWithStories = queryRundown(rundownID); - BasicDBList stories = NoSQLUtils.asDBList(rundownWithStories, IOctopusAPI.SLUGS); - if (stories != null) - storeRundownStories(stories, lastUpdateTime); - rundown.put(IOctopusAPI.SCHEDULED_START, toDate(rundown, IOctopusAPI.SCHEDULED_START)); - rundown.put(IOctopusAPI.MODIFIED, toDate(rundown, IOctopusAPI.MODIFIED)); - DBCollection collection = db.getCollection(RUNDOWN_COLLECTION); - if (lastUpdateTime == null || (lastUpdateTime != null && isModified(lastUpdateTime, rundown))) { - logger.debug(SAVING_RUNDOWN, rundownID, name); - collection.save(rundown); + if (rundownWithStories != null) { + BasicDBList stories = NoSQLUtils.asDBList(rundownWithStories, IOctopusAPI.SLUGS); + if (stories != null) + storeRundownStories(stories, lastUpdateTime); + rundown.put(IOctopusAPI.SCHEDULED_START, toDate(rundown, IOctopusAPI.SCHEDULED_START)); + rundown.put(IOctopusAPI.MODIFIED, toDate(rundown, IOctopusAPI.MODIFIED)); + DBCollection collection = db.getCollection(RUNDOWN_COLLECTION); + if (lastUpdateTime == null || (lastUpdateTime != null && isModified(lastUpdateTime, rundown))) { + logger.debug(SAVING_RUNDOWN, rundownID, name); + collection.save(rundown); + } } logger.trace(EXIT); } diff --git a/server/user.jobengine.osgi.db/sql/cleanup.sql b/server/user.jobengine.osgi.db/sql/cleanup.sql new file mode 100644 index 00000000..0352c35a --- /dev/null +++ b/server/user.jobengine.osgi.db/sql/cleanup.sql @@ -0,0 +1,38 @@ +--MEDIAFILE +select * from mediafile f where f.mediaid in (select mediaid from vw_mediafiles where mediafilecount = 1) +delete from mediafile f where f.mediaid in (select mediaid from vw_mediafiles where mediafilecount = 1) +select * from mediafile f where f.mediaid in (select id from media where created > '2017-12-08') +delete from mediafile f where f.mediaid in (select id from media where created > '2017-12-08') + + +--MEDIA +CREATE VIEW vw_mediafiles as select mediaid, count(*) as mediafilecount from mediafile group by (mediaid) +select m.id, m.title, m.created,f.mediafilecount from media m right outer join vw_mediafiles f on (f.mediaid = m.id) where m.created > '2017-12-08' +select m.itemid, m.id, m.itemtypeid, m.title, m.created,f.mediafilecount from media m left outer join vw_mediafiles f on (f.mediaid = m.id) where f.mediafilecount is null +select m.itemid, m.id, m.itemtypeid, m.title, m.created,f.mediafilecount from media m left outer join vw_mediafiles f on (f.mediaid = m.id) where f.mediafilecount = 1 +delete from media where id in (select m.id from media m left outer join vw_mediafiles f on (f.mediaid = m.id) where f.mediafilecount is null) + + + +--ITEM +CREATE VIEW vw_medias as select itemid, count(*) as mediacount from media group by (itemid) +select i.id, i.title, i.created, m.mediacount from item i left outer join vw_medias m on (m.itemid = i.id) where m.mediacount is null +delete from item where id in (select i.id from item i left outer join vw_medias m on (m.itemid = i.id) where m.mediacount is null) + + + +insert into media (id, itemid, title, ITEMTYPEID, houseid, length) values (13985, 13045, 'xxx', 2, 'xxx', 0) + +select * from media fetch first 10 rows only + +select id from item where created > '2017-12-08' + +SELECT C.TABSCHEMA, C.TABNAME, +C.COLNAME +FROM SYSCAT.TABLES AS T, +SYSCAT.COLUMNS AS C +WHERE T.TBSPACEID = 2 +AND T.TABLEID = 14 +AND C.COLNO = 0 +AND C.TABSCHEMA = T.TABSCHEMA +AND C.TABNAME = T.TABNAME diff --git a/server/user.jobengine.osgi.server/pages/joblist.zul b/server/user.jobengine.osgi.server/pages/joblist.zul index 9c5f39fe..a9ff3cb5 100644 --- a/server/user.jobengine.osgi.server/pages/joblist.zul +++ b/server/user.jobengine.osgi.server/pages/joblist.zul @@ -35,17 +35,18 @@

- + - - - - - - - - + + + + + + + +