From: Vásáry Dániel Date: Tue, 21 Nov 2017 15:58:05 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=64894a36f99b089c5433978602cb230d0879e6e2;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30752 --- diff --git a/client/Maestro/Configuration/configuration-playout-ingest.json b/client/Maestro/Configuration/configuration-playout-ingest.json index ddd13040..aa818ef7 100644 --- a/client/Maestro/Configuration/configuration-playout-ingest.json +++ b/client/Maestro/Configuration/configuration-playout-ingest.json @@ -1,6 +1,6 @@ { "title": "Lebony betöltő", - "active": false, + "active": true, "startInTray": false, "enableCustomMetadataId": true, "player": { diff --git a/client/Maestro/Installer/installforge-installer-project.ifp b/client/Maestro/Installer/installforge-installer-project.ifp index f289b99e..c925d278 100644 Binary files a/client/Maestro/Installer/installforge-installer-project.ifp and b/client/Maestro/Installer/installforge-installer-project.ifp differ diff --git a/client/Maestro/MaestroForm.Designer.cs b/client/Maestro/MaestroForm.Designer.cs index b4b037ee..4b77ea25 100644 --- a/client/Maestro/MaestroForm.Designer.cs +++ b/client/Maestro/MaestroForm.Designer.cs @@ -26,17 +26,17 @@ namespace Maestro { /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MaestroForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle16 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle17 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle19 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle20 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle18 = new System.Windows.Forms.DataGridViewCellStyle(); this.groupSource = new System.Windows.Forms.GroupBox(); this.dgSource = new System.Windows.Forms.DataGridView(); this.bindingSource = new System.Windows.Forms.BindingSource(this.components); @@ -159,32 +159,32 @@ namespace Maestro { this.dgSource.BackgroundColor = System.Drawing.Color.White; this.dgSource.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dgSource.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.Raised; - dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgSource.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle11.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle11.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle11.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle11.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle11.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgSource.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle11; this.dgSource.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgSource.DataSource = this.bindingSource; - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.Gainsboro; - dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.Black; - dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgSource.DefaultCellStyle = dataGridViewCellStyle2; + dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle12.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle12.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle12.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle12.SelectionBackColor = System.Drawing.Color.Gainsboro; + dataGridViewCellStyle12.SelectionForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgSource.DefaultCellStyle = dataGridViewCellStyle12; this.dgSource.Dock = System.Windows.Forms.DockStyle.Fill; this.dgSource.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgSource.EnableHeadersVisualStyles = false; this.dgSource.Location = new System.Drawing.Point(10, 47); this.dgSource.Name = "dgSource"; this.dgSource.RowHeadersVisible = false; - dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.dgSource.RowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle13.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.dgSource.RowsDefaultCellStyle = dataGridViewCellStyle13; this.dgSource.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.dgSource.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgSource.Size = new System.Drawing.Size(330, 159); @@ -324,6 +324,7 @@ namespace Maestro { this.textSelectedSource.ReadOnly = true; this.textSelectedSource.Size = new System.Drawing.Size(288, 26); this.textSelectedSource.TabIndex = 10; + this.textSelectedSource.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textSelectedSource_KeyDown); // // label1 // @@ -527,6 +528,7 @@ namespace Maestro { this.textSelectedMetadata.Size = new System.Drawing.Size(288, 26); this.textSelectedMetadata.TabIndex = 12; this.textSelectedMetadata.TextChanged += new System.EventHandler(this.OnMetadataIDChanged); + this.textSelectedMetadata.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textSelectedMetadata_KeyDown); // // tsMetadata // @@ -704,15 +706,15 @@ namespace Maestro { this.columnOutput, this.columnKillDate}); this.dgJobs.DataSource = this.bindingSourceJobs; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle6.NullValue = null; - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.Gainsboro; - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.Black; - dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgJobs.DefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle16.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle16.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle16.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle16.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle16.NullValue = null; + dataGridViewCellStyle16.SelectionBackColor = System.Drawing.Color.Gainsboro; + dataGridViewCellStyle16.SelectionForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle16.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgJobs.DefaultCellStyle = dataGridViewCellStyle16; this.dgJobs.Dock = System.Windows.Forms.DockStyle.Fill; this.dgJobs.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgJobs.EnableHeadersVisualStyles = false; @@ -720,8 +722,8 @@ namespace Maestro { this.dgJobs.Location = new System.Drawing.Point(3, 3); this.dgJobs.Name = "dgJobs"; this.dgJobs.RowHeadersVisible = false; - dataGridViewCellStyle7.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.dgJobs.RowsDefaultCellStyle = dataGridViewCellStyle7; + dataGridViewCellStyle17.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.dgJobs.RowsDefaultCellStyle = dataGridViewCellStyle17; this.dgJobs.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.dgJobs.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgJobs.Size = new System.Drawing.Size(988, 90); @@ -742,8 +744,8 @@ namespace Maestro { // this.columnID.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; this.columnID.DataPropertyName = "ID"; - dataGridViewCellStyle4.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.columnID.DefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle14.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.columnID.DefaultCellStyle = dataGridViewCellStyle14; this.columnID.HeaderText = "ID"; this.columnID.Name = "columnID"; this.columnID.Width = 44; @@ -760,8 +762,8 @@ namespace Maestro { // this.columnStatus.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells; this.columnStatus.DataPropertyName = "Status"; - dataGridViewCellStyle5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.columnStatus.DefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle15.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.columnStatus.DefaultCellStyle = dataGridViewCellStyle15; this.columnStatus.HeaderText = "Status"; this.columnStatus.Name = "columnStatus"; this.columnStatus.Width = 66; @@ -829,15 +831,15 @@ namespace Maestro { this.dgMessages.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridViewTextBoxColumn1, this.dataGridViewTextBoxColumn2}); - dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle9.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle9.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle9.ForeColor = System.Drawing.Color.Red; - dataGridViewCellStyle9.NullValue = null; - dataGridViewCellStyle9.SelectionBackColor = System.Drawing.Color.Gainsboro; - dataGridViewCellStyle9.SelectionForeColor = System.Drawing.Color.Red; - dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgMessages.DefaultCellStyle = dataGridViewCellStyle9; + dataGridViewCellStyle19.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle19.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle19.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle19.ForeColor = System.Drawing.Color.Red; + dataGridViewCellStyle19.NullValue = null; + dataGridViewCellStyle19.SelectionBackColor = System.Drawing.Color.Gainsboro; + dataGridViewCellStyle19.SelectionForeColor = System.Drawing.Color.Red; + dataGridViewCellStyle19.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgMessages.DefaultCellStyle = dataGridViewCellStyle19; this.dgMessages.Dock = System.Windows.Forms.DockStyle.Fill; this.dgMessages.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgMessages.EnableHeadersVisualStyles = false; @@ -846,8 +848,8 @@ namespace Maestro { this.dgMessages.Name = "dgMessages"; this.dgMessages.ReadOnly = true; this.dgMessages.RowHeadersVisible = false; - dataGridViewCellStyle10.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.dgMessages.RowsDefaultCellStyle = dataGridViewCellStyle10; + dataGridViewCellStyle20.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.dgMessages.RowsDefaultCellStyle = dataGridViewCellStyle20; this.dgMessages.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); this.dgMessages.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgMessages.Size = new System.Drawing.Size(988, 90); @@ -866,8 +868,8 @@ namespace Maestro { // this.dataGridViewTextBoxColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.dataGridViewTextBoxColumn2.DataPropertyName = "Message"; - dataGridViewCellStyle8.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle8; + dataGridViewCellStyle18.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + this.dataGridViewTextBoxColumn2.DefaultCellStyle = dataGridViewCellStyle18; this.dataGridViewTextBoxColumn2.HeaderText = "Üzenet"; this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2"; this.dataGridViewTextBoxColumn2.ReadOnly = true; diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index c5b5546c..48e4cacd 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -295,44 +295,31 @@ namespace Maestro { IEnumerable octopusResult = null; switch (metadataType) { case MetadataType.OctopusPlaceHolder: - octopusResult = api.GetStoriesByPlaceHolderId(id); + octopusResult = api.GetStoriesByPlaceHolderID(id); break; case MetadataType.OctopusStory: - octopusResult = api.GetStoriesByParentStoryId(id); + octopusResult = api.GetStoriesByParentStoryID(id); break; } - if (octopusResult == null) + List stories = octopusResult?.ToList(); + if (stories == null || stories.Count == 0) return null; - List stories = octopusResult.ToList(); - return GetStoryMetadata(stories); + return GetStoryMetadata(stories[0]); } - private ArchiveMetadata GetStoryMetadata(List stories) { - if (stories == null || stories.Count == 0) - return null; - Story story = stories[0]; + private ArchiveMetadata GetStoryMetadata(Story story) { ArchiveMetadata result = new ArchiveMetadata(); - - OctopusAPI api = octopusIDSelector.GetClient(); if (story.Rundowns != null && story.Rundowns.Length > 0) { - IEnumerable rundownsEnum = api.GetRundownsByStoryID(story.ID); - if (rundownsEnum == null) - return null; - List rundowns = rundownsEnum.ToList(); - Rundown rundown = rundowns[0]; + Rundown rundown = story.Rundowns[0]; result.itemHouseId = rundown.ID; result.itemTitle = rundown.Name; - result.itemDescription = rundown.Start.ToString(); + //result.itemDescription = rundown.Start.ToString(); } else if (story.StoryFolders != null && story.StoryFolders.Length > 0) { - IEnumerable storyFoldersEnum = api.GetStoryFoldersByStoryID(story.ID); - if (storyFoldersEnum == null) - return null; - List storyFolders = storyFoldersEnum.ToList(); - StoryFolder folder = storyFolders[0]; + StoryFolder folder = story.StoryFolders[0]; result.itemHouseId = folder.ID; result.itemTitle = folder.Name; } - result.mediaHouseId = story.ID; + result.mediaHouseId = story.ParentStoryID; result.mediaTitle = story.Name; result.mediaDescription = story.ScriptContent; return result; @@ -482,5 +469,12 @@ namespace Maestro { MetadataType metadataType = GuessMetadataType(SelectedMetadata?.ID); btnLookupMetadata.Enabled = metadataType != MetadataType.None && metadataType != MetadataType.MediaCube; } + + private void textSelectedMetadata_KeyDown(object sender, KeyEventArgs e) { + if (e.KeyCode != Keys.Return || !btnLookupMetadata.Enabled) + return; + Lookup(SelectedMetadata.ID); + } + } } diff --git a/client/Maestro/MaestroForm.Source.cs b/client/Maestro/MaestroForm.Source.cs index a11fbbb1..12b915ac 100644 --- a/client/Maestro/MaestroForm.Source.cs +++ b/client/Maestro/MaestroForm.Source.cs @@ -285,8 +285,42 @@ namespace Maestro { private string GetPrefix(string name) { if (String.IsNullOrEmpty(name)) return null; - string[] byHyphen = name.Replace('_', '-').Replace('.', '-').Split('-'); - return byHyphen.Length > 0 ? byHyphen[0] : null; + + string nameWithoutExtension = name.Contains(".") ? name.Split('.')[0] : name; + var t = GuessMetadataType(nameWithoutExtension); + if (t != MetadataType.MediaCube && t != MetadataType.None) + return nameWithoutExtension; + + if (nameWithoutExtension.Contains("-")) { + int start = nameWithoutExtension.Length; + while (true) { + int p = nameWithoutExtension.LastIndexOf("-", start); + if (p < 1) + break; + start = p - 1; + string x = nameWithoutExtension.Substring(0, p); + var z = GuessMetadataType(x); + if (z != MetadataType.MediaCube && z != MetadataType.None) + return x; + } + } + if (nameWithoutExtension.Contains("_")) { + int start = nameWithoutExtension.Length; + while (true) { + int p = nameWithoutExtension.LastIndexOf("_", start); + if (p < 1) + break; + start = p - 1; + string x = nameWithoutExtension.Substring(0, p); + var z = GuessMetadataType(x); + if (z != MetadataType.MediaCube && z != MetadataType.None) + return x; + } + } + + //string[] byHyphen = name.Replace('_', '-').Replace('.', '-').Split('-'); + //return byHyphen.Length > 0 ? byHyphen[0] : null; + return null; } private FileInfo GetSelectedSourceFileInfo() { @@ -342,6 +376,12 @@ namespace Maestro { SelectedSource = null; } + private void textSelectedSource_KeyDown(object sender, KeyEventArgs e) { + if (e.KeyCode != Keys.Return || !btnLookupBySource.Enabled) + return; + Lookup(SelectedSource.Prefix); + } + private void UpdateLookupBySourceEnabled() { MetadataType metadataType = GuessMetadataType(SelectedSource?.Prefix); btnLookupBySource.Enabled = metadataType != MetadataType.MediaCube && metadataType != MetadataType.None; diff --git a/client/Maestro/MaestroForm.cs b/client/Maestro/MaestroForm.cs index ad9d46af..a2a0e145 100644 --- a/client/Maestro/MaestroForm.cs +++ b/client/Maestro/MaestroForm.cs @@ -250,5 +250,7 @@ namespace Maestro { if (e.Button == MouseButtons.Right) treeFolders.SelectedNode = treeFolders.GetNodeAt(e.X, e.Y); } + + } } diff --git a/client/Maestro/MaestroForm.resx b/client/Maestro/MaestroForm.resx index f09802db..ffe86623 100644 --- a/client/Maestro/MaestroForm.resx +++ b/client/Maestro/MaestroForm.resx @@ -128,7 +128,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACU - BwAAAk1TRnQBSQFMAwEBAAFYAQABWAEAARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA + BwAAAk1TRnQBSQFMAwEBAAFgAQABYAEAARABAAEQAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA AUADAAEQAwABAQEAAQgGAAEEGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEA AfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEA AYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFm @@ -163,6 +163,9 @@ AUADAAEQAwABAQEAAQEFAAGAFwAD/4EACw== + + 951, 17 + @@ -172,8 +175,8 @@ 3/jmkprcKEuYE8aOir3NRGolzAnzVFoPuyGPLs5GSj/4XULq1sxx1wAAAABJRU5ErkJggg== - - 951, 17 + + 846, 17 846, 17 diff --git a/client/Maestro/Properties/AssemblyInfo.cs b/client/Maestro/Properties/AssemblyInfo.cs index e4b28889..9da19dff 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.4.0")] -[assembly: AssemblyFileVersion("2.0.4.0")] +[assembly: AssemblyVersion("2.0.4.2")] +[assembly: AssemblyFileVersion("2.0.4.2")] diff --git a/client/OctopusClient/OctopusAPI.cs b/client/OctopusClient/OctopusAPI.cs index 57ed4aeb..aaff347a 100644 --- a/client/OctopusClient/OctopusAPI.cs +++ b/client/OctopusClient/OctopusAPI.cs @@ -61,6 +61,7 @@ namespace OctopusClient { public class OctopusAPI { private static Logger logger = LogManager.GetCurrentClassLogger(); public const string UNNAMED = "<üres>"; + private const string ID = "id"; private RestClient client; private string user; private string pwd; @@ -94,22 +95,16 @@ namespace OctopusClient { return result; } - public IEnumerable GetRundownStories(string rundownID) { - IEnumerable result = null; + public IEnumerable GetRundownsByParentStoryID(String id) { + IEnumerable result = null; try { - var request = new RestRequest("stories/{rundownID}", Method.GET); - request.AddParameter("rundownID", rundownID, ParameterType.UrlSegment); + var request = new RestRequest("rundownsByParentStoryID/{id}", Method.GET); + request.AddParameter(ID, id, ParameterType.UrlSegment); var response = client.Execute(request); if (!CheckResponse(response)) return null; JArray resultObject = JArray.Parse(response.Content); - result = resultObject.Children().Select(d => { - Story r = ToRundownStory(d, rundownID); - //logger.Debug($"{r}"); - return r; - }).OrderBy(r => { - return r.ID; - }); + result = resultObject.Children().Select(d => ToRundown(d)); } catch (Exception e) { OnError(e); @@ -117,22 +112,16 @@ namespace OctopusClient { return result; } - public IEnumerable GetStoryFolderStories(string storyFolderID) { - IEnumerable result = null; + public IEnumerable GetRundownsByPlaceHolderId(string id) { + IEnumerable result = null; try { - var request = new RestRequest("storiesByStoryFolderID/{storyFolderID}", Method.GET); - request.AddParameter("storyFolderID", storyFolderID, ParameterType.UrlSegment); + var request = new RestRequest("rundownsByPlaceHolderID/{id}", Method.GET); + request.AddParameter(ID, id, ParameterType.UrlSegment); var response = client.Execute(request); if (!CheckResponse(response)) return null; JArray resultObject = JArray.Parse(response.Content); - result = resultObject.Children().Select(d => { - Story r = ToStoryFolderStory(d, storyFolderID); - logger.Debug($"{r}"); - return r; - }).OrderBy(r => { - return r.ID; - }); + result = resultObject.Children().Select(d => ToRundown(d)); } catch (Exception e) { OnError(e); @@ -140,18 +129,21 @@ namespace OctopusClient { return result; } - public IEnumerable getStoryFolders() { - IEnumerable result = null; + public IEnumerable GetRundownStories(string id) { + IEnumerable result = null; try { - var request = new RestRequest("storyfolders", Method.GET); + var request = new RestRequest("rundownStories/{id}", Method.GET); + request.AddParameter(ID, id, ParameterType.UrlSegment); var response = client.Execute(request); if (!CheckResponse(response)) return null; JArray resultObject = JArray.Parse(response.Content); result = resultObject.Children().Select(d => { - StoryFolder r = ToStoryFolder(d); + Story r = ToRundownStory(d, id); //logger.Debug($"{r}"); return r; + }).OrderBy(r => { + return r.ID; }); } catch (Exception e) { @@ -160,18 +152,21 @@ namespace OctopusClient { return result; } - public IEnumerable GetStories() { + public IEnumerable GetStoriesByID(string id) { IEnumerable result = null; try { - var request = new RestRequest("stories", Method.GET); + var request = new RestRequest("rundownStories/{id}", Method.GET); + request.AddParameter(ID, id, ParameterType.UrlSegment); var response = client.Execute(request); if (!CheckResponse(response)) return null; JArray resultObject = JArray.Parse(response.Content); result = resultObject.Children().Select(d => { - Story r = ToStory(d); - logger.Debug($"{r}"); + Story r = ToRundownStory(d, id); + //logger.Debug($"{r}"); return r; + }).OrderBy(r => { + return r.ID; }); } catch (Exception e) { @@ -180,11 +175,11 @@ namespace OctopusClient { return result; } - public IEnumerable GetStoriesById(String id) { + public IEnumerable GetStoriesByParentStoryID(String id) { IEnumerable result = null; try { - var request = new RestRequest("getStoriesByID/{id}", Method.GET); - request.AddParameter("id", id, ParameterType.UrlSegment); + var request = new RestRequest("storiesByParentStoryID/{id}", Method.GET); + request.AddParameter(ID, id, ParameterType.UrlSegment); var response = client.Execute(request); if (!CheckResponse(response)) return null; @@ -201,11 +196,11 @@ namespace OctopusClient { return result; } - public IEnumerable GetStoriesByParentStoryId(String id) { + public IEnumerable GetStoriesByPlaceHolderID(string placeHolderID) { IEnumerable result = null; try { - var request = new RestRequest("getStoriesByParentStoryID/{id}", Method.GET); - request.AddParameter("id", id, ParameterType.UrlSegment); + var request = new RestRequest("storiesByPlaceHolderID/{id}", Method.GET); + request.AddParameter(ID, placeHolderID, ParameterType.UrlSegment); var response = client.Execute(request); if (!CheckResponse(response)) return null; @@ -214,6 +209,8 @@ namespace OctopusClient { Story r = ToStory(d); //logger.Debug($"{r}"); return r; + }).OrderBy(r => { + return r.ID; }); } catch (Exception e) { @@ -222,22 +219,17 @@ namespace OctopusClient { return result; } - public IEnumerable GetStoryFoldersByStoryID(String id) { + public IEnumerable getStoryFolders() { IEnumerable result = null; try { - var request = new RestRequest("getStoryFolders/{id}", Method.GET); - request.AddParameter("id", id, ParameterType.UrlSegment); + var request = new RestRequest("storyFolders", Method.GET); var response = client.Execute(request); if (!CheckResponse(response)) return null; JArray resultObject = JArray.Parse(response.Content); result = resultObject.Children().Select(d => { - StoryFolder r = new StoryFolder { - ID = d["id"].ToString(), - Name = String.IsNullOrEmpty(d["name"].ToString()) ? OctopusAPI.UNNAMED : d["name"].ToString() - }; - - logger.Debug($"{r}"); + StoryFolder r = ToStoryFolder(d); + //logger.Debug($"{r}"); return r; }); } @@ -247,41 +239,18 @@ namespace OctopusClient { return result; } - public IEnumerable GetRundownsByStoryID(String id) { - IEnumerable result = null; - try { - var request = new RestRequest("getRundownByStoryID/{id}", Method.GET); - request.AddParameter("id", id, ParameterType.UrlSegment); - var response = client.Execute(request); - if (!CheckResponse(response)) - return null; - JArray resultObject = JArray.Parse(response.Content); - result = resultObject.Children().Select(d => ToRundown(d)); - } - catch (Exception e) { - OnError(e); - } - return result; - } - - public IEnumerable GetMosObjectsByID(String id) { - IEnumerable result = null; + public IEnumerable GetStoryFoldersByPlaceHolderID(string id) { + IEnumerable result = null; try { - var request = new RestRequest("getMosObjectsByID/{id}", Method.GET); - request.AddParameter("id", id, ParameterType.UrlSegment); + var request = new RestRequest("storyFoldersByPlaceHolderID/{id}", Method.GET); + request.AddParameter(ID, id, ParameterType.UrlSegment); var response = client.Execute(request); if (!CheckResponse(response)) return null; JArray resultObject = JArray.Parse(response.Content); result = resultObject.Children().Select(d => { - MosObject r = new MosObject { - ID = d["id"].ToString(), - GlobalID = d["globalId"].ToString(), - MosID = d["mosId"].ToString(), - ObjectType = d["objectType"].ToString(), - ObjID = d["objId"].ToString() - }; - logger.Debug($"{r}"); + StoryFolder r = ToStoryFolder(d); + //logger.Debug($"{r}"); return r; }); } @@ -291,35 +260,21 @@ namespace OctopusClient { return result; } - public IEnumerable GetRundownsByPlaceHolderId(string placeHolderID) { - IEnumerable result = null; - try { - var request = new RestRequest("getRundownsByPlaceHolderId/{id}", Method.GET); - request.AddParameter("id", placeHolderID, ParameterType.UrlSegment); - var response = client.Execute(request); - if (!CheckResponse(response)) - return null; - JArray resultObject = JArray.Parse(response.Content); - result = resultObject.Children().Select(d => ToRundown(d)); - } - catch (Exception e) { - OnError(e); - } - return result; - } - - - public IEnumerable GetStoryFoldersByPlaceHolderId(string placeHolderID) { + public IEnumerable GetStoryFoldersByParentStoryID(String id) { IEnumerable result = null; try { - var request = new RestRequest("getStoryFoldersByPlaceHolderId/{id}", Method.GET); - request.AddParameter("id", placeHolderID, ParameterType.UrlSegment); + var request = new RestRequest("storyFoldersByParentStoryID/{id}", Method.GET); + request.AddParameter(ID, id, ParameterType.UrlSegment); var response = client.Execute(request); if (!CheckResponse(response)) return null; JArray resultObject = JArray.Parse(response.Content); result = resultObject.Children().Select(d => { - StoryFolder r = ToStoryFolder(d); + StoryFolder r = new StoryFolder { + ID = d[ID].ToString(), + Name = String.IsNullOrEmpty(d["name"].ToString()) ? OctopusAPI.UNNAMED : d["name"].ToString() + }; + //logger.Debug($"{r}"); return r; }); @@ -330,17 +285,17 @@ namespace OctopusClient { return result; } - public IEnumerable GetStoriesByPlaceHolderId(string placeHolderID) { + public IEnumerable GetStoryFolderStories(string id) { IEnumerable result = null; try { - var request = new RestRequest("getStoriesByPlaceHolderId/{id}", Method.GET); - request.AddParameter("id", placeHolderID, ParameterType.UrlSegment); + var request = new RestRequest("storyFolderStories/{id}", Method.GET); + request.AddParameter(ID, id, ParameterType.UrlSegment); var response = client.Execute(request); if (!CheckResponse(response)) return null; JArray resultObject = JArray.Parse(response.Content); result = resultObject.Children().Select(d => { - Story r = ToStory(d); + Story r = ToStoryFolderStory(d, id); //logger.Debug($"{r}"); return r; }).OrderBy(r => { @@ -373,50 +328,74 @@ namespace OctopusClient { return d["mosObjects"]?.Select(t => ToMosObject(t)); } - private static IEnumerable GetStoryFolderFromStory(JToken d) { + private static IEnumerable GetPartialStoryFolderFromStory(JToken d) { return d["story_folder"]?.Select(t => ToPartialStoryFolder(t)); } - private static IEnumerable GetRundownFromStory(JToken d) { + private static IEnumerable GetPartialRundownFromStory(JToken d) { return d["rundown"]?.Select(t => ToPartialRundown(t)); } + private static IEnumerable GetStoryFolderFromStory(JToken d) { + return d["story_folder"]?.Select(t => ToStoryFolder(t)); + } + + private static IEnumerable GetRundownFromStory(JToken d) { + return d["rundown"]?.Select(t => ToRundown(t)); + } + private static StoryFolder ToStoryFolder(JToken d) { return new StoryFolder() { - ID = d.Value("id"), + ID = d.Value(ID), Name = d.Value("name") }; } private static StoryFolder ToPartialStoryFolder(JToken d) { return new StoryFolder() { - ID = d.Value("id"), + ID = d.Value(ID), StoryPosition = d.Value("position") }; } private static Rundown ToPartialRundown(JToken d) { return new Rundown() { - ID = d.Value("id"), + ID = d.Value(ID), StoryPosition = d.Value("position") }; } private static Story ToRundownStory(JToken d, string id) { - Story result = ToStory(d); + Story result = ToPartialStory(d); result.Position = result.Rundowns.Where(r => id.Equals(r.ID)).FirstOrDefault()?.StoryPosition; return result; } private static Story ToStoryFolderStory(JToken d, string id) { - Story result = ToStory(d); + Story result = ToPartialStory(d); result.Position = result.StoryFolders.Where(r => id.Equals(r.ID)).FirstOrDefault()?.StoryPosition; return result; } + private static Story ToPartialStory(JToken d) { + Story result = new Story { + ID = d[ID]?.ToString(), + ParentStoryID = d["parentStoryId"]?.ToString(), + Name = d["name"]?.ToString() ?? UNNAMED, + Format = d["format"]?.ToString(), + Script = d["script"]?.ToString(), + ScriptContent = d["script_content"]?.ToString(), + MosObjects = GetMosObjectsFromStory(d)?.ToArray(), + StoryFolders = GetPartialStoryFolderFromStory(d)?.ToArray(), + Rundowns = GetPartialRundownFromStory(d)?.ToArray() + }; + + return result; + } + private static Story ToStory(JToken d) { Story result = new Story { - ID = d["id"]?.ToString(), + ID = d[ID]?.ToString(), ParentStoryID = d["parentStoryId"]?.ToString(), Name = d["name"]?.ToString() ?? UNNAMED, Format = d["format"]?.ToString(), @@ -426,13 +405,12 @@ namespace OctopusClient { StoryFolders = GetStoryFolderFromStory(d)?.ToArray(), Rundowns = GetRundownFromStory(d)?.ToArray() }; - return result; } private static Rundown ToRundown(JToken d) { Rundown result = new Rundown { - ID = d["id"].ToString(), + ID = d[ID].ToString(), Name = d["name"]?.ToString() ?? UNNAMED, Start = DateTime.Parse(d["scheduledStart"]?.ToString()), }; @@ -446,7 +424,7 @@ namespace OctopusClient { private static MosObject ToMosObject(JToken d) { return new MosObject() { GlobalID = d.Value("globalId"), - ID = d.Value("id"), + ID = d.Value(ID), MosID = d.Value("mosId"), ObjectType = d.Value("objectType"), ObjID = d.Value("objId") diff --git a/client/OctopusClient/OctopusIDSelector.cs b/client/OctopusClient/OctopusIDSelector.cs index 8d046f1d..77f6cafc 100644 --- a/client/OctopusClient/OctopusIDSelector.cs +++ b/client/OctopusClient/OctopusIDSelector.cs @@ -96,6 +96,7 @@ namespace OctopusClient { treeOctopus.AfterCheck += OnTreeAfterCheck; selectedNode = null; IDChangedEvent?.Invoke(null, null, null); + txtFilter.Text = null; } private void RefreshPlaceHolderIDS(String ID) { @@ -114,6 +115,12 @@ namespace OctopusClient { private void treeContent_KeyDown(object sender, KeyEventArgs e) { //this.OnKeyDown(e); + if (e.KeyCode != Keys.F5) + return; + if (String.IsNullOrEmpty(txtFilter.Text)) + RefreshStories(); + else + Lookup(); } private void AddStories(IEnumerable stories, bool isFolderView = false) { @@ -207,11 +214,18 @@ namespace OctopusClient { public void LookupByStory(string storyId) { if (String.IsNullOrEmpty(storyId)) return; - var rundown = client.GetRundownsByStoryID(storyId)?.FirstOrDefault(); + ClearSelection(); + lookupStoryId = null; + lookupPlaceHolderId = null; + var rundown = client.GetRundownsByParentStoryID(storyId)?.FirstOrDefault(); if (rundown == null) { - var storyFolder = client.GetStoryFoldersByStoryID(storyId)?.FirstOrDefault(); + var storyFolder = client.GetStoryFoldersByParentStoryID(storyId)?.FirstOrDefault(); if (storyFolder != null) { + refreshDisabled = true; + bool forceRefresh = rbStoryFolder.Checked; rbStoryFolder.Checked = true; + refreshDisabled = false; + RefreshFolders(); List storyFolders = cbFolders.DataSource as List; if (storyFolders != null) { var folderToSelect = storyFolders.Where(f => f.ID.Equals(storyFolder.ID)).FirstOrDefault(); @@ -224,8 +238,9 @@ namespace OctopusClient { } else { refreshDisabled = true; dtScheduled.Value = rundown.Start; - refreshDisabled = false; rbRundown.Checked = true; + refreshDisabled = false; + RefreshFolders(); List rundowns = cbFolders.DataSource as List; if (rundowns != null) { var rundownToSelect = rundowns.Where(f => f.ID.Equals(rundown.ID)).FirstOrDefault(); @@ -235,20 +250,28 @@ namespace OctopusClient { } } } - txtFilter.Text = lookupStoryId; - lookupStoryId = null; + txtFilter.Text = storyId; if (selectedNode == null) MessageBox.Show("Nincs találat."); + else + treeOctopus.Focus(); } public void LookupByPlaceHolder(string placeHolderId) { if (String.IsNullOrEmpty(placeHolderId)) return; + ClearSelection(); + lookupStoryId = null; + lookupPlaceHolderId = null; var rundown = client.GetRundownsByPlaceHolderId(placeHolderId)?.FirstOrDefault(); if (rundown == null) { - var storyFolder = client.GetStoryFoldersByPlaceHolderId(placeHolderId)?.FirstOrDefault(); + var storyFolder = client.GetStoryFoldersByPlaceHolderID(placeHolderId)?.FirstOrDefault(); if (storyFolder != null) { + refreshDisabled = true; + bool forceRefresh = rbStoryFolder.Checked; rbStoryFolder.Checked = true; + refreshDisabled = false; + RefreshFolders(); List storyFolders = cbFolders.DataSource as List; if (storyFolders != null) { var folderToSelect = storyFolders.Where(f => f.ID.Equals(storyFolder.ID)).FirstOrDefault(); @@ -262,8 +285,9 @@ namespace OctopusClient { } else { refreshDisabled = true; dtScheduled.Value = rundown.Start; - refreshDisabled = false; rbRundown.Checked = true; + refreshDisabled = false; + RefreshFolders(); List rundowns = cbFolders.DataSource as List; if (rundowns != null) { var rundownToSelect = rundowns.Where(f => f.ID.Equals(rundown.ID)).FirstOrDefault(); @@ -274,10 +298,11 @@ namespace OctopusClient { } } - txtFilter.Text = lookupPlaceHolderId; - lookupPlaceHolderId = null; + txtFilter.Text = placeHolderId; if (selectedNode == null) MessageBox.Show("Nincs találat."); + else + treeOctopus.Focus(); } private void OnTypeCheckChanged(object sender, EventArgs e) { @@ -322,6 +347,10 @@ namespace OctopusClient { } private void OnSelectedFolderChanged(object sender, EventArgs e) { + RefreshStories(); + } + + private void RefreshStories() { IEnumerable stories = null; treeOctopus.Nodes.Clear(); if (rbRundown.Checked) { @@ -348,8 +377,12 @@ namespace OctopusClient { } private void OnFilterKeyDown(object sender, KeyEventArgs e) { - if (String.IsNullOrEmpty(txtFilter.Text) || e.KeyCode != Keys.Return) + if (e.KeyCode != Keys.Return || String.IsNullOrEmpty(txtFilter.Text)) return; + Lookup(); + } + + private void Lookup() { if (txtFilter.Text.Contains("_")) LookupByPlaceHolder(txtFilter.Text); else diff --git a/client/PlanAIRClient/TrafficIDSelector.Designer.cs b/client/PlanAIRClient/TrafficIDSelector.Designer.cs index dbddf5af..d434460b 100644 --- a/client/PlanAIRClient/TrafficIDSelector.Designer.cs +++ b/client/PlanAIRClient/TrafficIDSelector.Designer.cs @@ -29,9 +29,9 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); this.trafficAPIBindingSource = new System.Windows.Forms.BindingSource(this.components); this.dtScheduled = new System.Windows.Forms.DateTimePicker(); this.txtFilter = new System.Windows.Forms.TextBox(); @@ -180,23 +180,23 @@ this.dgTraffic.BackgroundColor = System.Drawing.Color.White; this.dgTraffic.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dgTraffic.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.Raised; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); - dataGridViewCellStyle4.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgTraffic.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgTraffic.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dgTraffic.DataSource = this.trafficAPIBindingSource; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle5.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); - dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.ControlText; - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.Gainsboro; - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.Black; - dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgTraffic.DefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.Gainsboro; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.Black; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgTraffic.DefaultCellStyle = dataGridViewCellStyle2; this.dgTraffic.Dock = System.Windows.Forms.DockStyle.Fill; this.dgTraffic.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dgTraffic.EnableHeadersVisualStyles = false; @@ -205,8 +205,8 @@ this.dgTraffic.MultiSelect = false; this.dgTraffic.Name = "dgTraffic"; this.dgTraffic.RowHeadersVisible = false; - dataGridViewCellStyle6.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); - this.dgTraffic.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); + this.dgTraffic.RowsDefaultCellStyle = dataGridViewCellStyle3; this.dgTraffic.RowTemplate.DefaultCellStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F); this.dgTraffic.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgTraffic.Size = new System.Drawing.Size(300, 322); diff --git a/client/PlanAIRClient/TrafficIDSelector.cs b/client/PlanAIRClient/TrafficIDSelector.cs index 81dc0c07..c3fd5de3 100644 --- a/client/PlanAIRClient/TrafficIDSelector.cs +++ b/client/PlanAIRClient/TrafficIDSelector.cs @@ -115,6 +115,8 @@ namespace TrafficClient { private void OnDataGridKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Space && dgTraffic.CurrentCell.ColumnIndex != 0) OnSelectionChanged(dgTraffic.SelectedRows[0]); + if (e.KeyCode == Keys.F5) + RefreshResults(); } private void dtScheduled_ValueChanged(object sender, EventArgs e) { @@ -152,6 +154,7 @@ namespace TrafficClient { public bool LookupByADID(string id) { return false; } + } public class TrafficItem { diff --git a/server/-configuration/log4j2.xml b/server/-configuration/log4j2.xml index 9e0ab538..81aa0cd2 100644 --- a/server/-configuration/log4j2.xml +++ b/server/-configuration/log4j2.xml @@ -47,7 +47,7 @@ - + diff --git a/server/-configuration/scheduledjobs.json b/server/-configuration/scheduledjobs.json index 452149c3..01d40197 100644 --- a/server/-configuration/scheduledjobs.json +++ b/server/-configuration/scheduledjobs.json @@ -85,7 +85,7 @@ "name" : "Teszt folyamat", "template": "fake.xml", "executeimmediate": false, - "cronexpression": "0/10 * * ? * *", + "cronexpression": "* 0/1 * ? * *", "parameters": [ {"name": "itemID", "value": 1, "type": "java.lang.Long"} ] } ]} diff --git a/server/-modules/pom.xml b/server/-modules/pom.xml index e8060fb4..e9cb460d 100644 --- a/server/-modules/pom.xml +++ b/server/-modules/pom.xml @@ -26,7 +26,8 @@ UTF-8 scp://root:password@10.10.1.27 - ssh-ed25519 256 ea:ab:67:70:79:63:2f:6a:34:81:48:e2:b9:dd:ca:d4 + + ssh-ed25519 256 ea:58:1c:d3:b8:d5:7a:92:4c:a3:a5:8d:e2:7b:07:fd diff --git a/server/-product/mediacube.product b/server/-product/mediacube.product index da453c87..9d427d6f 100644 --- a/server/-product/mediacube.product +++ b/server/-product/mediacube.product @@ -9,45 +9,45 @@ -consoleLog -console 5555 - -Xms512m --Xmx1024m --Dfile.encoding=UTF-8 --agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8888 --Djavax.ws.rs.ext.RuntimeDelegate=org.jboss.resteasy.spi.ResteasyProviderFactory - -#System --Djetty.home=/opt/mediacube/configuration/jetty --Dlog4j.configurationFile=/opt/mediacube/configuration/log4j2.xml --Djobengine.jobsteps.root=/opt/mediacube/configuration/executors --Djobengine.jobtemplates.root=/opt/mediacube/configuration/jobtemplates --Djobengine.jobscheduling.config=/opt/mediacube/configuration/scheduledjobs.json - --Dorg.eclipse.equinox.http.jetty.http.port=80 --Dorg.eclipse.epp.logging.aeri.skipReports=true --Declipse.ignoreApp=true --Dosgi.noShutdown=true --Djobengine.loglevel=INFO --Djetty.etc.config.urls=etc/user-jetty.xml,etc/user-jetty-ssl.xml,etc/user-jetty-ssl-context.xml,etc/user-jetty-http.xml,etc/user-jetty-https.xml - - #Database --Djobengine.db.url=jdbc:db2://localhost:50000/mc:retrieveMessagesFromServerOnGetMessage=true; --Djobengine.db.user=db2admin --Djobengine.db.password=password --Djobengine.nosql.db.url=jdbc:db2://localhost:50000/mc:retrieveMessagesFromServerOnGetMessage=true; --Djobengine.nosql.db.user=db2admin --Djobengine.nosql.db.password=password --Djobengine.nosql.db.schema=test + -Xms512m +-Xmx1024m +-Dfile.encoding=UTF-8 +-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8888 +-Djavax.ws.rs.ext.RuntimeDelegate=org.jboss.resteasy.spi.ResteasyProviderFactory -#Octopus --Djobengine.octopus.api.address=http://10.10.1.11/api/v1 --Djobengine.octopus.api.user=mam --Djobengine.octopus.api.password=napocska - -#Selenio --Djobengine.selenio.address=http://10.10.1.71:44000/TranscodeMgrWS?wsdl --Djobengine.selenio.projectfilepath=\\10.10.1.71\Data\Blueprints\MP4_H264_AAC_v4.zenium +#System +-Djetty.home=/opt/mediacube/configuration/jetty +-Dlog4j.configurationFile=/opt/mediacube/configuration/log4j2.xml +-Djobengine.jobsteps.root=/opt/mediacube/configuration/executors +-Djobengine.jobtemplates.root=/opt/mediacube/configuration/jobtemplates +-Djobengine.jobscheduling.config=/opt/mediacube/configuration/scheduledjobs.json -#Nexio +-Dorg.eclipse.equinox.http.jetty.http.port=80 +-Dorg.eclipse.epp.logging.aeri.skipReports=true +-Declipse.ignoreApp=true +-Dosgi.noShutdown=true +-Djobengine.loglevel=INFO +-Djetty.etc.config.urls=etc/user-jetty.xml,etc/user-jetty-ssl.xml,etc/user-jetty-ssl-context.xml,etc/user-jetty-http.xml,etc/user-jetty-https.xml + + #Database +-Djobengine.db.url=jdbc:db2://localhost:50000/mc:retrieveMessagesFromServerOnGetMessage=true; +-Djobengine.db.user=db2admin +-Djobengine.db.password=password +-Djobengine.nosql.db.url=jdbc:db2://localhost:50000/mc:retrieveMessagesFromServerOnGetMessage=true; +-Djobengine.nosql.db.user=db2admin +-Djobengine.nosql.db.password=password +-Djobengine.nosql.db.schema=test + +#Octopus +-Djobengine.octopus.api.address=http://10.10.1.11/api/v1 +-Djobengine.octopus.api.user=mam +-Djobengine.octopus.api.password=napocska + +#Selenio +-Djobengine.selenio.address=http://10.10.1.71:44000/TranscodeMgrWS?wsdl +-Djobengine.selenio.projectfilepath=\\10.10.1.71\Data\Blueprints\MP4_H264_AAC_v3.zenium + +#Nexio -Dnexio.host=10.10.1.55 -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts diff --git a/server/user.commons.log4j2/src/user/commons/log4j2/appender/HTMLMailAppender.java b/server/user.commons.log4j2/src/user/commons/log4j2/appender/HTMLMailAppender.java index 470bf16b..7a4dffbf 100644 --- a/server/user.commons.log4j2/src/user/commons/log4j2/appender/HTMLMailAppender.java +++ b/server/user.commons.log4j2/src/user/commons/log4j2/appender/HTMLMailAppender.java @@ -40,6 +40,8 @@ public final class HTMLMailAppender extends AbstractAppender { private static final int DEFAULT_BUFFER_SIZE = 512; + private static final ExecutorService executor = Executors.newFixedThreadPool(5); + /** * Create a SmtpAppender. * @@ -119,8 +121,6 @@ public final class HTMLMailAppender extends AbstractAppender { /** The SMTP Manager */ private final SmtpManager manager; - private final ExecutorService executor = Executors.newFixedThreadPool(5); - private HTMLMailAppender(final String name, final Filter filter, final Layout layout, final SmtpManager manager, final boolean ignoreExceptions) { super(name, filter, layout, ignoreExceptions); @@ -135,9 +135,10 @@ public final class HTMLMailAppender extends AbstractAppender { */ @Override public void append(final LogEvent event) { - + //System.out.println("append " + event.getMessage().getFormattedMessage()); + final LogEvent eventToSend = event.toImmutable(); executor.submit(() -> { - manager.sendEvents(getLayout(), event); + manager.sendEvents(getLayout(), eventToSend); }); } @@ -155,6 +156,8 @@ public final class HTMLMailAppender extends AbstractAppender { // if (filtered) { // manager.add(event); // } + + //System.out.println("isFiltered"); return filtered; } } diff --git a/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java b/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java index f276ab33..134524ba 100644 --- a/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java +++ b/server/user.commons.log4j2/src/user/commons/log4j2/appender/SmtpManager.java @@ -49,7 +49,6 @@ import org.apache.logging.log4j.core.impl.MutableLogEvent; import org.apache.logging.log4j.core.layout.AbstractStringLayout.Serializer; import org.apache.logging.log4j.core.layout.PatternLayout; import org.apache.logging.log4j.core.net.MimeMessageBuilder; -import org.apache.logging.log4j.core.util.CyclicBuffer; import org.apache.logging.log4j.core.util.NameUtil; import org.apache.logging.log4j.core.util.NetUtils; import org.apache.logging.log4j.message.ReusableMessage; @@ -208,7 +207,7 @@ public class SmtpManager extends AbstractManager { private final Session session; - private final CyclicBuffer buffer; + //private final CyclicBuffer buffer; private volatile MimeMessage message; @@ -219,7 +218,7 @@ public class SmtpManager extends AbstractManager { this.session = session; this.message = message; this.data = data; - this.buffer = new CyclicBuffer<>(LogEvent.class, data.numElements); + //this.buffer = new CyclicBuffer<>(LogEvent.class, data.numElements); } public void add(LogEvent event) { @@ -228,7 +227,7 @@ public class SmtpManager extends AbstractManager { } else if (event instanceof MutableLogEvent) { event = ((MutableLogEvent) event).createMemento(); } - buffer.add(event); + //buffer.add(event); } private synchronized void connect(final LogEvent appendEvent) { @@ -298,10 +297,10 @@ public class SmtpManager extends AbstractManager { message.setRecipient(RecipientType.TO, new InternetAddress(mcm.getTo())); } - final LogEvent[] priorEvents = buffer.removeAll(); + //final LogEvent[] priorEvents = buffer.removeAll(); // LOG4J-310: log appendEvent even if priorEvents is empty - final byte[] rawBytes = formatContentToBytes(priorEvents, appendEvent, layout); + final byte[] rawBytes = formatContentToBytes(null, appendEvent, layout); final String contentType = layout.getContentType(); final String encoding = getEncoding(rawBytes, contentType); diff --git a/server/user.jobengine.executors/config/config.xml b/server/user.jobengine.executors/config/config.xml index b0c2901f..ddf4d6ba 100644 --- a/server/user.jobengine.executors/config/config.xml +++ b/server/user.jobengine.executors/config/config.xml @@ -10,6 +10,6 @@ - + \ No newline at end of file diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java index 1b10a174..151a5020 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/FakeStep.java @@ -3,9 +3,6 @@ package user.jobengine.server.steps; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import com.ibm.nosql.json.JSONUtil; -import com.ibm.nosql.json.api.BasicDBObject; - import user.jobengine.server.IJobEngine; import user.jobengine.server.IJobRuntime; @@ -16,15 +13,16 @@ public class FakeStep extends JobStep { @StepEntry public Object[] execute(long itemID, IJobEngine jobEngine, IJobRuntime jobRuntime) { try { - logger.warn("Starting Fake step"); - String json = "{ houseID: '111222' }"; - BasicDBObject o = (BasicDBObject) JSONUtil.jsonToDbObject(json); for (int i = 0; i < count; i++) { if (!canContinue()) break; jobRuntime.incrementProgress((i + 1) * count); - Thread.sleep(10000); - // logger.info("Progress {}", jobRuntime.getProgress()); + Thread.sleep(100); + logger.info(getMarker(), "Log markered"); + logger.info("Progress {}", jobRuntime.getProgress()); + logger.info("Progress {}", jobRuntime.getProgress()); + logger.info("Progress {}", jobRuntime.getProgress()); + logger.info("Progress {}", jobRuntime.getProgress()); } } catch (Exception e) { logger.error(e.getMessage()); 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 038a8783..3266b69c 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 @@ -6,30 +6,61 @@ import java.util.List; import com.ibm.nosql.json.api.DBObject; public interface IOctopusAPI { + static final String RUNDOWN_COLLECTION_NAME = "rundowns"; + static final String STORY_COLLECTION_NAME = "stories"; + static final String STORY_FOLDER_COLLECTION_NAME = "story_folders"; + static final String TIME_COLLECTION_NAME = "time"; + static final String LASTUPDATE_TIME = "lastUpdateTime"; + static final String NEXIO_MOS = "NEXIO.MOS"; + static final String PARENT_STORY_ID = "parentStoryId"; + static final String VALUE = "value"; + static final String CUSTOM_COLUMNS = "customColumns"; + static final String MOS_ID = "mosId"; + static final String MOS_OBJECTS = "mosObjects"; + static final String NAME = "name"; + static final String LABEL = "label"; + static final String OBJ_ID = "objId"; + static final String OBJECT = "object"; + static final String MOS = "mos"; + static final String TEXT = "text"; + static final String TYPE = "type"; + static final String CONTENT = "content"; + static final String BODY = "body"; + static final String SCRIPT = "script"; + static final String REF_RUNDOWN = "rundown"; + static final String REF_STORYFOLDER = "story_folder"; + static final String POSITION = "position"; + static final String STORY = "story"; + static final String SCHEDULED_START = "scheduledStart"; + static final String SLUGS = "slugs"; + static final String MODIFIED = "modified"; + static final String STORIES = "stories"; + static final String ID = "id"; + static final String _ID = "_id"; + static final String STORYID = "storyId"; + static final String FORMAT = "format"; - List getMosObjectsByID(String id); + List getRundowns(Date scheduledDate); - List getRundownByStoryID(long storyID); + List getRundownsByParentStoryID(String storyID); - List getRundowns(Date scheduledDate); + List getRundownsByPlaceHolderID(String placeHolderID); - List getRundownsByPlaceHolderId(String placeHolderID); + List getRundownStories(long id); List getStories(); - List getStories(long rundownID); - List getStoriesByID(String id); List getStoriesByParentStoryID(String id); - List getStoriesByPlaceHolderId(String placeHolderID); - - List getStoriesByStoryFolderId(long storyFolderID); + List getStoriesByPlaceHolderID(String placeHolderID); List getStoryFolders(); - List getStoryFolders(long storyID); + List getStoryFoldersByParentStoryID(String id); + + List getStoryFoldersByPlaceHolderID(String placeHolderID); - List getStoryFoldersByPlaceHolderId(String placeHolderID); + List getStoryFolderStories(long storyFolderID); } 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 36d4e792..fa6674af 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 @@ -18,79 +18,36 @@ import user.commons.CalendarUtils; import user.commons.nosql.NoSQLUtils; public class OctopusAPI implements IOctopusAPI { - private static final String _ID = "_id"; - private static final String OBJID = "objId"; + //private static final Logger logger = LogManager.getLogger(); private static final String $DATE = "$date"; - private static final String SCHEDULEDSTART = "scheduledStart"; - private static final String STORYID = "storyId"; private static final String $ELEMMATCH = "$elemMatch"; - //private static final Logger logger = LogManager.getLogger(); - private static final String SLUGS = "slugs"; - private static final String ID = "id"; - private static final String STORY_FOLDER = "story_folder"; - private static final String MOSOBJECTS = "mosObjects"; - private static final String RUNDOWN = "rundown"; - public static final String RUNDOWN_COLLECTION_NAME = "rundowns"; - public static final String STORY_COLLECTION_NAME = "stories"; - public static final String STORY_FOLDER_COLLECTION_NAME = "story_folders"; - public static final String TIME_COLLECTION_NAME = "time"; private DB db; public OctopusAPI() throws SQLException { db = NoSQLUtils.getDB(); } - private List getIDsFromReferences(List list, String referenceName) { - List result = new ArrayList<>(); - for (DBObject dbObject : list) { - BasicDBObject object = (BasicDBObject) dbObject; - BasicDBList l = (BasicDBList) object.get(referenceName); - BasicDBObject o = (BasicDBObject) l.get(0); - long id = o.getLong("id"); - result.add(id); - } - return result; - } - - @Override - public List getMosObjectsByID(String id) { - List result = null; - List mosObjectsResult = new ArrayList<>(); - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); - DBCursor find = collection - .find(new BasicDBObject(MOSOBJECTS, new BasicDBObject($ELEMMATCH, new BasicDBObject(ID, id))), - new BasicDBObject(ID, 1).append("name", 1).append("modified", 1).append(STORY_FOLDER, 1).append("type", 1).append("mosObjects", 1)) - .sort(new BasicDBObject("name", 1)); - if (find.hasNext()) - // return the story - result = find.toArray(); - for (DBObject actual : result) { - BasicDBList actualList = (BasicDBList) actual.get("mosObjects"); - if (!actualList.isEmpty()) { - List mosObjectList = NoSQLUtils.asList(actualList); - for (BasicDBObject actualMosObject : mosObjectList) { - long mosID = actualMosObject.getLong(ID); - if (id.equals(String.format("%d", mosID))) - mosObjectsResult.add(actualMosObject); - } + private void addReferences(List result) { + for (DBObject storyObject : result) { + if (storyObject == null) + continue; + BasicDBObject story = (BasicDBObject) storyObject; + if (story.containsKey(REF_RUNDOWN) && story.get(REF_RUNDOWN) != null) { + List rundowns = getReferencedObjects(result, RUNDOWN_COLLECTION_NAME, REF_RUNDOWN); + story.put(REF_RUNDOWN, rundowns); + } + if (story.containsKey(REF_STORYFOLDER) && story.get(REF_STORYFOLDER) != null) { + List storyFolders = getReferencedObjects(result, STORY_FOLDER_COLLECTION_NAME, REF_STORYFOLDER); + story.put(REF_STORYFOLDER, storyFolders); } } - return mosObjectsResult; - } - - private List getParentsByReferences(List references, DBCollection collection, String referenceName) { - List result = null; - List rundownIDs = getIDsFromReferences(references, referenceName); - BasicDBObject query = (BasicDBObject) QueryBuilder.start().put(ID).in(rundownIDs).get(); - DBCursor find = collection.find(query); - if (find.hasNext()) - result = find.toArray(); - return result; } private List getReferencedObjects(List stories, String referenceCollectionName, String referenceField) { List ids = null; for (DBObject story : stories) { + if (story == null) + continue; List references = NoSQLUtils.asList((BasicDBObject) story, referenceField); if (references == null) continue; @@ -103,7 +60,8 @@ public class OctopusAPI implements IOctopusAPI { ids.add(id); } } - + if (ids == null) + return null; List result = null; DBCollection rundownCollection = db.getCollection(referenceCollectionName); BasicDBObject query = (BasicDBObject) QueryBuilder.start().put(ID).in(ids).get(); @@ -113,16 +71,6 @@ public class OctopusAPI implements IOctopusAPI { return result; } - @Override - public List getRundownByStoryID(long storyID) { - List result = null; - DBCollection rundownCollection = db.getCollection(RUNDOWN_COLLECTION_NAME); - DBCursor find = rundownCollection.find(new BasicDBObject(SLUGS, new BasicDBObject($ELEMMATCH, new BasicDBObject(STORYID, storyID)))); - if (find.hasNext()) - result = find.toArray(); - return result; - } - @Override public List getRundowns(Date scheduledDate) { List result = null; @@ -136,50 +84,57 @@ public class OctopusAPI implements IOctopusAPI { if (scheduledDate == null) { query = builder.get(); } else { - query = builder.and(QueryBuilder.start(SCHEDULEDSTART).greaterThanEquals(calStart.getTime()).get(), - QueryBuilder.start(SCHEDULEDSTART).lessThan(calStop.getTime()).get()).get(); + query = builder.and(QueryBuilder.start(SCHEDULED_START).greaterThanEquals(calStart.getTime()).get(), + QueryBuilder.start(SCHEDULED_START).lessThan(calStop.getTime()).get()).get(); } //logger.info(query); - DBCursor find = collection.find(query).sort(new BasicDBObject(SCHEDULEDSTART, new BasicDBList(1, $DATE))); + DBCursor find = collection.find(query).sort(new BasicDBObject(SCHEDULED_START, new BasicDBList(1, $DATE))); if (find.hasNext()) result = find.toArray(); return result; } @Override - public List getRundownsByPlaceHolderId(String placeHolderID) { + public List getRundownsByParentStoryID(String id) { DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); + DBCursor find = storyCollection.find(new BasicDBObject(PARENT_STORY_ID, id), new BasicDBObject(REF_RUNDOWN, 1)); + if (!find.hasNext()) + return null; + return getReferencedObjects(find.toArray(), RUNDOWN_COLLECTION_NAME, REF_RUNDOWN); + } + + @Override + public List getRundownsByPlaceHolderID(String id) { //db.testStoryCollection.find({"mosObjects": {$elemMatch: {"globalId": "OCTOPUS-ECHOTV-2429902"}}}) - BasicDBObject criteria = new BasicDBObject(MOSOBJECTS, new BasicDBObject($ELEMMATCH, new BasicDBObject(OBJID, placeHolderID))); - BasicDBObject filter = new BasicDBObject(RUNDOWN, 1).append(_ID, 0); - DBCursor find = storyCollection.find(criteria, filter); + DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); + BasicDBObject criteria = new BasicDBObject(MOS_OBJECTS, new BasicDBObject($ELEMMATCH, new BasicDBObject(OBJ_ID, id))); + DBCursor find = storyCollection.find(criteria, new BasicDBObject(REF_RUNDOWN, 1)); if (!find.hasNext()) return null; - return getReferencedObjects(find.toArray(), RUNDOWN_COLLECTION_NAME, RUNDOWN); + return getReferencedObjects(find.toArray(), RUNDOWN_COLLECTION_NAME, REF_RUNDOWN); } @Override - public List getStories() { + public List getRundownStories(long id) { + // db.stories.find({ rundown: { $elemMatch: { id: 92950867 } }}) + // { rundown: { $elemMatch: { id: 44622396 } }} List result = null; DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); - DBCursor find = collection.find(); + DBCursor find = collection + .find(new BasicDBObject(REF_RUNDOWN, new BasicDBObject($ELEMMATCH, new BasicDBObject(ID, id))), new BasicDBObject(ID, 1) + .append(PARENT_STORY_ID, 1).append(NAME, 1).append(MODIFIED, 1).append(REF_RUNDOWN, 1).append(FORMAT, 1).append(MOS_OBJECTS, 1)) + .sort(new BasicDBObject("name", 1)); if (find.hasNext()) result = find.toArray(); return result; } @Override - public List getStories(long rundownID) { + public List getStories() { List result = null; DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); - // db.stories.find({ rundown: { $elemMatch: { id: 92950867 } }}) - - // { rundown: { $elemMatch: { id: 44622396 } }} - DBCursor find = collection - .find(new BasicDBObject(RUNDOWN, new BasicDBObject($ELEMMATCH, new BasicDBObject(ID, rundownID))), new BasicDBObject(ID, 1) - .append("parentStoryId", 1).append("name", 1).append("modified", 1).append(RUNDOWN, 1).append("format", 1).append("mosObjects", 1)) - .sort(new BasicDBObject("name", 1)); + DBCursor find = collection.find(); if (find.hasNext()) result = find.toArray(); return result; @@ -189,49 +144,38 @@ public class OctopusAPI implements IOctopusAPI { public List getStoriesByID(String id) { List result = null; DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); - //Pattern regex = Pattern.compile(id, Pattern.CASE_INSENSITIVE); - //BasicDBObject query = new BasicDBObject("id", Pattern.compile(id)); - DBCursor find = collection.find(new BasicDBObject("id", id)); - if (find.hasNext()) + DBCursor find = collection.find(new BasicDBObject(ID, id)); + if (find.hasNext()) { result = find.toArray(); + addReferences(result); + } return result; } @Override public List getStoriesByParentStoryID(String id) { - List result = null; - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); //Pattern regex = Pattern.compile(id, Pattern.CASE_INSENSITIVE); //BasicDBObject query = new BasicDBObject("id", Pattern.compile(id)); - DBCursor find = collection.find(new BasicDBObject("parentStoryId", id)); - if (find.hasNext()) + List result = null; + DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); + DBCursor find = collection.find(new BasicDBObject(PARENT_STORY_ID, id)); + if (find.hasNext()) { result = find.toArray(); + addReferences(result); + } return result; } @Override - public List getStoriesByPlaceHolderId(String placeHolderID) { + public List getStoriesByPlaceHolderID(String id) { List result = new ArrayList<>(); DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); - BasicDBObject globalId = new BasicDBObject(OBJID, placeHolderID); - BasicDBObject elemmatch = new BasicDBObject($ELEMMATCH, globalId); - BasicDBObject mosObjects = new BasicDBObject(MOSOBJECTS, elemmatch); - DBCursor find = storyCollection.find(mosObjects); - if (find.hasNext()) - result.add(find.next()); - return result; - } - - @Override - public List getStoriesByStoryFolderId(long storyFolderId) { - List result = null; - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); - DBCursor find = collection - .find(new BasicDBObject(STORY_FOLDER, new BasicDBObject($ELEMMATCH, new BasicDBObject(ID, storyFolderId))), new BasicDBObject(ID, 1) - .append("parentStoryId", 1).append("name", 1).append("modified", 1).append(STORY_FOLDER, 1).append("format", 1).append("mosObjects", 1)) - .sort(new BasicDBObject("name", 1)); - if (find.hasNext()) + BasicDBObject criteria = new BasicDBObject(MOS_OBJECTS, new BasicDBObject($ELEMMATCH, new BasicDBObject(OBJ_ID, id))); + DBCursor find = storyCollection.find(criteria); + if (find.hasNext()) { result = find.toArray(); + addReferences(result); + } return result; } @@ -246,24 +190,34 @@ public class OctopusAPI implements IOctopusAPI { } @Override - public List getStoryFolders(long storyID) { + public List getStoryFoldersByParentStoryID(String id) { DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); - BasicDBObject criteria = new BasicDBObject(ID, storyID); - BasicDBObject filter = new BasicDBObject(STORY_FOLDER, 1).append(_ID, 0); - DBCursor find = storyCollection.find(criteria, filter); + DBCursor find = storyCollection.find(new BasicDBObject(ID, id), new BasicDBObject(REF_STORYFOLDER, 1)); if (!find.hasNext()) return null; - return getReferencedObjects(find.toArray(), STORY_FOLDER_COLLECTION_NAME, STORY_FOLDER); + return getReferencedObjects(find.toArray(), STORY_FOLDER_COLLECTION_NAME, REF_STORYFOLDER); } @Override - public List getStoryFoldersByPlaceHolderId(String placeHolderID) { + public List getStoryFoldersByPlaceHolderID(String id) { DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); - BasicDBObject criteria = new BasicDBObject(MOSOBJECTS, new BasicDBObject($ELEMMATCH, new BasicDBObject(OBJID, placeHolderID))); - BasicDBObject filter = new BasicDBObject(STORY_FOLDER, 1).append(_ID, 0); - DBCursor find = storyCollection.find(criteria, filter); + BasicDBObject criteria = new BasicDBObject(MOS_OBJECTS, new BasicDBObject($ELEMMATCH, new BasicDBObject(OBJ_ID, id))); + DBCursor find = storyCollection.find(criteria, new BasicDBObject(REF_STORYFOLDER, 1)); if (!find.hasNext()) return null; - return getReferencedObjects(find.toArray(), STORY_FOLDER_COLLECTION_NAME, STORY_FOLDER); + return getReferencedObjects(find.toArray(), STORY_FOLDER_COLLECTION_NAME, REF_STORYFOLDER); + } + + @Override + public List getStoryFolderStories(long storyFolderId) { + List result = null; + DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); + DBCursor find = collection + .find(new BasicDBObject(REF_STORYFOLDER, new BasicDBObject($ELEMMATCH, new BasicDBObject(ID, storyFolderId))), new BasicDBObject(ID, 1) + .append(PARENT_STORY_ID, 1).append(NAME, 1).append(MODIFIED, 1).append(REF_STORYFOLDER, 1).append(FORMAT, 1).append(MOS_OBJECTS, 1)) + .sort(new BasicDBObject(NAME, 1)); + if (find.hasNext()) + result = find.toArray(); + return result; } } 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 a6c535ac..96760ebb 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 @@ -34,46 +34,21 @@ import user.commons.remotestore.IProgressEventListener; import user.commons.remotestore.ProgressEvent; public class OctopusDataMiner implements Runnable { - private static final String PARENT_STORY_ID = "parentStoryId"; - private static final String VALUE = "value"; - private static final String CUSTOM_COLUMNS = "customColumns"; - private static final String MOS_ID = "mosId"; - private static final String MOS_OBJECTS = "mosObjects"; - private static final String NAME = "name"; - private static final String LABEL = "label"; - private static final String SIMPLE_LINEFEED = "\n"; - private static final String MOSOBJECT = "Bejátszó: "; - private static final String OBJ_ID = "objId"; - private static final String OBJECT = "object"; + private static final Logger logger = LogManager.getLogger(); private static final String LINEFEED = "\r\n"; - private static final String MOS = "mos"; - private static final String TEXT = "text"; - private static final String TYPE = "type"; - private static final String CONTENT = "content"; - private static final String BODY = "body"; - private static final String SCRIPT = "script"; + private static final String SIMPLE_LINEFEED = "\n"; private static final String SCRIPT_CONTENT = "script_content"; - private static final Logger logger = LogManager.getLogger(); private static final String SAVING_STORY_ID = "Saving story {}"; private static final String SAVING_RUNDOWN = "Saving rundown : {} {}"; - private static final String REF_RUNDOWN = "rundown"; - private static final String REF_STORYFOLDER = "story_folder"; - private static final String POSITION = "position"; - private static final String STORY = "story"; - private static final String SCHEDULED_START = "scheduledStart"; - private static final String SLUGS = "slugs"; private static final String CHECKING_RUNDOWN = "Checking Rundown {} ({}/{})"; private static final String FIELDS_STORIES = "stories,Story.modified,Story.name,Story.id,Story.mosObjects,Story.script,Story.type,Story.format,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 RUNDOWN = "Rundown"; 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 RUNDOWN = "Rundown"; private static final String OCTOPUS_DEVICE_NAME = "Octopus-Device-Name"; private static final String OCTOPUS_DEVICE_ID = "Octopus-Device-Id"; private static final String FIELDS = "fields"; - private static final String MODIFIED = "modified"; - private static final String STORIES = "stories"; - private static final String ID = "id"; private static final String CHECKING_STORY_FOLDER = "Checking StoryFolder %s (%d/%d)"; private static final String EXIT = "Exit"; private static final String RESULT = "result"; @@ -81,13 +56,7 @@ public class OctopusDataMiner implements Runnable { private static final String ENTER = "Enter"; private static final String FINISHED = "Finished"; private static final String STARTING = "Starting"; - private static final String STORYID = "storyId"; - - public static String RUNDOWN_COLLECTION_NAME = "rundowns"; - public static String STORY_COLLECTION_NAME = "stories"; - public static String STORY_FOLDER_COLLECTION_NAME = "story_folders"; - public static String TIME_COLLECTION_NAME = "time"; - public static String LASTUPDATE_TIME = "lastUpdateTime"; + private static final String MOSOBJECT = "Bejátszó: "; private DB db; private ResteasyWebTarget webTarget; @@ -127,53 +96,54 @@ public class OctopusDataMiner implements Runnable { Map result = new HashMap<>(); List rundownsList = NoSQLUtils.asList(rundowns); for (BasicDBObject rundown : rundownsList) { - if (!rundown.containsKey(ID)) + if (!rundown.containsKey(IOctopusAPI.ID)) continue; - long rundownId = rundown.getLong(ID); - List slugs = NoSQLUtils.asList(rundown, SLUGS); + long rundownId = rundown.getLong(IOctopusAPI.ID); + List slugs = NoSQLUtils.asList(rundown, IOctopusAPI.SLUGS); if (slugs == null) continue; for (BasicDBObject slug : slugs) { - if (!slug.containsKey(STORYID)) + if (!slug.containsKey(IOctopusAPI.STORYID)) continue; - long storyId = slug.getLong(STORYID); + long storyId = slug.getLong(IOctopusAPI.STORYID); BasicDBList references = result.get(storyId); if (references == null) { references = new BasicDBList(); result.put(storyId, references); } - long position = slug.getLong(POSITION); - if (slug.containsKey(POSITION)) - position = slug.getLong(POSITION); - references.add(new BasicDBObject(ID, rundownId).append(POSITION, position)); + long position = slug.getLong(IOctopusAPI.POSITION); + if (slug.containsKey(IOctopusAPI.POSITION)) + position = slug.getLong(IOctopusAPI.POSITION); + references.add(new BasicDBObject(IOctopusAPI.ID, rundownId).append(IOctopusAPI.POSITION, position)); } } return result; } private void buildStoriesReferences() { - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); - DBCursor cursor = collection.find(null, new BasicDBObject(ID, 1).append(REF_RUNDOWN, 1).append(REF_STORYFOLDER, 1).append(MOS_OBJECTS, 1)); + DBCollection collection = db.getCollection(IOctopusAPI.STORY_COLLECTION_NAME); + DBCursor cursor = collection.find(null, new BasicDBObject(IOctopusAPI.ID, 1).append(IOctopusAPI.REF_RUNDOWN, 1).append(IOctopusAPI.REF_STORYFOLDER, 1) + .append(IOctopusAPI.MOS_OBJECTS, 1)); //DBCursor find = collection.find(QueryBuilder.start(ID).greaterThan(0).get()); try { while (cursor.hasNext()) { BasicDBObject story = (BasicDBObject) cursor.next(); - long storyId = story.getLong(ID); - BasicDBList rundownRef = NoSQLUtils.asDBList(story, REF_RUNDOWN); + long storyId = story.getLong(IOctopusAPI.ID); + BasicDBList rundownRef = NoSQLUtils.asDBList(story, IOctopusAPI.REF_RUNDOWN); if (rundownRef != null) { if (storedStoryRundowns == null) storedStoryRundowns = new HashMap<>(); storedStoryRundowns.put(storyId, rundownRef); } - BasicDBList storyFolderRef = NoSQLUtils.asDBList(story, REF_STORYFOLDER); + BasicDBList storyFolderRef = NoSQLUtils.asDBList(story, IOctopusAPI.REF_STORYFOLDER); if (storyFolderRef != null) { if (storedStoryStoryFolders == null) storedStoryStoryFolders = new HashMap<>(); storedStoryStoryFolders.put(storyId, storyFolderRef); } - BasicDBList storyMosObjects = NoSQLUtils.asDBList(story, MOS_OBJECTS); + BasicDBList storyMosObjects = NoSQLUtils.asDBList(story, IOctopusAPI.MOS_OBJECTS); if (storyMosObjects != null) { if (storedStoryMosObjects == null) storedStoryMosObjects = new HashMap<>(); @@ -192,29 +162,29 @@ public class OctopusDataMiner implements Runnable { Map result = new HashMap<>(); List storyFolderList = NoSQLUtils.asList(storyFolders); for (BasicDBObject storyFolder : storyFolderList) { - long storyFolderId = storyFolder.getLong(ID); - List stories = NoSQLUtils.asList(storyFolder, STORIES); + long storyFolderId = storyFolder.getLong(IOctopusAPI.ID); + List stories = NoSQLUtils.asList(storyFolder, IOctopusAPI.STORIES); if (stories == null) continue; long position = 1; for (BasicDBObject story : stories) { - long storyId = story.getLong(ID); + long storyId = story.getLong(IOctopusAPI.ID); BasicDBList references = result.get(storyId); if (references == null) { references = new BasicDBList(); result.put(storyId, references); } - references.add(new BasicDBObject(ID, storyFolderId).append(POSITION, position++)); + references.add(new BasicDBObject(IOctopusAPI.ID, storyFolderId).append(IOctopusAPI.POSITION, position++)); } } return result; } public void clear() { - db.getCollection(RUNDOWN_COLLECTION_NAME).remove(); - db.getCollection(STORY_COLLECTION_NAME).remove(); - db.getCollection(STORY_FOLDER_COLLECTION_NAME).remove(); - db.getCollection(TIME_COLLECTION_NAME).remove(); + db.getCollection(IOctopusAPI.RUNDOWN_COLLECTION_NAME).remove(); + db.getCollection(IOctopusAPI.STORY_COLLECTION_NAME).remove(); + db.getCollection(IOctopusAPI.STORY_FOLDER_COLLECTION_NAME).remove(); + db.getCollection(IOctopusAPI.TIME_COLLECTION_NAME).remove(); } private String concatParentsToStoryFolder(BasicDBObject actual, String name) { @@ -227,15 +197,15 @@ public class OctopusDataMiner implements Runnable { BasicDBObject parent = (BasicDBObject) res.get("parent"); if (parent == null || parent.isEmpty()) return name; - String parentName = parent.getString(NAME); - String actualName = actual.getString(NAME); + String parentName = parent.getString(IOctopusAPI.NAME); + String actualName = actual.getString(IOctopusAPI.NAME); String newName = String.format("%s/%s", parentName, actualName); return concatParentsToStoryFolder(parent, newName); } private void deleteOrphanStories() { try { - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection collection = db.getCollection(IOctopusAPI.STORY_COLLECTION_NAME); BasicDBObject query = (BasicDBObject) QueryBuilder.start().put("id").notIn(storyIDs.toArray()).get(); WriteResult res = collection.remove(query); logger.trace(String.format("Deleted orphan stories: %d", res.getN())); @@ -245,17 +215,17 @@ public class OctopusDataMiner implements Runnable { } private void ensureIndexes() { - DBCollection collection = db.getCollection(STORY_FOLDER_COLLECTION_NAME); + DBCollection collection = db.getCollection(IOctopusAPI.STORY_FOLDER_COLLECTION_NAME); if (collection.count() == 0) - collection.ensureIndex(ID); - collection = db.getCollection(RUNDOWN_COLLECTION_NAME); + collection.ensureIndex(IOctopusAPI.ID); + collection = db.getCollection(IOctopusAPI.RUNDOWN_COLLECTION_NAME); if (collection.count() == 0) { - collection.ensureIndex(ID); - collection.ensureIndex(SCHEDULED_START); + collection.ensureIndex(IOctopusAPI.ID); + collection.ensureIndex(IOctopusAPI.SCHEDULED_START); } - collection = db.getCollection(STORY_COLLECTION_NAME); + collection = db.getCollection(IOctopusAPI.STORY_COLLECTION_NAME); if (collection.count() == 0) - collection.ensureIndex(ID); + collection.ensureIndex(IOctopusAPI.ID); } private void fireProgressEvent(ProgressEvent evt) { @@ -271,31 +241,31 @@ public class OctopusDataMiner implements Runnable { private String GetContent(BasicDBObject content) { String scriptContent = ""; - if (!content.containsKey(TYPE)) + if (!content.containsKey(IOctopusAPI.TYPE)) return scriptContent; - String type = content.getString(TYPE); + String type = content.getString(IOctopusAPI.TYPE); switch (type) { - case TEXT: { - if (content.containsKey(TEXT)) { - String text = content.getString(TEXT); + case IOctopusAPI.TEXT: { + if (content.containsKey(IOctopusAPI.TEXT)) { + String text = content.getString(IOctopusAPI.TEXT); if (text != null) scriptContent += String.format("%s%s", text.replaceAll(SIMPLE_LINEFEED, LINEFEED), LINEFEED); } break; } - case MOS: { - BasicDBObject mosObject = NoSQLUtils.asDBObject(content, OBJECT); + case IOctopusAPI.MOS: { + BasicDBObject mosObject = NoSQLUtils.asDBObject(content, IOctopusAPI.OBJECT); if (mosObject != null && !mosObject.isEmpty()) { - if (mosObject.containsKey(OBJ_ID)) { - String objID = mosObject.getString(OBJ_ID); + if (mosObject.containsKey(IOctopusAPI.OBJ_ID)) { + String objID = mosObject.getString(IOctopusAPI.OBJ_ID); scriptContent += String.format("%s %s%s", MOSOBJECT, objID, LINEFEED); } } break; } default: { - if (content.containsKey(CONTENT)) { - List innerContents = NoSQLUtils.asList(content, CONTENT); + if (content.containsKey(IOctopusAPI.CONTENT)) { + List innerContents = NoSQLUtils.asList(content, IOctopusAPI.CONTENT); if (innerContents != null) { for (BasicDBObject actualInnerContent : innerContents) { if (actualInnerContent != null && actualInnerContent.isEmpty()) @@ -318,21 +288,21 @@ public class OctopusDataMiner implements Runnable { // } private String GetCustomColumnValue(String columnName, BasicDBObject story) { - List customColumns = NoSQLUtils.asList(story, CUSTOM_COLUMNS); + List customColumns = NoSQLUtils.asList(story, IOctopusAPI.CUSTOM_COLUMNS); if (customColumns == null) return null; String result = null; for (BasicDBObject customColumn : customColumns) { - if (!customColumn.containsKey(LABEL)) + if (!customColumn.containsKey(IOctopusAPI.LABEL)) continue; - String currentName = customColumn.getString(LABEL); + String currentName = customColumn.getString(IOctopusAPI.LABEL); if (currentName == null) continue; if (!currentName.toLowerCase().equals(columnName.toLowerCase())) continue; - if (!customColumn.containsKey(VALUE)) + if (!customColumn.containsKey(IOctopusAPI.VALUE)) continue; - result = customColumn.getString(VALUE); + result = customColumn.getString(IOctopusAPI.VALUE); break; } return result; @@ -340,23 +310,23 @@ public class OctopusDataMiner implements Runnable { private Date getLastUpdateTime() { Date result = null; - DBCollection collection = db.getCollection(TIME_COLLECTION_NAME); + DBCollection collection = db.getCollection(IOctopusAPI.TIME_COLLECTION_NAME); DBObject timeObject = collection.findOne(); if (timeObject != null) - result = (Date) timeObject.get(LASTUPDATE_TIME); + result = (Date) timeObject.get(IOctopusAPI.LASTUPDATE_TIME); return result; } private BasicDBList GetRelevantMOSObjects(BasicDBObject story) { - List mosObjects = NoSQLUtils.asList(story, MOS_OBJECTS); + List mosObjects = NoSQLUtils.asList(story, IOctopusAPI.MOS_OBJECTS); if (mosObjects == null) return null; BasicDBList result = null; for (BasicDBObject mosObject : mosObjects) { - if (!mosObject.containsKey(MOS_ID)) + if (!mosObject.containsKey(IOctopusAPI.MOS_ID)) continue; - String mosId = mosObject.getString(MOS_ID); - if (!"NEXIO.MOS".equals(mosId)) + String mosId = mosObject.getString(IOctopusAPI.MOS_ID); + if (!IOctopusAPI.NEXIO_MOS.equals(mosId)) continue; if (result == null) result = new BasicDBList(); @@ -366,22 +336,22 @@ public class OctopusDataMiner implements Runnable { } private String GetScriptContent(BasicDBObject story) { - BasicDBObject script = NoSQLUtils.asDBObject(story, SCRIPT); + BasicDBObject script = NoSQLUtils.asDBObject(story, IOctopusAPI.SCRIPT); if (script == null || script.isEmpty()) return null; - List body = NoSQLUtils.asList(script, BODY); + List body = NoSQLUtils.asList(script, IOctopusAPI.BODY); if (body == null || body.size() == 0) return null; StringBuilder sb = new StringBuilder(); for (BasicDBObject bodyItem : body) { - if (bodyItem.containsKey(LABEL)) { - sb.append(bodyItem.getString(LABEL)); + if (bodyItem.containsKey(IOctopusAPI.LABEL)) { + sb.append(bodyItem.getString(IOctopusAPI.LABEL)); sb.append(LINEFEED); } - List contents = NoSQLUtils.asList(bodyItem, CONTENT); + List contents = NoSQLUtils.asList(bodyItem, IOctopusAPI.CONTENT); if (contents == null) continue; for (BasicDBObject content : contents) { @@ -394,7 +364,7 @@ public class OctopusDataMiner implements Runnable { private boolean isModified(Date date, BasicDBObject object) { if (date == null) return true; - Date modified = (Date) object.get(MODIFIED); + Date modified = (Date) object.get(IOctopusAPI.MODIFIED); int result = date.compareTo(modified); return result <= 0; } @@ -455,10 +425,10 @@ public class OctopusDataMiner implements Runnable { /* teszt */ List list = NoSQLUtils.asList(result); for (BasicDBObject actual : list) { - String fullName = concatParentsToStoryFolder(actual, actual.getString(NAME)); + String fullName = concatParentsToStoryFolder(actual, actual.getString(IOctopusAPI.NAME)); //logger.info("Checking StoryFolder {}", fullName); - actual.remove(NAME); - actual.append(NAME, fullName); + actual.remove(IOctopusAPI.NAME); + actual.append(IOctopusAPI.NAME, fullName); } logger.trace(EXIT); @@ -534,23 +504,23 @@ public class OctopusDataMiner implements Runnable { DBObject timeObject = collection.findOne(); if (timeObject == null) timeObject = new BasicDBObject(); - timeObject.put(LASTUPDATE_TIME, lastUpdateTime); + timeObject.put(IOctopusAPI.LASTUPDATE_TIME, lastUpdateTime); collection.save(timeObject); } private void storeRundown(BasicDBObject rundown, Date lastUpdateTime) { logger.trace(ENTER); - long rundownID = rundown.getLong(ID); - String name = rundown.containsKey(NAME) ? rundown.getString(NAME) : null; - logger.debug("Storing rundown {} {}", name, rundown.get(SCHEDULED_START)); + long rundownID = rundown.getLong(IOctopusAPI.ID); + 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, SLUGS); + BasicDBList stories = NoSQLUtils.asDBList(rundownWithStories, IOctopusAPI.SLUGS); if (stories != null) storeRundownStories(stories, lastUpdateTime); - rundown.put(SCHEDULED_START, toDate(rundown, SCHEDULED_START)); - rundown.put(MODIFIED, toDate(rundown, MODIFIED)); - DBCollection collection = db.getCollection(RUNDOWN_COLLECTION_NAME); + rundown.put(IOctopusAPI.SCHEDULED_START, toDate(rundown, IOctopusAPI.SCHEDULED_START)); + rundown.put(IOctopusAPI.MODIFIED, toDate(rundown, IOctopusAPI.MODIFIED)); + DBCollection collection = db.getCollection(IOctopusAPI.RUNDOWN_COLLECTION_NAME); if (lastUpdateTime == null || (lastUpdateTime != null && isModified(lastUpdateTime, rundown))) { logger.debug(SAVING_RUNDOWN, rundownID, name); collection.save(rundown); @@ -580,20 +550,20 @@ public class OctopusDataMiner implements Runnable { logger.trace(ENTER); List slugsList = NoSQLUtils.asList(slugs); for (BasicDBObject slug : slugsList) { - if (slug.containsKey(STORY)) - storeStory((BasicDBObject) slug.get(STORY), lastUpdateTime); + if (slug.containsKey(IOctopusAPI.STORY)) + storeStory((BasicDBObject) slug.get(IOctopusAPI.STORY), lastUpdateTime); } logger.trace(EXIT); } private void storeStory(BasicDBObject story, Date lastUpdateTime) { logger.trace(ENTER); - long storyID = story.getLong(ID); + long storyID = story.getLong(IOctopusAPI.ID); boolean isContains = storyIDs.contains(storyID); if (isContains) return; storyIDs.add(storyID); - story.put(MODIFIED, toDate(story, MODIFIED)); + story.put(IOctopusAPI.MODIFIED, toDate(story, IOctopusAPI.MODIFIED)); BasicDBList rundownRef = storyRundowns.get(storyID); rundownRef = (rundownRef == null) ? new BasicDBList() : rundownRef; BasicDBList storyFolderRef = storyStoryFolders.get(storyID); @@ -623,29 +593,29 @@ public class OctopusDataMiner implements Runnable { return; } - DBCollection collection = db.getCollection(STORY_COLLECTION_NAME); + DBCollection collection = db.getCollection(IOctopusAPI.STORY_COLLECTION_NAME); if (lastUpdateTime != null) { - BasicDBObject orig = (BasicDBObject) collection.findOne(new BasicDBObject(ID, storyID), new BasicDBObject(ID, 1)); + BasicDBObject orig = (BasicDBObject) collection.findOne(new BasicDBObject(IOctopusAPI.ID, storyID), new BasicDBObject(IOctopusAPI.ID, 1)); if (orig != null) story.put("_id", orig.getID()); } if (rundownRef != null) - story.put(REF_RUNDOWN, rundownRef); + story.put(IOctopusAPI.REF_RUNDOWN, rundownRef); if (storyFolderRef != null) - story.put(REF_STORYFOLDER, storyFolderRef); + story.put(IOctopusAPI.REF_STORYFOLDER, storyFolderRef); String scriptContent = GetScriptContent(story); story.put(SCRIPT_CONTENT, scriptContent); if (modifiedMOS == null || modifiedMOS.isEmpty()) { - if (story.containsKey(MOS_OBJECTS)) - story.remove(MOS_OBJECTS); + if (story.containsKey(IOctopusAPI.MOS_OBJECTS)) + story.remove(IOctopusAPI.MOS_OBJECTS); } else - story.put(MOS_OBJECTS, modifiedMOS); + story.put(IOctopusAPI.MOS_OBJECTS, modifiedMOS); - String parentSoryId = GetCustomColumnValue(PARENT_STORY_ID, story); + String parentSoryId = GetCustomColumnValue(IOctopusAPI.PARENT_STORY_ID, story); if (parentSoryId == null) - story.append(PARENT_STORY_ID, storyID); + story.append(IOctopusAPI.PARENT_STORY_ID, storyID); else - story.append(PARENT_STORY_ID, parentSoryId); + story.append(IOctopusAPI.PARENT_STORY_ID, parentSoryId); logger.debug(SAVING_STORY_ID, storyID); collection.save(story); logger.trace(EXIT); @@ -653,16 +623,16 @@ public class OctopusDataMiner implements Runnable { private void storeStoryFolder(BasicDBObject storyFolder, Date lastUpdateTime) { logger.trace(ENTER); - long storyFolderID = storyFolder.getLong(ID); + long storyFolderID = storyFolder.getLong(IOctopusAPI.ID); BasicDBObject storyFoldersWithStories = queryStoryFolder(storyFolderID); - BasicDBList stories = NoSQLUtils.asDBList(storyFoldersWithStories, STORIES); + BasicDBList stories = NoSQLUtils.asDBList(storyFoldersWithStories, IOctopusAPI.STORIES); if (stories != null) storeStoryFolderStories(stories, lastUpdateTime); - storyFolder.put(MODIFIED, toDate(storyFolder, MODIFIED)); - DBCollection collection = db.getCollection(STORY_FOLDER_COLLECTION_NAME); + storyFolder.put(IOctopusAPI.MODIFIED, toDate(storyFolder, IOctopusAPI.MODIFIED)); + DBCollection collection = db.getCollection(IOctopusAPI.STORY_FOLDER_COLLECTION_NAME); if (lastUpdateTime == null || (lastUpdateTime != null && isModified(lastUpdateTime, storyFolder))) { - String name = storyFolder.getString(NAME); + String name = storyFolder.getString(IOctopusAPI.NAME); logger.debug("Storing story folder {}", name); collection.save(storyFolder); } @@ -674,7 +644,7 @@ public class OctopusDataMiner implements Runnable { List storyFolderList = NoSQLUtils.asList(storyFolders); int idx = 1; for (BasicDBObject storyFolder : storyFolderList) { - logger.debug(String.format(CHECKING_STORY_FOLDER, storyFolder.getLong(ID), storyFolderList.size(), idx)); + logger.debug(String.format(CHECKING_STORY_FOLDER, storyFolder.getLong(IOctopusAPI.ID), storyFolderList.size(), idx)); storeStoryFolder(storyFolder, lastUpdateTime); int progress = 50 + (idx * 50 / storyFolderList.size()); if (progress - progressEvent.getProgress() > 0) { diff --git a/server/user.jobengine.osgi.commons/test/user/common/octopus/test/OctopusAPITest.java b/server/user.jobengine.osgi.commons/test/user/common/octopus/test/OctopusAPITest.java index 9109ea04..8d846c6e 100644 --- a/server/user.jobengine.osgi.commons/test/user/common/octopus/test/OctopusAPITest.java +++ b/server/user.jobengine.osgi.commons/test/user/common/octopus/test/OctopusAPITest.java @@ -20,12 +20,9 @@ import user.commons.octopus.OctopusAPI; public class OctopusAPITest { - private IOctopusAPI sut; - @BeforeClass public static void initialize() { - System.setProperty("jobengine.nosql.db.url", - "jdbc:db2://10.228.198.1:50000/mccache:retrieveMessagesFromServerOnGetMessage=true;"); + System.setProperty("jobengine.nosql.db.url", "jdbc:db2://10.228.198.1:50000/mccache:retrieveMessagesFromServerOnGetMessage=true;"); System.setProperty("jobengine.nosql.db.user", "db2admin"); System.setProperty("jobengine.nosql.db.password", "password"); System.setProperty("jobengine.nosql.db.schema", "test"); @@ -34,68 +31,13 @@ public class OctopusAPITest { System.setProperty("jobengine.octopus.api.password", "demo"); } - @Test - public void getRundownsByDate() throws SQLException { - sut = new OctopusAPI(); - Calendar calendar = Calendar.getInstance(); - calendar.set(2000, 5, 21); - // BasicDBList rundowns = sut.getRundowns(calendar.getTime()); - // assertNotNull(rundowns); - // assertTrue(rundowns.size() > 0); - } - - @Test - public void getRundownByStoryID() throws SQLException { - sut = new OctopusAPI(); - - List actual = sut.getRundownByStoryID(36421476); - - /* - * long actualID = actual.getLong("id"); Assert.assertEquals(44622396, - * actualID); - */ - } - - @Test - public void getStoryFolders() throws SQLException { - sut = new OctopusAPI(); - - List actual = sut.getStoryFolders(62549297); - } - - @Test - public void getStoriesByPlaceHolderIdTest() throws SQLException { - sut = new OctopusAPI(); - - List actual = sut.getStoriesByPlaceHolderId("1589225"); - - Assert.assertFalse(actual.isEmpty()); - } - - @Test - public void getStoryFoldersTest() throws SQLException { - sut = new OctopusAPI(); - - sut.getStoryFolders(); - } + private IOctopusAPI sut; - @Test - public void getMosObjectsByID() throws SQLException { - //Fixture - final String ID = "1589225"; - sut = new OctopusAPI(); - - List actual = sut.getMosObjectsByID(ID); - - Assert.assertTrue(!actual.isEmpty()); - } - @Test public void getRundownByPlaceHolderIdTest() throws SQLException { // Fixture sut = new OctopusAPI(); - DB db = NoSQLClient.getDB("jdbc:db2://10.228.198.1:50000/mccache:retrieveMessagesFromServerOnGetMessage=true;", - "db2admin", "password", "test"); + DB db = NoSQLClient.getDB("jdbc:db2://10.228.198.1:50000/mccache:retrieveMessagesFromServerOnGetMessage=true;", "db2admin", "password", "test"); DBCollection testStoryCollection = db.getCollection("testStoryCollection"); DBCollection testRundownCollection = db.getCollection("testRundownCollection"); long storyID = 1; @@ -103,9 +45,8 @@ public class OctopusAPITest { BasicDBObject obj = new BasicDBObject("id", storyID); String globalID = "OCTOPUS-ECHOTV-2429902"; String placeHolderID = "2429902"; - BasicDBObject mosObject = new BasicDBObject("mosId", "NEXIO.MOS").append("mosId", "NEXIO.MOS") - .append("objId", "xxxl").append("objectType", "MosObject").append("id", placeHolderID) - .append("globalId", globalID).append("modified", "2017-08-08T11:38:53.000+02:00"); + BasicDBObject mosObject = new BasicDBObject("mosId", "NEXIO.MOS").append("mosId", "NEXIO.MOS").append("objId", "xxxl").append("objectType", "MosObject") + .append("id", placeHolderID).append("globalId", globalID).append("modified", "2017-08-08T11:38:53.000+02:00"); BasicDBList mosObjects = new BasicDBList(mosObject); obj.append("mosObjects", mosObjects); BasicDBObject referenceObject = new BasicDBObject("id", rundownID); @@ -117,7 +58,7 @@ public class OctopusAPITest { // Exercise try { - List actual = sut.getRundownsByPlaceHolderId(placeHolderID); + List actual = sut.getRundownsByPlaceHolderID(placeHolderID); } catch (Exception e) { System.out.println(e.getMessage()); } finally { @@ -125,4 +66,30 @@ public class OctopusAPITest { testStoryCollection.remove(); } } + + @Test + public void getRundownsByDate() throws SQLException { + sut = new OctopusAPI(); + Calendar calendar = Calendar.getInstance(); + calendar.set(2000, 5, 21); + // BasicDBList rundowns = sut.getRundowns(calendar.getTime()); + // assertNotNull(rundowns); + // assertTrue(rundowns.size() > 0); + } + + @Test + public void getStoriesByPlaceHolderIdTest() throws SQLException { + sut = new OctopusAPI(); + + List actual = sut.getStoriesByPlaceHolderID("1589225"); + + Assert.assertFalse(actual.isEmpty()); + } + + @Test + public void getStoryFoldersTest() throws SQLException { + sut = new OctopusAPI(); + + sut.getStoryFolders(); + } } diff --git a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/octopus/OctopusRESTService.java b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/octopus/OctopusRESTService.java index 5b187754..0f68911a 100644 --- a/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/octopus/OctopusRESTService.java +++ b/server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/octopus/OctopusRESTService.java @@ -23,50 +23,17 @@ import user.jobengine.osgi.rest.ComponentBinder; @Path("/octopus") public class OctopusRESTService { private static final Logger logger = LogManager.getLogger(); + private static final String ID = "id"; private IOctopusAPI octopusService = ComponentBinder.getOctopusService(); public OctopusRESTService() { - logger.info("Created"); + logger.trace("Created"); } private Response createErrorResponse(Exception e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); } - @GET - @Path("/getMosObjectsByID/{id}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public Response getMosObjectsByID(@PathParam("id") String id) { - logger.trace("Entry"); - Response result = null; - try { - List mosObjects = octopusService.getMosObjectsByID(id); - result = Response.ok(mosObjects).build(); - } catch (Exception e) { - result = createErrorResponse(e); - } - logger.trace("Exit"); - return result; - } - - @GET - @Path("/getRundownByStoryID/{id}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public Response getRundownByStoryID(@PathParam("id") String id) { - logger.trace("Entry"); - Response result = null; - try { - List rundowns = octopusService.getRundownByStoryID(Long.parseLong(id)); - result = Response.ok(rundowns).build(); - } catch (Exception e) { - result = createErrorResponse(e); - } - logger.trace("Exit"); - return result; - } - @GET @Path("/rundowns") @Consumes({ MediaType.APPLICATION_JSON }) @@ -100,14 +67,14 @@ public class OctopusRESTService { } @GET - @Path("/getRundownsByPlaceHolderId/{id}") + @Path("/rundownsByParentStoryID/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getRundownsByPlaceHolderId(@PathParam("id") String id) { + public Response getRundownsByParentStoryID(@PathParam(ID) String id) { logger.trace("Entry"); Response result = null; try { - List rundowns = octopusService.getRundownsByPlaceHolderId(id); + List rundowns = octopusService.getRundownsByParentStoryID(id); result = Response.ok(rundowns).build(); } catch (Exception e) { result = createErrorResponse(e); @@ -117,15 +84,15 @@ public class OctopusRESTService { } @GET - @Path("/stories/") + @Path("/rundownsByPlaceHolderID/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getStories() { + public Response getRundownsByPlaceHolderID(@PathParam(ID) String id) { logger.trace("Entry"); Response result = null; try { - List stories = octopusService.getStories(); - result = Response.ok(stories).build(); + List rundowns = octopusService.getRundownsByPlaceHolderID(id); + result = Response.ok(rundowns).build(); } catch (Exception e) { result = createErrorResponse(e); } @@ -134,14 +101,14 @@ public class OctopusRESTService { } @GET - @Path("/stories/{rundownID}") + @Path("/rundownStories/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getStories(@PathParam("rundownID") long rundownID) { + public Response getRundownStories(@PathParam(ID) long id) { logger.trace("Entry"); Response result = null; try { - List stories = octopusService.getStories(rundownID); + List stories = octopusService.getRundownStories(id); result = Response.ok(stories).build(); } catch (Exception e) { result = createErrorResponse(e); @@ -151,10 +118,10 @@ public class OctopusRESTService { } @GET - @Path("/getStoriesByID/{id}") + @Path("/storiesByID/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getStoriesByID(@PathParam("id") String id) { + public Response getStoriesByID(@PathParam(ID) String id) { logger.trace("Entry"); Response result = null; try { @@ -168,10 +135,10 @@ public class OctopusRESTService { } @GET - @Path("/getStoriesByParentStoryID/{id}") + @Path("/storiesByParentStoryID/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getStoriesByParentStoryID(@PathParam("id") String id) { + public Response getStoriesByParentStoryID(@PathParam(ID) String id) { logger.trace("Entry"); Response result = null; try { @@ -185,14 +152,14 @@ public class OctopusRESTService { } @GET - @Path("/getStoriesByPlaceHolderId/{id}") + @Path("/storiesByPlaceHolderID/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getStoriesByPlaceHolderId(@PathParam("id") String id) { + public Response getStoriesByPlaceHolderID(@PathParam(ID) String id) { logger.trace("Entry"); Response result = null; try { - List stories = octopusService.getStoriesByPlaceHolderId(id); + List stories = octopusService.getStoriesByPlaceHolderID(id); result = Response.ok(stories).build(); } catch (Exception e) { result = createErrorResponse(e); @@ -202,15 +169,15 @@ public class OctopusRESTService { } @GET - @Path("/storiesByStoryFolderID/{storyFolderID}") + @Path("/storyFolders") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getStoriesByStoryFolderId(@PathParam("storyFolderID") long storyFolderID) { + public Response getStoryFolders() { logger.trace("Entry"); Response result = null; try { - List stories = octopusService.getStoriesByStoryFolderId(storyFolderID); - result = Response.ok(stories).build(); + List storyFolders = octopusService.getStoryFolders(); + result = Response.ok(storyFolders).build(); } catch (Exception e) { result = createErrorResponse(e); } @@ -219,14 +186,14 @@ public class OctopusRESTService { } @GET - @Path("/storyfolders") + @Path("/storyFoldersByPlaceHolderID/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getStoryFolders() { + public Response getStoryFoldersByPlaceHolderID(@PathParam(ID) String id) { logger.trace("Entry"); Response result = null; try { - List storyFolders = octopusService.getStoryFolders(); + List storyFolders = octopusService.getStoryFoldersByPlaceHolderID(id); result = Response.ok(storyFolders).build(); } catch (Exception e) { result = createErrorResponse(e); @@ -236,14 +203,14 @@ public class OctopusRESTService { } @GET - @Path("/getStoryFoldersByPlaceHolderId/{id}") + @Path("/storyFoldersByParentStoryID/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getStoryFoldersByPlaceHolderId(@PathParam("id") String id) { + public Response getStoryFoldersByStoryID(@PathParam(ID) String id) { logger.trace("Entry"); Response result = null; try { - List storyFolders = octopusService.getStoryFoldersByPlaceHolderId(id); + List storyFolders = octopusService.getStoryFoldersByParentStoryID(id); result = Response.ok(storyFolders).build(); } catch (Exception e) { result = createErrorResponse(e); @@ -253,15 +220,15 @@ public class OctopusRESTService { } @GET - @Path("/getStoryFolders/{id}") + @Path("/storyFolderStories/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getStoryFoldersByStoryID(@PathParam("id") String id) { + public Response getStoryFolderStories(@PathParam(ID) long id) { logger.trace("Entry"); Response result = null; try { - List storyFolders = octopusService.getStoryFolders(Long.parseLong(id)); - result = Response.ok(storyFolders).build(); + List stories = octopusService.getStoryFolderStories(id); + result = Response.ok(stories).build(); } catch (Exception e) { result = createErrorResponse(e); } @@ -273,7 +240,7 @@ public class OctopusRESTService { @Path("/test/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response test(@PathParam("id") Long jobId) { + public Response test(@PathParam(ID) Long jobId) { Response result = null; try { String json = "{valami: " + jobId + " }";