From dafc3e7a2b587c675ff5f52a3df1a8001b947e2c Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1s=C3=A1ry=20D=C3=A1niel?= Date: Thu, 29 Mar 2018 22:24:26 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C31005 --- .../-configuration/mediacube-auth.properties | 2 +- .../jobtemplates/retrieve-ondemand.xml | 2 +- .../CopyForArchiveNEXIOMaterialsStep.java | 2 +- .../CopyForArchiveNEXIORecordingsStep.java | 15 ++- .../server/steps/ImportStatisticsStep.java | 48 +++++--- .../sql/update-itemtypes.sql | 7 ++ .../user/jobengine/db/IResultSetConsumer.java | 10 ++ .../jobengine/db/IStatementDecorator.java | 10 ++ .../test/user/jobengine/db/Support_new.java | 86 +++++++++++++- .../css/archivum.css | 6 +- .../img/ic_search_black_24dp_1x.png | Bin 0 -> 249 bytes .../img/ic_shopping_cart_black_24dp.png | Bin 0 -> 215 bytes .../pages/index.zul | 7 +- .../pages/joblist.zul | 2 +- .../user.jobengine.osgi.server/pages/menu.zul | 10 +- .../pages/retrievebatchselector.zul | 49 ++++++++ .../pages/searchitems.zul | 53 +++++---- .../resources/i3-label_hu.properties | 2 +- .../user/jobengine/zk/model/MenuModel.java | 74 ++++++++++-- .../zk/model/MissingMaterialsModel.java | 3 +- .../zk/model/RetrieveBatchSelectorModel.java | 107 ++++++++++++++++++ .../user/jobengine/zk/model/SearchModel.java | 72 ++++++++++++ .../user/jobengine/zk/util/SessionUtil.java | 48 +++++--- 23 files changed, 532 insertions(+), 83 deletions(-) create mode 100644 server/user.jobengine.osgi.db/sql/update-itemtypes.sql create mode 100644 server/user.jobengine.osgi.db/test/user/jobengine/db/IResultSetConsumer.java create mode 100644 server/user.jobengine.osgi.db/test/user/jobengine/db/IStatementDecorator.java create mode 100644 server/user.jobengine.osgi.server/img/ic_search_black_24dp_1x.png create mode 100644 server/user.jobengine.osgi.server/img/ic_shopping_cart_black_24dp.png create mode 100644 server/user.jobengine.osgi.server/pages/retrievebatchselector.zul create mode 100644 server/user.jobengine.osgi.server/src/user/jobengine/zk/model/RetrieveBatchSelectorModel.java diff --git a/server/-configuration/mediacube-auth.properties b/server/-configuration/mediacube-auth.properties index 1e070942..c7032743 100644 --- a/server/-configuration/mediacube-auth.properties +++ b/server/-configuration/mediacube-auth.properties @@ -5,5 +5,5 @@ ad_nonsecureport=3268 ad_base_dn=DC=intra,DC=echotv,DC=hu ad_admin_map=G_ECH_U_INFORMATIKUSOK,G_ECH_U_MUSZAKVEZETOK,ECH-ISILON-ADMINS local_users=user:password;kuka:kuka -local_admins=root:password +local_admins=root:password:vasary@elgekko.net local_jobsubmitters=lebony:lebony \ No newline at end of file diff --git a/server/user.jobengine.executors/jobtemplates/retrieve-ondemand.xml b/server/user.jobengine.executors/jobtemplates/retrieve-ondemand.xml index e3ded320..da99265b 100644 --- a/server/user.jobengine.executors/jobtemplates/retrieve-ondemand.xml +++ b/server/user.jobengine.executors/jobtemplates/retrieve-ondemand.xml @@ -1,5 +1,5 @@ - + diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java index 5f7eedbb..35bba94f 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIOMaterialsStep.java @@ -45,7 +45,7 @@ public class CopyForArchiveNEXIOMaterialsStep extends JobStep { private static final String LONGNAMEID = "longnameid"; private static final String ARCHIVEDRUNDOWNS = "archivedrundowns"; private static final String ID = "id"; - private static final String MEDIATYPE = "Octopus bejátszó"; + private static final String MEDIATYPE = "Hír bejátszó"; private OctopusAPI octopusAPI; private IItemManager manager; diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIORecordingsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIORecordingsStep.java index 3c71a2a4..043a098a 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIORecordingsStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/CopyForArchiveNEXIORecordingsStep.java @@ -8,6 +8,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.List; +import java.util.TimeZone; import org.apache.commons.lang.StringUtils; import org.apache.commons.net.ftp.FTP; @@ -176,7 +177,11 @@ public class CopyForArchiveNEXIORecordingsStep extends JobStep { logger.warn(systemMarker, "A '{}' fájl neve nem időbélyeggel kezdődik, ezért nem archiválható.", clipName); return null; } - return CalendarUtils.createCalendar(CalendarUtils.createCalendar(recordDate), timePart).getTime(); + Calendar dateCal = CalendarUtils.createCalendar(recordDate); + dateCal.setTimeZone(TimeZone.getTimeZone("Europe/Budapest")); + Calendar wholeCal = CalendarUtils.createCalendar(CalendarUtils.createCalendar(recordDate), timePart); + wholeCal.setTimeZone(TimeZone.getTimeZone("Europe/Budapest")); + return wholeCal.getTime(); } private String getTargetFileName(RundownArchive rundownArchive, String sourceFileName) { @@ -208,10 +213,10 @@ public class CopyForArchiveNEXIORecordingsStep extends JobStep { return null; } - if (clipName.startsWith("1900")) { - Calendar cal = CalendarUtils.createCalendar(scheduledStart); - cal.add(Calendar.MINUTE, 5); - rundown = octopusAPI.getRundown(cal.getTime()); + if (clipName.startsWith("1900_")) { + String clipNameNext = clipName.replace("1900_", "1905_"); + scheduledStart = getScheduledStart(clipNameNext, recordDate); + rundown = octopusAPI.getRundown(scheduledStart); if (rundown == null) { logger.error(systemMarker, "A '{}' anyaghoz nem található tükör '{}' kezdéssel, ezért nem archiválható.", clipName, scheduledStart); return null; diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/ImportStatisticsStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/ImportStatisticsStep.java index 4856bf15..ce863149 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/ImportStatisticsStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/ImportStatisticsStep.java @@ -189,17 +189,22 @@ public class ImportStatisticsStep extends JobStep { if (mosObjects == null || mosObjects.isEmpty()) continue; + boolean foundAnyClip = false; for (BasicDBObject mosObject : mosObjects) { String clipName = NoSQLUtils.asString(mosObject, IOctopusAPI.OBJ_ID); if (clipName != null && clipName.length() > 0) { BasicDBObject clip = (BasicDBObject) clipCollection.findOne(new BasicDBObject(LONGNAMEID, clipName)); if (clip != null) { long duration = NoSQLUtils.asLong(clip, DURATION); - if (duration > 0) + if (duration > 0) { mosObject.put("duration", duration); + foundAnyClip = true; + } } } } + if (!foundAnyClip) + continue; List rdList = NoSQLUtils.asList(story, IOctopusAPI.REF_RUNDOWN); story.put(IOctopusAPI.REF_RUNDOWN, rdList == null ? 0 : rdList.size()); @@ -226,20 +231,26 @@ public class ImportStatisticsStep extends JobStep { } private void store(Calendar scheduledDate, List stories, BasicDBObject typeStat, BasicDBObject planStat, BasicDBObject reporterStat) { - BasicDBObject dailyHistory = new BasicDBObject(); - dailyHistory.put("dateTime", scheduledDate.getTime()); - BasicDBList list = new BasicDBList(); - dailyHistory.put("rawData", list); - for (BasicDBObject story : stories) { - list.add(story); - } - dailyHistory.put("typeStat", typeStat); - dailyHistory.put("planStat", planStat); - dailyHistory.put("reporterStat", reporterStat); + try { + BasicDBObject dailyHistory = new BasicDBObject(); + dailyHistory.put("dateTime", scheduledDate.getTime()); + BasicDBList list = new BasicDBList(); + dailyHistory.put("rawData", list); + for (BasicDBObject story : stories) { + list.add(story); + } + dailyHistory.put("typeStat", typeStat); + dailyHistory.put("planStat", planStat); + dailyHistory.put("reporterStat", reporterStat); + + DBCollection collection = db.getCollection("daily_news_history"); + collection.remove(new BasicDBObject("dateTime", scheduledDate.getTime())); + collection.save(dailyHistory); - DBCollection collection = db.getCollection("daily_news_history"); - collection.remove(new BasicDBObject("dateTime", scheduledDate.getTime())); - collection.save(dailyHistory); + } catch (Exception e) { + logger.error(e); + throw e; + } } private void storeStories(Calendar scheduledDate, Map stories) { @@ -254,6 +265,9 @@ public class ImportStatisticsStep extends JobStep { List mosObjects = NoSQLUtils.asList(story, IOctopusAPI.MOS_OBJECTS); for (BasicDBObject mos : mosObjects) { String objId = NoSQLUtils.asString(mos, IOctopusAPI.OBJ_ID); + if (!mos.containsKey("duration")) + continue; + long parentStoryId = NoSQLUtils.asLong(story, IOctopusAPI.PARENT_STORY_ID); String key = String.format("%d-%s", parentStoryId, objId); if (processed.contains(key)) @@ -261,6 +275,12 @@ public class ImportStatisticsStep extends JobStep { processed.add(key); String label = NoSQLUtils.asString(mos, IOctopusAPI.LABEL); + if (label == null) { + logger.error(marker, "Az anyag MOS objektuma nem tartalmaz formátum meghatározást, feldolgozása nem lehetséges. Részletek:"); + logger.error(marker, "STORY: {}", story.toString()); + logger.error(marker, "MOS: {}", mos.toString()); + continue; + } long duration = NoSQLUtils.asLong(mos, "duration"); long rdCount = NoSQLUtils.asLong(story, IOctopusAPI.REF_RUNDOWN); long sfCount = NoSQLUtils.asLong(story, IOctopusAPI.REF_STORYFOLDER); diff --git a/server/user.jobengine.osgi.db/sql/update-itemtypes.sql b/server/user.jobengine.osgi.db/sql/update-itemtypes.sql new file mode 100644 index 00000000..c93fe78a --- /dev/null +++ b/server/user.jobengine.osgi.db/sql/update-itemtypes.sql @@ -0,0 +1,7 @@ +select * from itemtype +insert into itemtype (name, description, isstatic) values('Hír bejátszó','Hír bejátszó','N') + +update media set itemtypeid=(select id from itemtype where name='Visszarögzített') where ID in (select mediaid from vw_items where itemtitle like '%Echo TV%' and itemtitle like '2%' and mediatitle like '%PGM%') +update media set itemtypeid=(select id from itemtype where name='Hír bejátszó') where ID in (select mediaid from vw_items where itemtitle like '%Echo TV%' and itemtitle like '2%' and mediatitle not like '%CLN%' and mediatitle not like '%PGM%') + +select * from vw_items where itemtitle like '%Echo TV%' and itemtitle like '2%' and mediatitle not like '%CLN%' and mediatitle not like '%PGM%' \ No newline at end of file diff --git a/server/user.jobengine.osgi.db/test/user/jobengine/db/IResultSetConsumer.java b/server/user.jobengine.osgi.db/test/user/jobengine/db/IResultSetConsumer.java new file mode 100644 index 00000000..36d6fe5a --- /dev/null +++ b/server/user.jobengine.osgi.db/test/user/jobengine/db/IResultSetConsumer.java @@ -0,0 +1,10 @@ +package user.jobengine.db; + +import java.sql.ResultSet; +import java.sql.SQLException; + +public interface IResultSetConsumer { + + void process(ResultSet resultSet) throws SQLException; + +} diff --git a/server/user.jobengine.osgi.db/test/user/jobengine/db/IStatementDecorator.java b/server/user.jobengine.osgi.db/test/user/jobengine/db/IStatementDecorator.java new file mode 100644 index 00000000..91fb7ef3 --- /dev/null +++ b/server/user.jobengine.osgi.db/test/user/jobengine/db/IStatementDecorator.java @@ -0,0 +1,10 @@ +package user.jobengine.db; + +import java.sql.PreparedStatement; +import java.sql.SQLException; + +public interface IStatementDecorator { + + void decorate(PreparedStatement statement) throws SQLException; + +} diff --git a/server/user.jobengine.osgi.db/test/user/jobengine/db/Support_new.java b/server/user.jobengine.osgi.db/test/user/jobengine/db/Support_new.java index 2fc515ff..e9bb7350 100644 --- a/server/user.jobengine.osgi.db/test/user/jobengine/db/Support_new.java +++ b/server/user.jobengine.osgi.db/test/user/jobengine/db/Support_new.java @@ -1,5 +1,6 @@ package user.jobengine.db; +import java.io.File; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; @@ -42,6 +43,10 @@ public class Support_new { protected static IItemManager manager = null; + private static final String LOWRES_ROOT = "//10.10.1.27/mclowres/www/video"; + + private static final long[] duplicateLength = { 0 }; + @BeforeClass static public void setUpConnection() { System.setProperty("jobengine.nosql.db.url", "jdbc:db2://10.10.1.27:50000/mc:retrieveMessagesFromServerOnGetMessage=true;"); @@ -103,6 +108,41 @@ public class Support_new { } + private void executeQuery(String query, IResultSetConsumer consumer, IStatementDecorator decorator) { + ResultSet rs = null; + PreparedStatement st = null; + DefaultContext context = ((ItemManager) manager).getDbContext(); + Connection connection = context.getConnection(); + try { + st = connection.prepareStatement(query); + if (decorator != null) + decorator.decorate(st); + rs = st.executeQuery(); + while (rs.next()) { + consumer.process(rs); + } + + connection.commit(); + } catch (Exception e) { + try { + connection.rollback(); + } catch (Exception e1) { + } + } finally { + try { + if (rs != null) + rs.close(); + } catch (Exception e1) { + } + try { + if (st != null) + st.close(); + } catch (Exception e1) { + } + ((ItemManager) manager).putDbContext(context); + } + } + @Test public void generateMissingRecordingsList() throws Exception { // select itemtitle, mediafilehouseid from vw_items where itemtitle like '%Echo TV%' and itemtitle like '2%' and mediatitle like '%PGM%' order by itemtitle, mediafilehouseid @@ -129,7 +169,10 @@ public class Support_new { lines.add(key + ";" + recordings.get(key) + ";"); System.out.println(key + "\t" + recordings.get(key)); } - Files.write(Paths.get("c:\\temp\\recordings.csv"), lines, Charset.forName("UTF-8"), StandardOpenOption.CREATE_NEW); + Path out = Paths.get("c:\\temp\\recordings.csv"); + if (Files.exists(out)) + Files.delete(out); + Files.write(out, lines, Charset.forName("UTF-8"), StandardOpenOption.CREATE_NEW); } @@ -188,6 +231,47 @@ public class Support_new { return result; } + private void processLowresDuplicateGroup(String fileName) { + System.out.println("*** Processing: " + fileName); + String query = "select mediafileid, mediafilehouseid, relativepath from vw_items_rd_lh where filename = ?"; + IStatementDecorator decorator = st -> { + st.setString(1, fileName); + }; + + MediaFile[] masterMediaFile = { null }; + + IResultSetConsumer consumer = rs -> { + long mediaFileId = rs.getLong("mediafileid"); + MediaFile mediaFile = (MediaFile) manager.get(MediaFile.class, mediaFileId); + String mediaFileHouseId = rs.getString("mediafilehouseid"); + if (masterMediaFile[0] == null) { + masterMediaFile[0] = mediaFile; + System.out.println("Skipping: " + mediaFileHouseId); + return; + } + + String path = rs.getString("relativepath"); + // System.out.println("Inspecting: " + path + " filename " + fileName + " mediaFileHouseId " + mediaFileHouseId); + + File file = Paths.get(LOWRES_ROOT, path).toFile(); + duplicateLength[0] += file.length(); + System.out.println("Inspecting: " + mediaFileHouseId + " now available " + duplicateLength[0]); + + }; + executeQuery(query, consumer, decorator); + } + + @Test + public void processLowresDuplicates() { + String query = "select filename from vw_items_rd_dup order by filecount"; + IResultSetConsumer consumer = rs -> { + String fileName = rs.getString("filename"); + processLowresDuplicateGroup(fileName); + }; + executeQuery(query, consumer, null); + System.out.println("Available will " + duplicateLength[0]); + } + private List query(Connection con) throws Exception { List result = new ArrayList<>(); diff --git a/server/user.jobengine.osgi.server/css/archivum.css b/server/user.jobengine.osgi.server/css/archivum.css index 05bd90b8..695d8905 100644 --- a/server/user.jobengine.osgi.server/css/archivum.css +++ b/server/user.jobengine.osgi.server/css/archivum.css @@ -82,7 +82,7 @@ body *:not([class*="z-icon-"]) { } .listbox-odd-style{ - background: #ebebeb; + background: white; } .attributedeflistbox .z-listcell-content { @@ -120,7 +120,7 @@ body *:not([class*="z-icon-"]) { } .z-row .z-row-inner, .z-row .z-cell { - border-left: 0px; + border: 0px; } .z-east-splitter, .z-west-splitter, .z-north-splitter, .z-south-splitter{ @@ -154,7 +154,7 @@ body *:not([class*="z-icon-"]) { .listbox-normal-style .z-listitem .z-listcell { border-left: 1px solid gray; - border-bottom: 1px solid gray; + border-bottom: 1px solid blue; } .z-treerow, .z-tree-body{ diff --git a/server/user.jobengine.osgi.server/img/ic_search_black_24dp_1x.png b/server/user.jobengine.osgi.server/img/ic_search_black_24dp_1x.png new file mode 100644 index 0000000000000000000000000000000000000000..6b16343235c2729720113158598c891fd041949f GIT binary patch literal 249 zcmV|r4fyyw@M>+ir$LGPVo;#@wk2g)LvA~nWu7_00000NkvXXu0mjfU?OPG literal 0 HcmV?d00001 diff --git a/server/user.jobengine.osgi.server/img/ic_shopping_cart_black_24dp.png b/server/user.jobengine.osgi.server/img/ic_shopping_cart_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..f56585b31aa8da3422d49a53c35318c956f445c9 GIT binary patch literal 215 zcmV;|04V>7P) -
+
@@ -68,7 +68,10 @@
-
diff --git a/server/user.jobengine.osgi.server/pages/retrievebatchselector.zul b/server/user.jobengine.osgi.server/pages/retrievebatchselector.zul new file mode 100644 index 00000000..98045733 --- /dev/null +++ b/server/user.jobengine.osgi.server/pages/retrievebatchselector.zul @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +