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
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
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
\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
}\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
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
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
}\r
return result;\r
}\r
+ \r
\r
private List<Long> getIDsFromReferences(List<DBObject> list, String referenceName) {\r
List<Long> result = new ArrayList<>();\r
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
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
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
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
\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