From: Vásáry Dániel Date: Thu, 28 Feb 2019 09:37:18 +0000 (+0000) Subject: #131 Szegmentálásba visszalépve a szegmensek nem módosíthatóakEdit this section X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=2e14ebc860cf0d94a2b341ce2c630f3d90623422;p=mediacube.git #131 Szegmentálásba visszalépve a szegmensek nem módosíthatóakEdit this section #130 Szegmensek meglétének kijelzése hibásEdit this section #100 Forrás listázó a lista változása esetén néha hibaüzenetet ad git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C31403 --- diff --git a/client/Maestro/Configuration/UJ-configuration-tqc-check.json b/client/Maestro/Configuration/UJ-configuration-tqc-check.json index 7180a0dd..c7ea89f9 100644 --- a/client/Maestro/Configuration/UJ-configuration-tqc-check.json +++ b/client/Maestro/Configuration/UJ-configuration-tqc-check.json @@ -1,5 +1,5 @@ { - "title": "TESZT TQC TESZT check", + "title": "TQC check", "active": true, "startInTray": false, "enableCustomMetadataId": true, @@ -12,13 +12,7 @@ "$type": "UNCSource", "filter": "avi,wav,mxf", "local": { - "address": "file://c:\\_video", - "userName": "mediacube", - "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", - "timeout": 1000 - }, - "remote": { - "address": "ftp://10.10.1.100/TESZT/CHECK", + "address": "file://c:/_video", "userName": "mediacube", "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", "timeout": 1000 @@ -34,8 +28,9 @@ "timeout": 1000 } }, - { + { "$type": "OctopusMetadata", + "disabled": true, "server": { "address": "http://10.10.1.27/services/rest/octopus/", "timeout": 1000 @@ -51,50 +46,21 @@ ], "targets": [ { - "label": "1", - "processor": "FXPTargetProcessor", - "subFolderFormat": "%IDROOT%-%TEXT%", - "outputFormat": "%ID%-%TEXT%", - "tag": "1", - "disableFileVersioning": true, - "enableOverride": true, - "remote": { - "address": "ftp://10.10.1.100/TESZT/1", - "userName": "mediacube", - "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", - "timeout": 1000 - } - }, - { - "label": "2", - "processor": "FXPTargetProcessor", - "subFolderFormat": "%IDROOT%-%TEXT%", - "outputFormat": "%ID%-%TEXT%", - "tag": "2", - "disableFileVersioning": true, - "enableOverride": true, - "remote": { - "address": "ftp://10.10.1.100/TESZT/2", - "userName": "mediacube", - "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", - "timeout": 1000 - } - }, - { - "label": "KESZ", - "processor": "FXPTargetProcessor", - "subFolderFormat": "%IDROOT%-%TEXT%", - "outputFormat": "%ID%-%TEXT%", - "tag": "KESZ", + "label": "Adáskész", + "processor": "FTPTargetProcessor", + "outputFormat": "%ID%", + "killDateDays": 5, + "saveSegments": true, + "tag": "Adáskész", "disableFileVersioning": true, "enableOverride": true, - "deleteAfterCopy": true, "remote": { - "address": "ftp://10.10.1.100/TESZT/KESZ", + "address": "ftp://10.10.1.105/TESZT", "userName": "mediacube", "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy", "timeout": 1000 } } + ] } diff --git a/client/Maestro/Configuration/configuration - Copy.json b/client/Maestro/Configuration/configuration - Copy.json index 446a12c3..a8b6ec5d 100644 --- a/client/Maestro/Configuration/configuration - Copy.json +++ b/client/Maestro/Configuration/configuration - Copy.json @@ -1,6 +1,6 @@ { "title": "Development", - "active": true, + "active": false, "startInTray": false, "enableCustomMetadataId": true, "filter": "avi", diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index 6b80905e..a55d12db 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -297,6 +297,9 @@ Always + + Always + diff --git a/client/Maestro/MaestroForm.Metadata.cs b/client/Maestro/MaestroForm.Metadata.cs index 15027508..1fabee9b 100644 --- a/client/Maestro/MaestroForm.Metadata.cs +++ b/client/Maestro/MaestroForm.Metadata.cs @@ -139,9 +139,11 @@ namespace Maestro { if (MovieSegments == null) return; foreach (var s in MovieSegments) { + /* //eredetileg a szegmens adatokkal ez nem jon le singlesegment eseten, de kell a mukodeshez if (!trafficIDSelector.MultiSegment && s.MediaID == null) s.MediaID = SelectedMetadata.ID; + */ //redefine if (true.Equals(SelectedMetadata?.IsRedefine)) s.ReadOnly = SelectedMetadata.ID != s.MediaID; @@ -172,6 +174,7 @@ namespace Maestro { if (readOnly && ArchiveMetadata != null && !SelectedMetadata.IsRedefine) MsgBox.Warning("Az anyag már el van fogadva, a szegmens módosítás nem kerül mentésre. A szegmensek módosításához vissza kell vonni az anyag elfogadását az adástervező rendszerben."); OpenFile(fileInfo, true, readOnly); + UpdateDefineSegmentsStatus(); Cursor.Current = Cursors.Default; } diff --git a/client/Maestro/Properties/AssemblyInfo.cs b/client/Maestro/Properties/AssemblyInfo.cs index d57fd576..da87d941 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.9.4")] -[assembly: AssemblyFileVersion("2.0.9.4")] +[assembly: AssemblyVersion("2.0.9.5")] +[assembly: AssemblyFileVersion("2.0.9.5")] diff --git a/client/MediaCubeClient/Properties/AssemblyInfo.cs b/client/MediaCubeClient/Properties/AssemblyInfo.cs index 9b072e3b..b2ced48e 100644 --- a/client/MediaCubeClient/Properties/AssemblyInfo.cs +++ b/client/MediaCubeClient/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.0.0.1")] -[assembly: AssemblyFileVersion("1.0.0.1")] +[assembly: AssemblyVersion("1.0.0.2")] +[assembly: AssemblyFileVersion("1.0.0.2")] diff --git a/client/PlanAIRClient/Properties/AssemblyInfo.cs b/client/PlanAIRClient/Properties/AssemblyInfo.cs index f3791239..ca4782af 100644 --- a/client/PlanAIRClient/Properties/AssemblyInfo.cs +++ b/client/PlanAIRClient/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("1.0.0.2")] -[assembly: AssemblyFileVersion("1.0.0.2")] +[assembly: AssemblyVersion("1.0.0.3")] +[assembly: AssemblyFileVersion("1.0.0.3")] diff --git a/client/PlanAIRClient/TrafficIDSelector.cs b/client/PlanAIRClient/TrafficIDSelector.cs index 4981b581..9f775eed 100644 --- a/client/PlanAIRClient/TrafficIDSelector.cs +++ b/client/PlanAIRClient/TrafficIDSelector.cs @@ -42,7 +42,10 @@ namespace TrafficClient { private void RefreshKeepPosition() { int pos = dgTraffic.FirstDisplayedScrollingRowIndex; RefreshResults(); - dgTraffic.FirstDisplayedScrollingRowIndex = pos; + //lehet ures a lista + try { + dgTraffic.FirstDisplayedScrollingRowIndex = pos; + } catch { } } private void OnRefreshTrafficGrid(IMessage m) { diff --git a/client/PlanAIRClient/Workers/TrafficWorker.cs b/client/PlanAIRClient/Workers/TrafficWorker.cs index ef26b1ef..c53c3056 100644 --- a/client/PlanAIRClient/Workers/TrafficWorker.cs +++ b/client/PlanAIRClient/Workers/TrafficWorker.cs @@ -6,6 +6,7 @@ using System.Data.SqlClient; namespace TrafficClient.Workers { public class TrafficWorker { + private static readonly Logger logger = LogManager.GetCurrentClassLogger(); protected IMessageBus messageBus; protected PlanAirDataReader dataReader; @@ -20,9 +21,13 @@ namespace TrafficClient.Workers { } protected void TryConnect() { - if (connection.State != ConnectionState.Open) { - connection.Close(); - connection.Open(); + try { + if (connection.State != ConnectionState.Open) { + connection.Close(); + connection.Open(); + } + } catch (Exception e) { + OnError(logger, e); } } diff --git a/server/RemoteSystemsTempFiles/.project b/server/RemoteSystemsTempFiles/.project new file mode 100644 index 00000000..76756293 --- /dev/null +++ b/server/RemoteSystemsTempFiles/.project @@ -0,0 +1,12 @@ + + + RemoteSystemsTempFiles + + + + + + + org.eclipse.rse.ui.remoteSystemsTempNature + + diff --git a/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/Support.java b/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/Support.java index 85c2b8e2..3a2adc70 100644 --- a/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/Support.java +++ b/server/hu.user.mediacube.executors.tests/src/hu/user/mediacube/executors/tests/Support.java @@ -84,28 +84,45 @@ public class Support { URI sourcePath = new URI("file://10.10.1.100/BRAAVOS/ARCHIVE"); try { stream = Files.newDirectoryStream(Paths.get(sourcePath)); - List allFiles = new ArrayList<>(); + List allFiles = new ArrayList<>(); for (Path p : stream) { check_rd_collect(p, allFiles); } stream.close(); - stream = Files.newDirectoryStream(Paths.get(sourcePath)); + stream = Files.newDirectoryStream(Paths.get(Paths.get(sourcePath).toString(), ".STATUS")); + List allStatus = new ArrayList<>(); for (Path p : stream) { - check_rd_process(p, allFiles); + check_rd_collect_status(p, allStatus); } stream.close(); + + check_rd_process(allFiles, allStatus); } catch (Exception e) { System.err.println(e.getMessage()); } } - private void check_rd_collect(Path mediaFilePath, List allFiles) { + private void check_rd_collect(Path mediaFilePath, List allFiles) { File mediaFile = mediaFilePath.toFile(); if (mediaFile.isDirectory() || !mediaFile.getName().toUpperCase().endsWith(".MXF")) return; - allFiles.add(mediaFile); + allFiles.add(mediaFile.getName().toUpperCase()); + } + + private void check_rd_collect_status(Path mediaFilePath, List allFiles) { + File file = mediaFilePath.toFile(); + if (file.isDirectory() || (!file.getName().toUpperCase().endsWith(".JSON") && !file.getName().toUpperCase().endsWith(".KILLDATE"))) + return; + + if (file.getName().toUpperCase().endsWith(".KILLDATE")) { + String absolutePath = file.getAbsolutePath(); + int pos = absolutePath.lastIndexOf("."); + pos = absolutePath.lastIndexOf(".", pos - 1); + file = new File(absolutePath.substring(0, pos) + ".KILLDATE"); + } + allFiles.add(file.getName().toUpperCase()); } private File check_rd_nonzero_fellow(String mediaid, List allFiles) { @@ -119,7 +136,7 @@ public class Support { return null; } - private void check_rd_process(Path mediaFilePath, List allFiles) { + private void check_rd_process(List allFiles, List allStatus) { File mediaFile = mediaFilePath.toFile(); if (mediaFile.isDirectory() || !mediaFile.getName().toUpperCase().endsWith(".MXF")) return; diff --git a/server/user.jobengine.executors/config/config.xml b/server/user.jobengine.executors/config/config.xml index e1d591d4..744df7f4 100644 --- a/server/user.jobengine.executors/config/config.xml +++ b/server/user.jobengine.executors/config/config.xml @@ -33,4 +33,5 @@ + \ No newline at end of file diff --git a/server/user.jobengine.executors/jobtemplates/sys-recreate-lowres.xml b/server/user.jobengine.executors/jobtemplates/sys-recreate-lowres.xml index b98bf6a0..1b6d7322 100644 --- a/server/user.jobengine.executors/jobtemplates/sys-recreate-lowres.xml +++ b/server/user.jobengine.executors/jobtemplates/sys-recreate-lowres.xml @@ -8,6 +8,8 @@ + + @@ -63,6 +65,12 @@ + + + + + + @@ -103,5 +111,12 @@ + + + + + + + \ No newline at end of file diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java index cc7ce391..e623850e 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CreateMissingLowresStep.java @@ -1,7 +1,6 @@ package user.jobengine.server.steps; import java.nio.file.Paths; -import java.util.List; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -10,11 +9,9 @@ import org.apache.logging.log4j.Marker; import com.ibm.nosql.json.api.BasicDBObject; import com.ibm.nosql.json.api.DB; import com.ibm.nosql.json.api.DBCollection; -import com.ibm.nosql.json.api.DBObject; import user.commons.nosql.NoSQLUtils; -import user.jobengine.db.ItemDAOEx; -import user.jobengine.db.ItemManager; +import user.jobengine.db.IItemManager; import user.jobengine.db.Media; import user.jobengine.server.IJobEngine; import user.jobengine.server.IJobRuntime; @@ -22,36 +19,30 @@ import user.jobengine.server.IJobRuntime; public class CreateMissingLowresStep extends JobStep { private static final Logger logger = LogManager.getLogger(); private Marker marker; + private long highresStoreId; @StepEntry public Object[] execute(String localHiresPath, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { Object[] result = { null, null, "%s", null, 0, true }; marker = jobRuntime.getMarker(); - ItemDAOEx dao = new ItemDAOEx((ItemManager) jobEngine.getItemManager()); - List medias = dao.getUntranscodedMedias(); - DB db = NoSQLUtils.getNoSQLDB(); DBCollection collection = db.getCollection("missing_lowres"); + IItemManager manager = jobEngine.getItemManager(); + highresStoreId = manager.getSystemStore(false).getId(); + Media media = getFirstUntranscodedMedia(manager, collection); + try { - if (medias == null || medias.size() == 0) { + if (media == null) { throw new Exception("Nincs feldolgozandó hiány."); } - for (Media media : medias) { - String name = media.getMediaFilesName(); - if (name == null) - continue; - DBObject existing = collection.findOne(new BasicDBObject("name", name)); - if (existing != null) - continue; - - result[0] = media; - ArchiveItem archiveItem = new ArchiveItem(); - archiveItem.setMediaFile(Paths.get(localHiresPath, name).toString()); - result[1] = archiveItem; - collection.save(new BasicDBObject("name", name)); - break; - } + String name = media.getMediaFilesName(); + result[0] = media; + ArchiveItem archiveItem = new ArchiveItem(); + archiveItem.setMediaFile(Paths.get(localHiresPath, name).toString()); + result[1] = archiveItem; + collection.save(new BasicDBObject("name", name)); + logger.info(marker, "Hiányzó lowres mediaId: {}", media.getId()); } catch (Exception e) { logger.catching(e); @@ -61,4 +52,30 @@ public class CreateMissingLowresStep extends JobStep { } return result; } + + private Media getFirstUntranscodedMedia(IItemManager manager, DBCollection collection) { + Media[] result = { null }; + String query = "select v.mediaid from vw_mediafiles v, mediafile mf where (v.mediafilecount=1 and mf.mediaid = v.mediaid and mf.storeid=1)"; + manager.executeQuery(query, rs -> { + try { + long mediaId = rs.getLong(1); + Media media = manager.getMedia(mediaId); + + //TEST!!! + // if (!media.getHouseId().equals("134118999")) + // return true; + + String name = media.getMediaFilesName(); + long existing = collection.find(new BasicDBObject("name", name)).count(); + if (existing > 0) + return true; + + result[0] = media; + } catch (Exception e) { + logger.error(e); + } + return false; + }, null); + return result[0]; + } } diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/MetadataTypeDetector.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/MetadataTypeDetector.java index f5b1b0fb..778dd7b9 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/MetadataTypeDetector.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/MetadataTypeDetector.java @@ -3,10 +3,14 @@ package user.jobengine.server.steps; import org.apache.commons.lang.StringUtils; public class MetadataTypeDetector { + public enum MetadataType { TrafficMaterial, TrafficPromo, TrafficAD, OctopusStory, OctopusPlaceholder, Generic } + private static final String HYPHEN = "-"; + private static final String DOT = "."; + private static final String REGEXP_TRAFFICMATERIALID = "^M{1}[0-9]{6}[A-Z]{1}$"; private static final String REGEXP_TRAFFICADID = "^R{1}[0-9]{6}[A-Z]{1}$"; private static final String REGEXP_TRAFFICPROMOID = "^P{1}[0-9]{6}[A-Z]{1}$"; @@ -32,4 +36,18 @@ public class MetadataTypeDetector { return MetadataType.Generic; } + public static String truncateExtension(String name) { + String result = name; + if (result != null && result.contains(DOT)) + result = result.substring(0, result.lastIndexOf(DOT)); + return result; + } + + public static String truncateVersion(String name) { + String result = name; + if (result != null && result.contains(HYPHEN)) + result = result.split(HYPHEN)[0]; + return result; + } + } diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/UpdateGhostMediaData.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/UpdateGhostMediaData.java new file mode 100644 index 00000000..7b37d3cc --- /dev/null +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/UpdateGhostMediaData.java @@ -0,0 +1,83 @@ +package user.jobengine.server.steps; + +import java.util.List; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.Marker; + +import user.jobengine.db.IItemManager; +import user.jobengine.db.Media; +import user.jobengine.db.MediaFile; +import user.jobengine.db.Store; +import user.jobengine.server.IJobEngine; +import user.jobengine.server.IJobRuntime; +import user.jobengine.server.steps.MetadataTypeDetector.MetadataType; + +public class UpdateGhostMediaData extends JobStep { + private static final Logger logger = LogManager.getLogger(); + private Marker marker; + + @StepEntry + public Object[] execute(Media mediaCubeMedia, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { + marker = jobRuntime.getMarker(); + + IItemManager manager = jobEngine.getItemManager(); + //Refresh from db + List mediaFiles = manager.getMedia(mediaCubeMedia.getId()).getMediaFiles(); + if (mediaFiles != null && mediaFiles.size() == 2) { + Store highresStore = manager.getSystemStore(false); + Store lowresStore = manager.getSystemStore(true); + MediaFile lowres = get(lowresStore, mediaFiles); + MediaFile highres = get(highresStore, mediaFiles); + if (highres == null) { + logger.info(marker, "Nincs highres mediaId: {}", mediaCubeMedia.getId()); + return null; + } + if (lowres == null) { + logger.info(marker, "Nincs lowres mediaId: {}", mediaCubeMedia.getId()); + return null; + } + String id = MetadataTypeDetector.truncateExtension(highres.getRelativePath()); + id = MetadataTypeDetector.truncateVersion(id); + boolean detect = MetadataTypeDetector.GuessMetadataType(id) == MetadataType.OctopusPlaceholder + || MetadataTypeDetector.GuessMetadataType(id) == MetadataType.OctopusStory; + if (!detect) { + logger.info(marker, "Nem bejátszó mediaId: {}, file: {}", mediaCubeMedia.getId(), highres.getRelativePath()); + return null; + } + + manager.executeQuery("SELECT mediaid FROM mediafile WHERE relativepath=? and storeid=? and id!=?", rs -> { + long mediaId = rs.getLong(1); + Media media = manager.getMedia(mediaId); + if (media.getMediaFilesCount() == 1) { + logger.info(marker, "Hiányzó szellem lowres hozzáadása mediaId: {}", media.getId()); + + MediaFile mf = (MediaFile) manager.get(MediaFile.class, lowres.getId()); + mf.setMedia(media); + mf.setId(0); + manager.add(mf); + media.setLength(mediaCubeMedia.getLength()); + manager.modify(media); + } + return true; + }, st -> { + st.setString(1, highres.getRelativePath()); + st.setLong(2, highresStore.getId()); + st.setLong(3, highres.getId()); + }); + + } + + return null; + } + + private MediaFile get(Store store, List mediaFiles) { + for (MediaFile mf : mediaFiles) { + if (mf.getStoreId() == store.getId()) + return mf; + } + return null; + } + +} diff --git a/server/user.jobengine.osgi.db/sql/4-CreateTrigger.db2 b/server/user.jobengine.osgi.db/sql/4-CreateTrigger.db2 deleted file mode 100644 index ce9888c0..00000000 --- a/server/user.jobengine.osgi.db/sql/4-CreateTrigger.db2 +++ /dev/null @@ -1,104 +0,0 @@ --- execute with --- db2 -td@ -vmf 2-CreateStructure.db2 - ---DROP TRIGGER TRG_INSERT_ITEM@ - ---CREATE TRIGGER TRG_INSERT_ITEM - --AFTER INSERT ON ITEM - --REFERENCING NEW AS r - --FOR EACH ROW ---BEGIN ATOMIC --- DECLARE x VARCHAR(255); --- CALL SYSPROC.SYSTS_UPDATE(NULL, 'item_title', NULL, 'hu_HU', :x); --- CALL SYSPROC.SYSTS_UPDATE(NULL, 'item_desc', NULL, 'hu_HU', :x); --- CALL SYSPROC.SYSTS_UPDATE(NULL, 'item_houseid', NULL, 'hu_HU', :x); ---END ---@ - - -CREATE TRIGGER DB2ADMIN.TRG_MEDIAFILE_AFTER_INSERT after insert -on mediafile -referencing new as n -for each row -when (n.storeid = 1) -begin atomic - insert into mediadescription (itemid, mediaid, mediafileid, description) - select - itemid, - mediaid, - mediafileid, - COALESCE(hundate(archived), '') concat ' ' - concat COALESCE(defdate(archived), '') concat ' ' - concat COALESCE(itemhouseid, '') concat ' ' - concat COALESCE(itemtitle, '') concat ' ' - concat COALESCE(itemdescription,'') concat ' ' - concat COALESCE(mediahouseid, '') concat ' ' - concat COALESCE(mediatitle, '') concat ' ' - concat COALESCE(mediadescription, '') concat ' ' - concat COALESCE(mediafilehouseid, '') - from vw_items_description - where mediafileid = n.id; -end -GO - -CREATE TRIGGER DB2ADMIN.TRG_MEDIAFILE_AFTER_UPDATE after update of HOUSEID -on mediafile -referencing new as n -for each row -when (n.storeid = 1) -begin atomic - update mediadescription set description = ( - select - COALESCE(hundate(archived), '') concat ' ' - concat COALESCE(defdate(archived), '') concat ' ' - concat COALESCE(itemhouseid, '') concat ' ' - concat COALESCE(itemtitle, '') concat ' ' - concat COALESCE(itemdescription,'') concat ' ' - concat COALESCE(mediahouseid, '') concat ' ' - concat COALESCE(mediatitle, '') concat ' ' - concat COALESCE(mediadescription, '') concat ' ' - concat COALESCE(mediafilehouseid, '') - from vw_items_description - where mediafileid = n.id); -end -GO - -CREATE TRIGGER DB2ADMIN.TRG_MEDIA_AFTER_UPDATE after update on media -referencing new as n -for each row -begin atomic - update mediadescription set description = ( - select - COALESCE(hundate(archived), '') concat ' ' - concat COALESCE(defdate(archived), '') concat ' ' - concat COALESCE(itemhouseid, '') concat ' ' - concat COALESCE(itemtitle, '') concat ' ' - concat COALESCE(itemdescription,'') concat ' ' - concat COALESCE(mediahouseid, '') concat ' ' - concat COALESCE(mediatitle, '') concat ' ' - concat COALESCE(mediadescription, '') concat ' ' - concat COALESCE(mediafilehouseid, '') - from vw_items_description - where mediaid = n.id); -end -GO - -CREATE TRIGGER DB2ADMIN.TRG_ITEM_AFTER_UPDATE after update on item -referencing new as n -for each row -begin atomic - update mediadescription set description = ( - select - COALESCE(hundate(archived), '') concat ' ' - concat COALESCE(defdate(archived), '') concat ' ' - concat COALESCE(itemhouseid, '') concat ' ' - concat COALESCE(itemtitle, '') concat ' ' - concat COALESCE(itemdescription,'') concat ' ' - concat COALESCE(mediahouseid, '') concat ' ' - concat COALESCE(mediatitle, '') concat ' ' - concat COALESCE(mediadescription, '') concat ' ' - concat COALESCE(mediafilehouseid, '') - from vw_items_description - where itemid = n.id); -end -GO diff --git a/server/user.jobengine.osgi.db/sql/4-CreateTrigger.sql b/server/user.jobengine.osgi.db/sql/4-CreateTrigger.sql new file mode 100644 index 00000000..409c3b4d --- /dev/null +++ b/server/user.jobengine.osgi.db/sql/4-CreateTrigger.sql @@ -0,0 +1,63 @@ +CREATE OR REPLACE FUNCTION "DB2ADMIN"."FULLDESC" (IN initemid BIGINT, IN inmediaid BIGINT, IN inmediafileid BIGINT) +returns CLOB(400000) +return +SELECT + COALESCE(hundate(archived), '') || ' ' || + COALESCE(defdate(archived), '') || ' ' || + COALESCE(itemhouseid, '') || ' ' || + COALESCE(itemtitle, '') || ' ' || + COALESCE(itemdescription,'') || ' ' || + COALESCE(mediahouseid, '') || ' ' || + COALESCE(mediatitle, '') || ' ' || + COALESCE(mediadescription, '') || ' ' || + COALESCE(mediafilehouseid, '') +from vw_items_description WHERE itemid = initemid AND mediaid = inmediaid AND mediafileid = inmediafileid +GO + +CREATE OR REPLACE TRIGGER DB2ADMIN.TRG_MEDIAFILE_AFTER_INSERT after insert +on mediafile +referencing new as n +for each row +when (n.storeid = 1) +begin atomic + insert into mediadescription (itemid, mediaid, mediafileid, description) + select + itemid, + mediaid, + mediafileid, + fulldesc(itemid, mediaid, mediafileid) + from vw_items + where mediafileid = n.id; +end +GO + +CREATE OR REPLACE TRIGGER DB2ADMIN.TRG_MEDIAFILE_AFTER_DELETE after delete +on mediafile +referencing old as o +for each row +when (o.storeid = 1) +begin atomic + delete from mediadescription where mediafileid = o.id; +end +GO + +CREATE OR REPLACE TRIGGER DB2ADMIN.TRG_MEDIA_AFTER_UPDATE after update on media +referencing new as n +for each row +begin atomic + update mediadescription SET description = fulldesc(itemid, mediaid, mediafileid) where mediaid = n.id; +end +GO + +CREATE OR REPLACE TRIGGER DB2ADMIN.TRG_ITEM_AFTER_UPDATE after update on item +referencing new as n +for each row +begin atomic + update mediadescription SET description = fulldesc(itemid, mediaid, mediafileid) where itemid = n.id; +end +GO + +--osszes frissitese +--update mediadescription SET description = fulldesc(itemid, mediaid, mediafileid) + + diff --git a/server/user.jobengine.osgi.server/test/user/jobengine/server/IT/Support.java b/server/user.jobengine.osgi.server/test/user/jobengine/server/IT/Support.java index d5408eb5..ceebf214 100644 --- a/server/user.jobengine.osgi.server/test/user/jobengine/server/IT/Support.java +++ b/server/user.jobengine.osgi.server/test/user/jobengine/server/IT/Support.java @@ -82,10 +82,10 @@ public class Support { System.setProperty("jobengine.octopus.stories.name", "stories180620"); System.setProperty("jobengine.octopus.storyfolders.name", "storyfolders180620"); - System.setProperty("jobengine.nosql.db.url", "jdbc:db2://10.10.1.27:50000/mc:retrieveMessagesFromServerOnGetMessage=true;"); + System.setProperty("jobengine.nosql.db.url", "jdbc:db2://10.10.1.29:50000/mc:retrieveMessagesFromServerOnGetMessage=true;"); System.setProperty("jobengine.nosql.db.user", "db2admin"); System.setProperty("jobengine.nosql.db.password", "password"); - System.setProperty(ItemManager.DBURL, "jdbc:db2://10.10.1.27:50000/mc:retrieveMessagesFromServerOnGetMessage=true;"); + System.setProperty(ItemManager.DBURL, "jdbc:db2://10.10.1.29:50000/mc:retrieveMessagesFromServerOnGetMessage=true;"); System.setProperty(ItemManager.DBUSERNAME, "db2admin"); System.setProperty(ItemManager.DBPASSWORD, "password"); System.setProperty(LogUtils.LOGLEVEL, "INFO"); @@ -592,4 +592,36 @@ public class Support { String idToCheck = houseid.substring(0, houseid.lastIndexOf("-")); System.out.println(idToCheck); } + + @Test + public void test5() throws Exception { + Item i = manager.createItem("Generic", "Item", "", "desc1"); + Media m = manager.createMedia("Generic", "Media", "", "desc2"); + i.appendMedia(m); + MediaFile mf = manager.createMediaFile("xxx", manager.getFileType("High-res"), manager.getSystemStore(false), m); + m.appendMediaFile(mf); + manager.mergeItemStructure(i); + System.out.println("ItemId:" + i.getId()); + System.out.println("MediaId:" + m.getId()); + System.out.println("MediaFileId:" + mf.getId()); + + i.setHouseId("1desc1"); + i.modify(); + System.out.println("Item modified"); + + m.setHouseId("2desc2"); + m.modify(); + System.out.println("Media modified"); + + mf.remove(); + System.out.println("MediaFile deleted"); + } + + @Test + public void test6() throws Exception { + String result = "sss.valami.yy"; + if (result != null && result.contains(".")) + result = result.substring(0, result.lastIndexOf(".")); + System.out.println(result); + } }