From 16d19f50c5b18ee6308cae9d9ba7924e3bb8660f Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Mon, 2 Oct 2017 22:06:00 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30505 --- .../run-mediacube-server-bsh.launch | 2 +- .../run-mediacube-server-localhost.launch | 2 +- .../run-mediacube-server.launch | 2 +- .../run-mediacube-server2_adam.launch | 4 +- server/-configuration/scheduledjobs.json | 7 + server/-product/mediacube.product | 32 +- .../config/config.xml | 6 +- .../jobtemplates/archive-material.xml | 4 +- .../jobtemplates/retrieve-material.xml | 17 + .../retrieve-traffic-missing-materials.xml | 6 + .../jobtemplates/sync-octopus.xml | 2 +- .../CheckTrafficMissingMaterialsStep.java | 84 ++++ ...inerStep.java => SyncOCTOPUSDataStep.java} | 2 +- .../server/steps/TSMRestoreStep.java | 24 +- ...odeStep.java => TranscodeSELENIOStep.java} | 4 +- .../database/db_create.sql | 3 + .../database/structure.sql | 4 + .../src/user/jobengine/db/MediaFile.java | 17 +- .../src/user/jobengine/db/MediaFileDAO.sqlj | 38 +- .../jobengine/db/SearchDefinitionDAO.java.tmp | 440 ------------------ .../user/jobengine/zk/model/SearchModel.java | 8 +- 21 files changed, 209 insertions(+), 499 deletions(-) create mode 100644 server/user.jobengine.executors/jobtemplates/retrieve-material.xml create mode 100644 server/user.jobengine.executors/jobtemplates/retrieve-traffic-missing-materials.xml create mode 100644 server/user.jobengine.executors/src/user/jobengine/server/steps/CheckTrafficMissingMaterialsStep.java rename server/user.jobengine.executors/src/user/jobengine/server/steps/{OCTOPUSDataMinerStep.java => SyncOCTOPUSDataStep.java} (92%) rename server/user.jobengine.executors/src/user/jobengine/server/steps/{SelenioLowresTranscodeStep.java => TranscodeSELENIOStep.java} (96%) delete mode 100644 server/user.jobengine.osgi.db/src/user/jobengine/db/SearchDefinitionDAO.java.tmp diff --git a/server/-configuration/run-mediacube-server-bsh.launch b/server/-configuration/run-mediacube-server-bsh.launch index 0cef7afc..ed3b2013 100644 --- a/server/-configuration/run-mediacube-server-bsh.launch +++ b/server/-configuration/run-mediacube-server-bsh.launch @@ -19,7 +19,7 @@ - + diff --git a/server/-configuration/run-mediacube-server-localhost.launch b/server/-configuration/run-mediacube-server-localhost.launch index 232365c4..810aaaf9 100644 --- a/server/-configuration/run-mediacube-server-localhost.launch +++ b/server/-configuration/run-mediacube-server-localhost.launch @@ -19,7 +19,7 @@ - + diff --git a/server/-configuration/run-mediacube-server.launch b/server/-configuration/run-mediacube-server.launch index e127a428..e1005b1c 100644 --- a/server/-configuration/run-mediacube-server.launch +++ b/server/-configuration/run-mediacube-server.launch @@ -19,7 +19,7 @@ - + diff --git a/server/-configuration/run-mediacube-server2_adam.launch b/server/-configuration/run-mediacube-server2_adam.launch index 171e419b..e4400e2a 100644 --- a/server/-configuration/run-mediacube-server2_adam.launch +++ b/server/-configuration/run-mediacube-server2_adam.launch @@ -19,10 +19,10 @@ - + - + diff --git a/server/-configuration/scheduledjobs.json b/server/-configuration/scheduledjobs.json index 0c947a47..2d0a4edb 100644 --- a/server/-configuration/scheduledjobs.json +++ b/server/-configuration/scheduledjobs.json @@ -23,6 +23,13 @@ ] }, { + "active": false, + "name" : "Traffic anyagok visszatöltése", + "template": "retrieve-traffic-missing-materials.xml", + "executeimmediate": true, + "cronexpression": "0 0 0/1 1/1 * ? *" + }, + { "active": false, "name" : "NEXIO anyagok törlése", "template": "delete-nexio-materials.xml", diff --git a/server/-product/mediacube.product b/server/-product/mediacube.product index c600e857..2af44d6c 100644 --- a/server/-product/mediacube.product +++ b/server/-product/mediacube.product @@ -9,19 +9,19 @@ -consoleLog -console - -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8888 - -#System --Dorg.eclipse.equinox.http.jetty.http.port=8080 --Dorg.eclipse.epp.logging.aeri.skipReports=true --Declipse.ignoreApp=true --Dosgi.noShutdown=true --Djetty.home=./configuration/jetty --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 --Dlog4j.configurationFile=./configuration/log4j2.xml --Djobengine.loglevel=INFO --Djobengine.jobsteps.root=./configuration/executors --Djobengine.jobtemplates.root=./configuration/jobtemplates + -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8888 + +#System +-Dorg.eclipse.equinox.http.jetty.http.port=8080 +-Dorg.eclipse.epp.logging.aeri.skipReports=true +-Declipse.ignoreApp=true +-Dosgi.noShutdown=true +-Djetty.home=./configuration/jetty +-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 +-Dlog4j.configurationFile=./configuration/log4j2.xml +-Djobengine.loglevel=INFO +-Djobengine.jobsteps.root=./configuration/executors +-Djobengine.jobtemplates.root=./configuration/jobtemplates -Djobengine.jobscheduling.config=./configuration/scheduledjobs.json #Database @@ -155,12 +155,6 @@ - - - - - - diff --git a/server/user.jobengine.executors/config/config.xml b/server/user.jobengine.executors/config/config.xml index 3b8fa33f..4baca823 100644 --- a/server/user.jobengine.executors/config/config.xml +++ b/server/user.jobengine.executors/config/config.xml @@ -2,9 +2,13 @@ + + + - + + \ No newline at end of file diff --git a/server/user.jobengine.executors/jobtemplates/archive-material.xml b/server/user.jobengine.executors/jobtemplates/archive-material.xml index bc716cea..784b0f50 100644 --- a/server/user.jobengine.executors/jobtemplates/archive-material.xml +++ b/server/user.jobengine.executors/jobtemplates/archive-material.xml @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/server/user.jobengine.executors/jobtemplates/retrieve-material.xml b/server/user.jobengine.executors/jobtemplates/retrieve-material.xml new file mode 100644 index 00000000..b236b501 --- /dev/null +++ b/server/user.jobengine.executors/jobtemplates/retrieve-material.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/user.jobengine.executors/jobtemplates/retrieve-traffic-missing-materials.xml b/server/user.jobengine.executors/jobtemplates/retrieve-traffic-missing-materials.xml new file mode 100644 index 00000000..d311ad4b --- /dev/null +++ b/server/user.jobengine.executors/jobtemplates/retrieve-traffic-missing-materials.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/server/user.jobengine.executors/jobtemplates/sync-octopus.xml b/server/user.jobengine.executors/jobtemplates/sync-octopus.xml index 04642a7f..8a6d0b12 100644 --- a/server/user.jobengine.executors/jobtemplates/sync-octopus.xml +++ b/server/user.jobengine.executors/jobtemplates/sync-octopus.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CheckTrafficMissingMaterialsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CheckTrafficMissingMaterialsStep.java new file mode 100644 index 00000000..487de5ed --- /dev/null +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CheckTrafficMissingMaterialsStep.java @@ -0,0 +1,84 @@ +package user.jobengine.server.steps; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import user.jobengine.db.IItemManager; +import user.jobengine.db.Media; +import user.jobengine.db.MediaFile; +import user.jobengine.db.MediaFileDAO; +import user.jobengine.server.IJobEngine; +import user.jobengine.server.IJobRuntime; + +public class CheckTrafficMissingMaterialsStep extends JobStep { + private static final Logger logger = LogManager.getLogger(); + private static final String SQLSERVER_JDBC_SQL_SERVER_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; + private static final String TRAFFIC_DB_PASSWORD = "traffic.db.password"; + private static final String TRAFFIC_DB_USER = "traffic.db.user"; + private static final String TRAFFIC_DB_URL = "traffic.db.url"; + private static final String SQL = "{call clIFsp_EC_MAM(1001, 40, Null, Null, ?)}"; + private IItemManager manager; + + @StepEntry + public Object[] execute(IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { + List result = new ArrayList<>(); + manager = jobEngine.getItemManager(); + try (Connection con = getSQLConnection(); PreparedStatement stmt = con.prepareStatement(SQL)) { + stmt.setInt(1, 7); + try (ResultSet rs = stmt.executeQuery()) { + if (rs.next()) { + String trafficId = rs.getString(5); + if (StringUtils.isNotBlank(trafficId)) { + try { + processTrafficId(result, trafficId); + } catch (Exception e) { + logger.error(getMarker(), "Hiba lépett fel az {} anyag visszatöltéskor. A rendszer hibaüzenete: {}", trafficId, e.getMessage()); + } + } + + } + } + } catch (Exception e) { + logger.catching(e); + throw e; + } finally { + } + return new Object[] {}; + } + + private Connection getSQLConnection() throws Exception { + Connection result = null; + Class.forName(SQLSERVER_JDBC_SQL_SERVER_DRIVER); + String url = System.getProperty(TRAFFIC_DB_URL); + String user = System.getProperty(TRAFFIC_DB_USER); + String pass = System.getProperty(TRAFFIC_DB_PASSWORD); + result = DriverManager.getConnection(url, user, pass); + return result; + } + + private void processTrafficId(List result, String trafficId) throws Exception { + MediaFileDAO dao = (MediaFileDAO) manager.getBaseDAO(MediaFile.class); + List medias = dao.getByHouseId(trafficId); + if (medias.size() == 0) { + logger.error(getMarker(), "Az {} anyag nem található az archívumban.", trafficId); + return; + } + + if (medias.size() > 0) { + logger.error(getMarker(), "Az {} anyagból egynél több található az archívumban.", trafficId); + return; + } + + result.add(medias.get(0)); + + } + +} diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/OCTOPUSDataMinerStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/SyncOCTOPUSDataStep.java similarity index 92% rename from server/user.jobengine.executors/src/user/jobengine/server/steps/OCTOPUSDataMinerStep.java rename to server/user.jobengine.executors/src/user/jobengine/server/steps/SyncOCTOPUSDataStep.java index 91e45b72..f6e6fc21 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/OCTOPUSDataMinerStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/SyncOCTOPUSDataStep.java @@ -9,7 +9,7 @@ import user.commons.remotestore.ProgressEvent; import user.jobengine.server.IJobEngine; import user.jobengine.server.IJobRuntime; -public class OCTOPUSDataMinerStep extends JobStep { +public class SyncOCTOPUSDataStep extends JobStep { private static final Logger logger = LogManager.getLogger(); private IProgressEventListener progressListener; diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMRestoreStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMRestoreStep.java index 915ffbf6..1a745b5c 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMRestoreStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TSMRestoreStep.java @@ -20,26 +20,28 @@ import user.jobengine.server.IJobRuntime; public class TSMRestoreStep extends JobStep { private static final Logger logger = LogManager.getLogger(); + @Override + public void cleanup() { + // if (sourceUri != null) + // sourceUri.clearListeners(); + } + @StepEntry public Object[] execute(Media media, IJobEngine jobEngine, IJobRuntime jobRuntime) throws Exception { - RemoteFile result = null; final IJobRuntime runtime = jobRuntime; IItemManager manager = jobEngine.getItemManager(); Store systemStore = manager.getSystemStore(false); - Store mfStore = null; MediaFile mediaFile = null; for (MediaFile mf : media.getMediaFiles()) { - mediaFile = mf; - mfStore = mf.getStore(); - if (mfStore.getId() == systemStore.getId()) + if (mf.getStore().getId() == systemStore.getId()) { + mediaFile = mf; break; + } } if (mediaFile == null) throw new Exception("Can not find HIRES media file"); - if (mfStore == null) - throw new Exception("Can not find HIRES store"); String path = mediaFile.getRelativePath(); logger.info("Relative path is: " + path); @@ -55,7 +57,7 @@ public class TSMRestoreStep extends JobStep { StoreUri sourceUri = new StoreUri(); sourceUri.setProtocol(RemoteStoreProtocol.TSM); - StoreUri target = mfStore.getTargetStoreUri(RemoteStoreProtocol.LOCAL); + StoreUri target = systemStore.getTargetStoreUri(RemoteStoreProtocol.LOCAL); logger.info("Target is: " + target.getUri()); sourceUri.addProgressListener(new IProgressEventListener() { @Override @@ -72,10 +74,4 @@ public class TSMRestoreStep extends JobStep { result = sourceUri.transferFrom(target, sourceFileName, "restored_" + sourceFileName); return new Object[] { result }; } - - @Override - public void cleanup() { - // if (sourceUri != null) - // sourceUri.clearListeners(); - } } diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/SelenioLowresTranscodeStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java similarity index 96% rename from server/user.jobengine.executors/src/user/jobengine/server/steps/SelenioLowresTranscodeStep.java rename to server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java index a88d75a6..33082441 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/SelenioLowresTranscodeStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java @@ -37,7 +37,7 @@ import user.jobengine.db.Store; import user.jobengine.server.IJobEngine; import user.jobengine.server.IJobRuntime; -public class SelenioLowresTranscodeStep extends JobStep { +public class TranscodeSELENIOStep extends JobStep { private static final String LOWRES_FILETYPE = "Low-res"; private static final Logger logger = LogManager.getLogger(); @@ -49,7 +49,7 @@ public class SelenioLowresTranscodeStep extends JobStep { private Store store; private FileType fileType; - public SelenioLowresTranscodeStep() throws Exception { + public TranscodeSELENIOStep() throws Exception { try { address = System.getProperty("jobengine.selenio.address"); if (StringUtils.isBlank(address)) diff --git a/server/user.jobengine.osgi.db/database/db_create.sql b/server/user.jobengine.osgi.db/database/db_create.sql index 9c11841c..65ef6350 100644 --- a/server/user.jobengine.osgi.db/database/db_create.sql +++ b/server/user.jobengine.osgi.db/database/db_create.sql @@ -251,11 +251,14 @@ CREATE TABLE MEDIAFILE FILETYPEID BIGINT NOT NULL, RELATIVEPATH VARCHAR(255) NOT NULL, FILESTRUCTINFO VARCHAR(255), + HOUSEID VARCHAR(40), CONSTRAINT FK_MEDIAFILE_MEDIAID FOREIGN KEY (MEDIAID) REFERENCES MEDIA (ID), CONSTRAINT FK_MEDIAFILE_STOREID FOREIGN KEY (STOREID) REFERENCES STORE (ID), CONSTRAINT FK_MEDIAFILE_FILETYPEID FOREIGN KEY (FILETYPEID) REFERENCES FILETYPE (ID) )@ +CREATE INDEX IDX_MEDIAFILE_HOUSEID ON MEDIAFILE ("HOUSEID")@ + CREATE TABLE STOREURI ( ID BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1) PRIMARY KEY, diff --git a/server/user.jobengine.osgi.db/database/structure.sql b/server/user.jobengine.osgi.db/database/structure.sql index 7e08eae8..2d5fb7b6 100644 --- a/server/user.jobengine.osgi.db/database/structure.sql +++ b/server/user.jobengine.osgi.db/database/structure.sql @@ -1,3 +1,7 @@ + +ALTER TABLE MEDIAFILE ADD COLUMN HOUSEID VARCHAR(40) +CREATE INDEX IDX_MEDIAFILE_HOUSEID ON MEDIAFILE ("HOUSEID") + ALTER TABLE JOB ADD COLUMN PARENTJOBID BIGINT /*ezt futtasd*/ diff --git a/server/user.jobengine.osgi.db/src/user/jobengine/db/MediaFile.java b/server/user.jobengine.osgi.db/src/user/jobengine/db/MediaFile.java index 810bc27f..e7acd34b 100644 --- a/server/user.jobengine.osgi.db/src/user/jobengine/db/MediaFile.java +++ b/server/user.jobengine.osgi.db/src/user/jobengine/db/MediaFile.java @@ -15,6 +15,7 @@ public class MediaFile extends EntityBase implements Serializable { private String relativePath = null; private Store store = null; private long storeId = 0; + private String houseId = null; public String getFileStructInfo() { return this.fileStructInfo; @@ -30,9 +31,13 @@ public class MediaFile extends EntityBase implements Serializable { return this.fileTypeId; } + public String getHouseId() { + return houseId; + } + public Media getMedia() { if (this.media == null && this.mediaId != 0) { - this.media = (Media)ItemManager.getInstance().getMedia(this.mediaId); + this.media = ItemManager.getInstance().getMedia(this.mediaId); } return this.media; } @@ -40,7 +45,7 @@ public class MediaFile extends EntityBase implements Serializable { public long getMediaId() { return this.mediaId; } - + public String getRelativePath() { return this.relativePath; } @@ -52,7 +57,7 @@ public class MediaFile extends EntityBase implements Serializable { } return this.store; } - + public long getStoreId() { return this.storeId; } @@ -72,10 +77,14 @@ public class MediaFile extends EntityBase implements Serializable { this.fileTypeId = fileTypeId; } + public void setHouseId(String houseId) { + this.houseId = houseId; + } + public void setMedia(Media media) { //checkParameter("Media", media); this.media = media; - this.mediaId = media.getId(); + this.mediaId = media.getId(); } public void setMediaId(long mediaId) { diff --git a/server/user.jobengine.osgi.db/src/user/jobengine/db/MediaFileDAO.sqlj b/server/user.jobengine.osgi.db/src/user/jobengine/db/MediaFileDAO.sqlj index 4171300f..2a9e05da 100644 --- a/server/user.jobengine.osgi.db/src/user/jobengine/db/MediaFileDAO.sqlj +++ b/server/user.jobengine.osgi.db/src/user/jobengine/db/MediaFileDAO.sqlj @@ -6,7 +6,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -#sql iterator MediaFileIter(long id, long mediaId, long storeId, long fileTypeId, String relativePath, String fileStructInfo); +#sql iterator MediaFileIter(long id, long mediaId, long storeId, long fileTypeId, String relativePath, String fileStructInfo, String houseId); @SuppressWarnings("unused") public class MediaFileDAO extends EntityBaseDAO { @@ -27,6 +27,7 @@ public class MediaFileDAO extends EntityBaseDAO { entity.setFileTypeId(iterator.fileTypeId()); entity.setRelativePath(iterator.relativePath()); entity.setFileStructInfo(iterator.fileStructInfo()); + entity.setHouseId(iterator.houseId()); if (result == null) result = new ArrayList(); @@ -39,21 +40,21 @@ public class MediaFileDAO extends EntityBaseDAO { @Override protected ResultSetIterImpl selectByKey(DefaultContext context, long id) throws SQLException{ MediaFileIter iter = null; - #sql [context] iter = { SELECT ID, MEDIAID, STOREID, FILETYPEID, RELATIVEPATH, FILESTRUCTINFO FROM MEDIAFILE WHERE ID = :id }; + #sql [context] iter = { SELECT ID, MEDIAID, STOREID, FILETYPEID, RELATIVEPATH, FILESTRUCTINFO, HOUSEID FROM MEDIAFILE WHERE ID = :id }; return iter; } @Override protected ResultSetIterImpl selectByForeignKey(DefaultContext context, long id) throws SQLException{ MediaFileIter iter = null; - #sql [context] iter = { SELECT ID, MEDIAID, STOREID, FILETYPEID, RELATIVEPATH, FILESTRUCTINFO FROM MEDIAFILE WHERE MEDIAID = :id }; + #sql [context] iter = { SELECT ID, MEDIAID, STOREID, FILETYPEID, RELATIVEPATH, FILESTRUCTINFO, HOUSEID FROM MEDIAFILE WHERE MEDIAID = :id }; return iter; } @Override protected ResultSetIterImpl selectAll(DefaultContext context) throws SQLException{ MediaFileIter iter = null; - #sql [context] iter = { SELECT ID, MEDIAID, STOREID, FILETYPEID, RELATIVEPATH, FILESTRUCTINFO FROM MEDIAFILE }; + #sql [context] iter = { SELECT ID, MEDIAID, STOREID, FILETYPEID, RELATIVEPATH, FILESTRUCTINFO, HOUSEID FROM MEDIAFILE }; return iter; } @@ -76,8 +77,9 @@ public class MediaFileDAO extends EntityBaseDAO { long fileTypeId = obj.getFileTypeId(); String relativePath = obj.getRelativePath(); String fileStructInfo = obj.getFileStructInfo(); + String houseId = obj.getHouseId(); - #sql [context] { UPDATE MEDIAFILE SET MEDIAID = :mediaId, STOREID = :storeId, FILETYPEID = :fileTypeId, RELATIVEPATH = :relativePath, FILESTRUCTINFO = :fileStructInfo WHERE ID = :id }; + #sql [context] { UPDATE MEDIAFILE SET MEDIAID = :mediaId, STOREID = :storeId, FILETYPEID = :fileTypeId, RELATIVEPATH = :relativePath, FILESTRUCTINFO = :fileStructInfo, HOUSEID = :houseId WHERE ID = :id }; } @Override @@ -88,8 +90,9 @@ public class MediaFileDAO extends EntityBaseDAO { long fileTypeId = obj.getFileTypeId(); String relativePath = obj.getRelativePath(); String fileStructInfo = obj.getFileStructInfo(); + String houseId = obj.getHouseId(); - #sql [context] { INSERT INTO MEDIAFILE (MEDIAID, STOREID, FILETYPEID, RELATIVEPATH, FILESTRUCTINFO) VALUES (:mediaId, :storeId, :fileTypeId, :relativePath, :fileStructInfo) }; + #sql [context] { INSERT INTO MEDIAFILE (MEDIAID, STOREID, FILETYPEID, RELATIVEPATH, FILESTRUCTINFO, HOUSEID) VALUES (:mediaId, :storeId, :fileTypeId, :relativePath, :fileStructInfo, :houseId) }; } void addAll(DefaultContext context, IEntityBase entity) throws SQLException { @@ -113,4 +116,27 @@ public class MediaFileDAO extends EntityBaseDAO { #sql [context] { DELETE FROM MEDIAFILE WHERE MEDIAID = :filterId }; manager.traceOut(); } + + private MediaFileIter selectByHouseId(DefaultContext context, String houseId) throws SQLException{ + MediaFileIter iter = null; + #sql [context] iter = { SELECT ID, MEDIAID, STOREID, FILETYPEID, RELATIVEPATH, FILESTRUCTINFO, HOUSEID FROM MEDIAFILE WHERE HOUSEID = :houseId }; + return iter; + } + + public List getByHouseId(String houseId) { + manager.traceIn(); + List result = null; + DefaultContext context = manager.getDbContext(); + try { + MediaFileIter iter = selectByHouseId(context, houseId); + result = getList(context, iter, false); + } catch (Exception e) { + throw new ItemManagerException(e); + } finally { + manager.putDbContext(context); + } + manager.traceOut(); + return result; + } + } diff --git a/server/user.jobengine.osgi.db/src/user/jobengine/db/SearchDefinitionDAO.java.tmp b/server/user.jobengine.osgi.db/src/user/jobengine/db/SearchDefinitionDAO.java.tmp deleted file mode 100644 index da742aa1..00000000 --- a/server/user.jobengine.osgi.db/src/user/jobengine/db/SearchDefinitionDAO.java.tmp +++ /dev/null @@ -1,440 +0,0 @@ -/*@lineinfo:filename=SearchDefinitionDAO*//*@lineinfo:user-code*//*@lineinfo:1^1*/package user.jobengine.db; - -import user.commons.IEntityBase; -import sqlj.runtime.ref.*; -import java.sql.SQLException; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; - -/*@lineinfo:generated-code*//*@lineinfo:10^2*/ - -// ************************************************************ -// SQLJ iterator declaration: -// ************************************************************ - -class SearchDefinitionIter -extends sqlj.runtime.ref.ResultSetIterImpl -implements sqlj.runtime.NamedIterator -{ - private int dataNdx; - private int modifiedNdx; - private int createdNdx; - private int nameNdx; - private int idNdx; - public SearchDefinitionIter(sqlj.runtime.profile.RTResultSet resultSet) - throws java.sql.SQLException - { - super(resultSet); - idNdx = findColumn("id"); - nameNdx = findColumn("name"); - createdNdx = findColumn("created"); - modifiedNdx = findColumn("modified"); - dataNdx = findColumn("data"); - } - public SearchDefinitionIter(sqlj.runtime.profile.RTResultSet resultSet, int fetchSize, int maxRows) - throws java.sql.SQLException - { - super(resultSet, fetchSize, maxRows); - idNdx = findColumn("id"); - nameNdx = findColumn("name"); - createdNdx = findColumn("created"); - modifiedNdx = findColumn("modified"); - dataNdx = findColumn("data"); - } - public long id() - throws java.sql.SQLException - { - return resultSet.getLongNoNull(idNdx); - } - public String name() - throws java.sql.SQLException - { - return resultSet.getString(nameNdx); - } - public Timestamp created() - throws java.sql.SQLException - { - return resultSet.getTimestamp(createdNdx); - } - public Timestamp modified() - throws java.sql.SQLException - { - return resultSet.getTimestamp(modifiedNdx); - } - public byte[] data() - throws java.sql.SQLException - { - return resultSet.getBytes(dataNdx); - } -} - - -// ************************************************************ - -/*@lineinfo:user-code*//*@lineinfo:10^107*/ - -@SuppressWarnings("unused") -public class SearchDefinitionDAO extends EntityBaseDAO { - - public SearchDefinitionDAO(ItemManager manager) { - super(manager); - } - - @Override - protected List entities(DefaultContext context, ResultSetIterImpl iter, boolean isChunked) throws SQLException { - List result = null; - SearchDefinitionIter iterator = (SearchDefinitionIter) iter; - while (iterator.next()) { - SearchDefinition entity = new SearchDefinition(); - entity.setId(iterator.id()); - entity.setName(iterator.name()); - entity.setCreated(iterator.created()); - entity.setModified(iterator.modified()); - if(isChunked == false){ - entity.setData(iterator.data()); - } - - if (result == null) - result = new ArrayList(); - result.add(entity); - } - iterator.close(); - return result; - } - - protected ResultSetIterImpl selectByName(DefaultContext context, String nameFilter) throws SQLException{ - SearchDefinitionIter iter = null; - /*@lineinfo:generated-code*//*@lineinfo:43^2*/ - -// ************************************************************ -// #sql [context] iter = { SELECT ID, NAME, CREATED, MODIFIED, DATA FROM SEARCHDEFINITION WHERE (UPPER(NAME) LIKE :nameFilter) ORDER BY CREATED DESC }; -// ************************************************************ - -{ - sqlj.runtime.ConnectionContext __sJT_connCtx = context; - if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_DEFAULT_CONN_CTX(); - sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext(); - if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX(); - synchronized (__sJT_execCtx) { - sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SearchDefinitionDAO_SJProfileKeys.getKey(0), 0); - try - { - __sJT_stmt.setString(1, nameFilter); - iter = new SearchDefinitionIter(__sJT_execCtx.executeQuery(), __sJT_execCtx.getFetchSize(), __sJT_execCtx.getMaxRows()); - } - finally - { - __sJT_execCtx.releaseStatement(); - } - } -} - - -// ************************************************************ - -/*@lineinfo:user-code*//*@lineinfo:43^147*/ - return iter; - } - - protected ResultSetIterImpl selectByModified(DefaultContext context) throws SQLException{ - SearchDefinitionIter iter = null; - /*@lineinfo:generated-code*//*@lineinfo:49^2*/ - -// ************************************************************ -// #sql [context] iter = { SELECT ID, NAME, CREATED, MODIFIED, DATA FROM SEARCHDEFINITION ORDER BY CREATED DESC FETCH FIRST 5 ROWS ONLY }; -// ************************************************************ - -{ - sqlj.runtime.ConnectionContext __sJT_connCtx = context; - if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_DEFAULT_CONN_CTX(); - sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext(); - if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX(); - synchronized (__sJT_execCtx) { - sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SearchDefinitionDAO_SJProfileKeys.getKey(0), 1); - try - { - iter = new SearchDefinitionIter(__sJT_execCtx.executeQuery(), __sJT_execCtx.getFetchSize(), __sJT_execCtx.getMaxRows()); - } - finally - { - __sJT_execCtx.releaseStatement(); - } - } -} - - -// ************************************************************ - -/*@lineinfo:user-code*//*@lineinfo:49^134*/ - return iter; - } - - @Override - protected ResultSetIterImpl selectByKey(DefaultContext context, long id) throws SQLException{ - SearchDefinitionIter iter = null; - /*@lineinfo:generated-code*//*@lineinfo:56^2*/ - -// ************************************************************ -// #sql [context] iter = { SELECT ID, NAME, CREATED, MODIFIED, DATA FROM SEARCHDEFINITION WHERE ID = :id }; -// ************************************************************ - -{ - sqlj.runtime.ConnectionContext __sJT_connCtx = context; - if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_DEFAULT_CONN_CTX(); - sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext(); - if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX(); - synchronized (__sJT_execCtx) { - sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SearchDefinitionDAO_SJProfileKeys.getKey(0), 2); - try - { - __sJT_stmt.setLong(1, id); - iter = new SearchDefinitionIter(__sJT_execCtx.executeQuery(), __sJT_execCtx.getFetchSize(), __sJT_execCtx.getMaxRows()); - } - finally - { - __sJT_execCtx.releaseStatement(); - } - } -} - - -// ************************************************************ - -/*@lineinfo:user-code*//*@lineinfo:56^104*/ - return iter; - } - - @Override - protected ResultSetIterImpl selectAll(DefaultContext context) throws SQLException{ - SearchDefinitionIter iter = null; - /*@lineinfo:generated-code*//*@lineinfo:63^2*/ - -// ************************************************************ -// #sql [context] iter = { SELECT ID, NAME, CREATED, MODIFIED, DATA FROM SEARCHDEFINITION }; -// ************************************************************ - -{ - sqlj.runtime.ConnectionContext __sJT_connCtx = context; - if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_DEFAULT_CONN_CTX(); - sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext(); - if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX(); - synchronized (__sJT_execCtx) { - sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SearchDefinitionDAO_SJProfileKeys.getKey(0), 3); - try - { - iter = new SearchDefinitionIter(__sJT_execCtx.executeQuery(), __sJT_execCtx.getFetchSize(), __sJT_execCtx.getMaxRows()); - } - finally - { - __sJT_execCtx.releaseStatement(); - } - } -} - - -// ************************************************************ - -/*@lineinfo:user-code*//*@lineinfo:63^88*/ - return iter; - } - - @Override - protected void delete(DefaultContext context, long id) throws SQLException{ - /*@lineinfo:generated-code*//*@lineinfo:69^2*/ - -// ************************************************************ -// #sql [context] { DELETE FROM SEARCHDEFINITION WHERE ID = :id }; -// ************************************************************ - -{ - sqlj.runtime.ConnectionContext __sJT_connCtx = context; - if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_DEFAULT_CONN_CTX(); - sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext(); - if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX(); - synchronized (__sJT_execCtx) { - sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SearchDefinitionDAO_SJProfileKeys.getKey(0), 4); - try - { - __sJT_stmt.setLong(1, id); - __sJT_execCtx.executeUpdate(); - } - finally - { - __sJT_execCtx.releaseStatement(); - } - } -} - - -// ************************************************************ - -/*@lineinfo:user-code*//*@lineinfo:69^63*/ - } - - @Override - protected void truncateTable(DefaultContext context) throws SQLException{ - /*@lineinfo:generated-code*//*@lineinfo:74^2*/ - -// ************************************************************ -// #sql [context] { TRUNCATE TABLE SEARCHDEFINITION DROP STORAGE IGNORE DELETE TRIGGERS IMMEDIATE }; -// ************************************************************ - -{ - sqlj.runtime.ConnectionContext __sJT_connCtx = context; - if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_DEFAULT_CONN_CTX(); - sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext(); - if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX(); - synchronized (__sJT_execCtx) { - sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SearchDefinitionDAO_SJProfileKeys.getKey(0), 5); - try - { - __sJT_execCtx.executeUpdate(); - } - finally - { - __sJT_execCtx.releaseStatement(); - } - } -} - - -// ************************************************************ - -/*@lineinfo:user-code*//*@lineinfo:74^97*/ - } - - @Override - protected void update(DefaultContext context, IEntityBase entity) throws SQLException{ - SearchDefinition obj = (SearchDefinition) entity; - long id = obj.getId(); - String name = obj.getName(); - Timestamp created = obj.getCreated(); - Timestamp modified = obj.getModified(); - byte[] data = obj.getData(); - - /*@lineinfo:generated-code*//*@lineinfo:86^2*/ - -// ************************************************************ -// #sql [context] { UPDATE SEARCHDEFINITION SET NAME = :name, CREATED = :created, MODIFIED = :modified, DATA = :data WHERE ID = :id }; -// ************************************************************ - -{ - sqlj.runtime.ConnectionContext __sJT_connCtx = context; - if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_DEFAULT_CONN_CTX(); - sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext(); - if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX(); - synchronized (__sJT_execCtx) { - sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SearchDefinitionDAO_SJProfileKeys.getKey(0), 6); - try - { - __sJT_stmt.setString(1, name); - __sJT_stmt.setTimestamp(2, created); - __sJT_stmt.setTimestamp(3, modified); - __sJT_stmt.setBytes(4, data); - __sJT_stmt.setLong(5, id); - __sJT_execCtx.executeUpdate(); - } - finally - { - __sJT_execCtx.releaseStatement(); - } - } -} - - -// ************************************************************ - -/*@lineinfo:user-code*//*@lineinfo:86^131*/ - } - - @Override - protected void insert(DefaultContext context, IEntityBase entity) throws SQLException{ - SearchDefinition obj = (SearchDefinition) entity; - String name = obj.getName(); - Timestamp created = obj.getCreated(); - Timestamp modified = obj.getModified(); - byte[] data = obj.getData(); - - /*@lineinfo:generated-code*//*@lineinfo:97^2*/ - -// ************************************************************ -// #sql [context] { INSERT INTO SEARCHDEFINITION (NAME, CREATED, MODIFIED, DATA) VALUES (:name, :created, :modified, :data) }; -// ************************************************************ - -{ - sqlj.runtime.ConnectionContext __sJT_connCtx = context; - if (__sJT_connCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_DEFAULT_CONN_CTX(); - sqlj.runtime.ExecutionContext __sJT_execCtx = __sJT_connCtx.getExecutionContext(); - if (__sJT_execCtx == null) sqlj.runtime.error.RuntimeRefErrors.raise_NULL_EXEC_CTX(); - synchronized (__sJT_execCtx) { - sqlj.runtime.profile.RTStatement __sJT_stmt = __sJT_execCtx.registerStatement(__sJT_connCtx, SearchDefinitionDAO_SJProfileKeys.getKey(0), 7); - try - { - __sJT_stmt.setString(1, name); - __sJT_stmt.setTimestamp(2, created); - __sJT_stmt.setTimestamp(3, modified); - __sJT_stmt.setBytes(4, data); - __sJT_execCtx.executeUpdate(); - } - finally - { - __sJT_execCtx.releaseStatement(); - } - } -} - - -// ************************************************************ - -/*@lineinfo:user-code*//*@lineinfo:97^123*/ - } - - public List getFilteredEntities(String nameFilter, boolean isChunked){ - manager.traceIn(); - List result = new ArrayList(); - if (isChunked == true) { - DefaultContext context = manager.getDbContext(); - try { - ResultSetIterImpl iter = null; - if (nameFilter != null) { - String filter = ("%" + nameFilter + "%").toUpperCase(); - iter = selectByName(context, filter); - } else { - iter = selectByModified(context); - } - checkNull(iter, ResultSetIterImpl.class); - result = getList(context, iter, isChunked); - } catch (Exception e) { - throw new ItemManagerException(e); - } finally { - manager.putDbContext(context); - } - } - manager.traceOut(); - return result; - } - -}/*@lineinfo:generated-code*/class SearchDefinitionDAO_SJProfileKeys -{ - private java.lang.Object[] keys; - private final sqlj.runtime.profile.Loader loader = sqlj.runtime.RuntimeContext.getRuntime().getLoaderForClass(getClass()); - private static SearchDefinitionDAO_SJProfileKeys inst = null; - public static java.lang.Object getKey(int keyNum) - throws java.sql.SQLException - { - synchronized(user.jobengine.db.SearchDefinitionDAO_SJProfileKeys.class) { - if (inst == null) - { - inst = new SearchDefinitionDAO_SJProfileKeys(); - } - } - return inst.keys[keyNum]; - } - private SearchDefinitionDAO_SJProfileKeys() - throws java.sql.SQLException - { - keys = new java.lang.Object[1]; - keys[0] = DefaultContext.getProfileKey(loader, "user.jobengine.db.SearchDefinitionDAO_SJProfile0"); - } -} diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/zk/model/SearchModel.java b/server/user.jobengine.osgi.server/src/user/jobengine/zk/model/SearchModel.java index 8ab91193..72461607 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/zk/model/SearchModel.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/zk/model/SearchModel.java @@ -46,10 +46,10 @@ public class SearchModel extends BaseModel { public void downloadMedia() { if (getHasTSMMediaFile()) { try { - Map parameters1 = new HashMap<>(); - parameters1.put("media", this.selectedMedia); + Map parameters = new HashMap<>(); + parameters.put("mediaCubeMedia", this.selectedMedia); IJobEngine jobEngine = JobEngine.getInstance(); - IJobRuntime runtime1 = jobEngine.submit("tsmrestore.xml", "TSMRestoreMedia", parameters1); + IJobRuntime runtime1 = jobEngine.submit("retrieve-material.xml", "TSMRestoreMedia", parameters); } catch (Exception exc) { logger.error("", exc); } @@ -135,7 +135,7 @@ public class SearchModel extends BaseModel { } return ret; } - + public boolean getHasSelectedMediaFile(){ String mediaFilePath =getMediaFilePath(); return (mediaFilePath != null && !"".equals(mediaFilePath)); -- 2.54.0