git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorBellai Ádám <USER\adam.bellai>
Fri, 29 Sep 2017 12:51:54 +0000 (12:51 +0000)
committerBellai Ádám <USER\adam.bellai>
Fri, 29 Sep 2017 12:51:54 +0000 (12:51 +0000)
client/Maestro/MaestroForm.Source.cs
client/Maestro/MaestroForm.Target.cs
client/Maestro/MaestroForm.cs
client/PlanAIRClient/TrafficIDSelector.cs
server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusAPI.java
server/user.jobengine.osgi.commons/test/user/common/octopus/test/OctopusAPITest.java

index abd0ecede59379cf728cad980e8edb2724b803f6..c358517c7041c72d6a8abd60a7c9fc0a81d6dc0d 100644 (file)
@@ -213,11 +213,8 @@ namespace Maestro {
         private void dataGridSource_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) {\r
             if (e.RowIndex < 0)\r
                 return;\r
-            ISourceItem item = dataGridSource.Rows[e.RowIndex].DataBoundItem as ISourceItem;\r
-            SelectedSource = new SourceInfo() {\r
-                FileInfo = (item as FileSourceItem)?.FileInfo,\r
-                Name = item.Name\r
-            };\r
+            var selectedItem = bindingSource.Current;\r
+            SetSourceFromCheckBoxAction(sender, selectedItem);\r
         }\r
     }\r
 }\r
index 96ac62b049959e5c1102e83c7c4ba765b079e9e2..269b5e0a1cac78f5ccf477d17be4593bd30e53fe 100644 (file)
@@ -141,10 +141,13 @@ namespace Maestro {
             string id = selectedMetadata.ID;\r
             OctopusAPI api = octopusIDSelector.GetClient();\r
             IEnumerable<Story> storyEnum = api.GetStoriesById(id);\r
-            if (storyEnum != null) \r
+            if (storyEnum != null)\r
                 FillModelFromStories(model, storyEnum.ToList(), api);\r
             else {\r
-                List<Story> stories = api.GetStoriesByPlaceHolderId(id).ToList();\r
+                IEnumerable<Story> storiesEnum = api.GetStoriesByPlaceHolderId(id);\r
+                if (storiesEnum == null)\r
+                    return;\r
+                List<Story> stories = storiesEnum.ToList();\r
                 FillModelFromStories(model, stories, api);\r
             }\r
         }\r
@@ -152,12 +155,18 @@ namespace Maestro {
         private void FillModelFromStories(ArchiveMetadataModel model, List<Story> stories, OctopusAPI api) {\r
             Story story = stories[0];\r
             if (story.StoryFolders != null) {\r
-                List<StoryFolder> storyFolders = api.GetStoryFoldersByStoryID(story.ID).ToList();\r
+                IEnumerable<StoryFolder> storyFoldersEnum = api.GetStoryFoldersByStoryID(story.ID);\r
+                if (storyFoldersEnum == null)\r
+                    return;\r
+                List<StoryFolder> storyFolders = storyFoldersEnum.ToList();\r
                 StoryFolder folder = storyFolders[0];\r
                 model.StuffID = folder.ID;\r
                 model.StuffTitle = folder.Name;\r
             } else if (story.Rundowns != null) {\r
-                List<Rundown> rundowns = api.GetRundownsByStoryID(story.ID).ToList();\r
+                IEnumerable<Rundown> rundownsEnum = api.GetRundownsByStoryID(story.ID);\r
+                if (rundownsEnum == null)\r
+                    return;\r
+                List<Rundown> rundowns = rundownsEnum.ToList();\r
                 Rundown rundown = rundowns[0];\r
                 model.StuffID = rundown.ID;\r
                 model.StuffTitle = rundown.Name;\r
index 5ad63c9cfb7243fc94cd055655ca018400179ef8..5d354e0c9a889b4ae0aa88fec75b4d283bad04a4 100644 (file)
@@ -208,6 +208,8 @@ namespace Maestro {
 \r
         private void SearchMosIDs(OctopusAPI api) {\r
             IEnumerable<MosObject> mosIDs = api.GetMosObjectsByID(startingName);\r
+            if (mosIDs == null)\r
+                return;\r
             List<MosObject> list = mosIDs.ToList();\r
             if (list == null || list.Count == 0) {\r
                 MessageBox.Show(this, StringResources.NINCS_TALALAT);\r
index 9b8f48cfa86ef9ab602f383ad1f952c7b1ed64d1..ef614ff02072f3416267baf6361bcc953c6d94b6 100644 (file)
@@ -106,13 +106,8 @@ namespace TrafficClient {
         }\r
 \r
         private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {\r
-            if (e.RowIndex < 0)\r
-                return;\r
-\r
-            MamResultWrapper res = dataGridView1.Rows[e.RowIndex].DataBoundItem as MamResultWrapper;\r
-            if (res == null)\r
-                return;\r
-            IDChangedEvent?.Invoke(res.MediaID, res.VariantID);\r
+            DataGridViewCell checkBoxCell = dataGridView1.Rows[e.RowIndex].Cells[0];\r
+            SetCheckBoxAndInvokeIDChangeEvent(checkBoxCell, e.RowIndex);\r
         }\r
 \r
         private void searchButton_Click(object sender, EventArgs e) {\r
@@ -133,11 +128,15 @@ namespace TrafficClient {
                 return;\r
             //nincs multiselect\r
             DataGridViewCell checkBoxCell = gridView.SelectedCells[0];\r
+            SetCheckBoxAndInvokeIDChangeEvent(checkBoxCell, e.RowIndex);\r
+        }\r
+\r
+        private void SetCheckBoxAndInvokeIDChangeEvent(DataGridViewCell checkBoxCell, int rowIndex) {\r
             bool selected = checkBoxCell.Value.Equals(false);\r
             clearCheckBox?.Invoke();\r
             ClearSelectionSource();\r
             //checkBoxCell.Value = checkBoxCell.Value.Equals(true) ? true : false;\r
-            MamResultWrapper res = dataGridView1.Rows[e.RowIndex].DataBoundItem as MamResultWrapper;\r
+            MamResultWrapper res = dataGridView1.Rows[rowIndex].DataBoundItem as MamResultWrapper;\r
             res.Selected = selected;\r
             if (selected) {\r
                 IDChangedEvent?.Invoke(res.MediaID, res.VariantID);\r
index 8a36592cb58cc0d0bca231ad70d4efc37b58c537..f6e97f83561783d01283b18817b9d93a9bc8673b 100644 (file)
@@ -96,12 +96,12 @@ public class OctopusAPI implements IOctopusAPI {
                DBCollection storyFolderCollection = db.getCollection(STORY_FOLDER_COLLECTION_NAME);\r
                DBCursor find = storyCollection.find(new BasicDBObject("id", storyID),\r
                                new BasicDBObject(STORY_FOLDER, 1).append("_id", 0));\r
-               result = getRundownsByReferences(find, storyFolderCollection, queryedStory_FoldersFromStoryCollection,\r
+               result = getParentsByReferences(find, storyFolderCollection, queryedStory_FoldersFromStoryCollection,\r
                                STORY_FOLDER);\r
                return result;\r
        }\r
 \r
-       private List<DBObject> getRundownsByReferences(DBCursor find, DBCollection collection,\r
+       private List<DBObject> getParentsByReferences(DBCursor find, DBCollection collection,\r
                        List<DBObject> referenceObjects, String referenceName) {\r
                List<DBObject> result = null;\r
                if (find.hasNext())\r
@@ -115,6 +115,7 @@ public class OctopusAPI implements IOctopusAPI {
                }\r
                return result;\r
        }\r
+       \r
 \r
        private List<Long> getIDsFromReferences(List<DBObject> list, String referenceName) {\r
                List<Long> result = new ArrayList<>();\r
@@ -136,7 +137,7 @@ public class OctopusAPI implements IOctopusAPI {
                DBCollection rundownCollection = db.getCollection(RUNDOWN_COLLECTION_NAME);\r
                DBCursor find = storyCollection.find(new BasicDBObject("id", storyID),\r
                                new BasicDBObject(RUNDOWN, 1).append("_id", 0));\r
-               result = getRundownsByReferences(find, rundownCollection, queryedRundownsFromStoryCollection, RUNDOWN);\r
+               result = getParentsByReferences(find, rundownCollection, queryedRundownsFromStoryCollection, RUNDOWN);\r
                return result;\r
        }\r
 \r
@@ -146,27 +147,26 @@ public class OctopusAPI implements IOctopusAPI {
                DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME);\r
                DBCollection rundownCollection = db.getCollection(RUNDOWN_COLLECTION_NAME);\r
                List<DBObject> queryedRundownsFromStoryCollection = null;\r
-               BasicDBObject globalId = new BasicDBObject("globalId", placeHolderID);\r
-               BasicDBObject elemmatch = new BasicDBObject("$elemMatch", globalId);\r
+               BasicDBObject id = new BasicDBObject("id", placeHolderID);\r
+               BasicDBObject elemmatch = new BasicDBObject("$elemMatch", id);\r
                BasicDBObject mosObjects = new BasicDBObject("mosObjects", elemmatch);\r
                //db.testStoryCollection.find({"mosObjects": {$elemMatch: {"globalId": "OCTOPUS-ECHOTV-2429902"}}})\r
-               DBCursor find = storyCollection.find(mosObjects, new BasicDBObject(RUNDOWN, 1).append("_id", 0));\r
-               result = getRundownsByReferences(find, rundownCollection, queryedRundownsFromStoryCollection, RUNDOWN);\r
+               DBCursor find = storyCollection.find(mosObjects);\r
+               result = getParentsByReferences(find, rundownCollection, queryedRundownsFromStoryCollection, RUNDOWN);\r
                return result;\r
        }\r
 \r
-       //teszteletlen\r
        @Override\r
        public List<DBObject> getStoryFoldersByPlaceHolderId(String placeHolderID) {\r
                List<DBObject> result = null;\r
                DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME);\r
                DBCollection rundownCollection = db.getCollection(STORY_FOLDER_COLLECTION_NAME);\r
                List<DBObject> queryedRundownsFromStoryCollection = null;\r
-               BasicDBObject globalId = new BasicDBObject("globalId", placeHolderID);\r
+               BasicDBObject globalId = new BasicDBObject("id", placeHolderID);\r
                BasicDBObject elemmatch = new BasicDBObject("$elemMatch", globalId);\r
                BasicDBObject mosObjects = new BasicDBObject("mosObjects", elemmatch);\r
                DBCursor find = storyCollection.find(mosObjects, new BasicDBObject(STORY_FOLDER, 1).append("_id", 0));\r
-               result = getRundownsByReferences(find, rundownCollection, queryedRundownsFromStoryCollection, STORY_FOLDER);\r
+               result = getParentsByReferences(find, rundownCollection, queryedRundownsFromStoryCollection, STORY_FOLDER);\r
                return result;\r
        }\r
 \r
@@ -247,7 +247,6 @@ public class OctopusAPI implements IOctopusAPI {
                DBCursor find = storyCollection.find(mosObjects);\r
                if(find.hasNext())\r
                        result.add(find.next());\r
-               //result = getRundownsByReferences(find, rundownCollection, queryedRundownsFromStoryCollection, RUNDOWN);\r
                return result;\r
        }\r
 }\r
index 57a1d4381bd4d34e3687a04701a2f09363094485..9109ea04ccca7be2ad3bcff47773bc4b86cca9b6 100644 (file)
@@ -102,8 +102,9 @@ public class OctopusAPITest {
                long rundownID = 2;\r
                BasicDBObject obj = new BasicDBObject("id", storyID);\r
                String globalID = "OCTOPUS-ECHOTV-2429902";\r
+               String placeHolderID = "2429902";\r
                BasicDBObject mosObject = new BasicDBObject("mosId", "NEXIO.MOS").append("mosId", "NEXIO.MOS")\r
-                               .append("objId", "xxxl").append("objectType", "MosObject").append("id", 2429902)\r
+                               .append("objId", "xxxl").append("objectType", "MosObject").append("id", placeHolderID)\r
                                .append("globalId", globalID).append("modified", "2017-08-08T11:38:53.000+02:00");\r
                BasicDBList mosObjects = new BasicDBList(mosObject);\r
                obj.append("mosObjects", mosObjects);\r
@@ -116,7 +117,7 @@ public class OctopusAPITest {
 \r
                // Exercise\r
                try {\r
-                       List<DBObject> actual = sut.getRundownsByPlaceHolderId(globalID);\r
+                       List<DBObject> actual = sut.getRundownsByPlaceHolderId(placeHolderID);\r
                } catch (Exception e) {\r
                        System.out.println(e.getMessage());\r
                } finally {\r