From: Vásáry Dániel Date: Mon, 13 Nov 2017 17:10:13 +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=0c9196ba2f23d6bd6fa15850f83b7e8e6f6adc8d;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30724 --- 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 542b8b59..038a8783 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 @@ -7,27 +7,29 @@ import com.ibm.nosql.json.api.DBObject; public interface IOctopusAPI { + List getMosObjectsByID(String id); + + List getRundownByStoryID(long storyID); + List getRundowns(Date scheduledDate); + List getRundownsByPlaceHolderId(String placeHolderID); + + List getStories(); + List getStories(long rundownID); - + + List getStoriesByID(String id); + + List getStoriesByParentStoryID(String id); + + List getStoriesByPlaceHolderId(String placeHolderID); + List getStoriesByStoryFolderId(long storyFolderID); List getStoryFolders(); List getStoryFolders(long storyID); - List getRundownByStoryID(long storyID); - - List getRundownsByPlaceHolderId(String placeHolderID); - List getStoryFoldersByPlaceHolderId(String placeHolderID); - - List getStoriesByPlaceHolderId(String placeHolderID); - - List getStories(); - - List getStoriesByIDRegex(String id); - - List getMosObjectsByID(String id); } 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 44f69bf9..2b57a447 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 @@ -5,7 +5,6 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; -import java.util.regex.Pattern; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -130,9 +129,9 @@ public class OctopusAPI implements IOctopusAPI { DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); DBCollection rundownCollection = db.getCollection(RUNDOWN_COLLECTION_NAME); List queryedRundownsFromStoryCollection = null; - BasicDBObject id = new BasicDBObject("id", placeHolderID); + BasicDBObject id = new BasicDBObject("objId", placeHolderID); BasicDBObject elemmatch = new BasicDBObject("$elemMatch", id); - BasicDBObject mosObjects = new BasicDBObject("mosObjects", elemmatch); + BasicDBObject mosObjects = new BasicDBObject(MOS_OBJECTS, elemmatch); //db.testStoryCollection.find({"mosObjects": {$elemMatch: {"globalId": "OCTOPUS-ECHOTV-2429902"}}}) DBCursor find = storyCollection.find(mosObjects); result = getParentsByReferences(find, rundownCollection, queryedRundownsFromStoryCollection, RUNDOWN); @@ -157,8 +156,8 @@ public class OctopusAPI implements IOctopusAPI { // { rundown: { $elemMatch: { id: 44622396 } }} DBCursor find = collection - .find(new BasicDBObject(RUNDOWN, new BasicDBObject("$elemMatch", new BasicDBObject(ID, rundownID))), - new BasicDBObject(ID, 1).append("name", 1).append("modified", 1).append(RUNDOWN, 1).append("format", 1).append("mosObjects", 1)) + .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)); if (find.hasNext()) result = find.toArray(); @@ -166,14 +165,24 @@ public class OctopusAPI implements IOctopusAPI { } @Override - public List getStoriesByIDRegex(String id) { + 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", new BasicDBObject("$regex", id));*/ - BasicDBObject query = new BasicDBObject("id", Pattern.compile(id)); - logger.info(query); - DBCursor find = collection.find(query); + //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()) + result = find.toArray(); + 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()) result = find.toArray(); return result; @@ -183,11 +192,9 @@ public class OctopusAPI implements IOctopusAPI { public List getStoriesByPlaceHolderId(String placeHolderID) { List result = new ArrayList<>(); DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); - DBCollection rundownCollection = db.getCollection(RUNDOWN_COLLECTION_NAME); - BasicDBObject globalId = new BasicDBObject("id", placeHolderID); + BasicDBObject globalId = new BasicDBObject("objId", placeHolderID); BasicDBObject elemmatch = new BasicDBObject("$elemMatch", globalId); - BasicDBObject mosObjects = new BasicDBObject("mosObjects", elemmatch); - + BasicDBObject mosObjects = new BasicDBObject(MOS_OBJECTS, elemmatch); DBCursor find = storyCollection.find(mosObjects); if (find.hasNext()) result.add(find.next()); @@ -199,8 +206,8 @@ public class OctopusAPI implements IOctopusAPI { 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("name", 1).append("modified", 1).append(STORY_FOLDER, 1).append("format", 1).append("mosObjects", 1)) + .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()) result = find.toArray(); @@ -234,7 +241,7 @@ public class OctopusAPI implements IOctopusAPI { DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME); DBCollection rundownCollection = db.getCollection(STORY_FOLDER_COLLECTION_NAME); List queryedRundownsFromStoryCollection = null; - BasicDBObject globalId = new BasicDBObject("id", placeHolderID); + BasicDBObject globalId = new BasicDBObject("objId", placeHolderID); BasicDBObject elemmatch = new BasicDBObject("$elemMatch", globalId); BasicDBObject mosObjects = new BasicDBObject("mosObjects", elemmatch); DBCursor find = storyCollection.find(mosObjects, new BasicDBObject(STORY_FOLDER, 1).append("_id", 0)); 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 85478e7c..844f5e68 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,6 +34,9 @@ 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"; @@ -311,6 +314,25 @@ public class OctopusDataMiner implements Runnable { // return result <= 0; // } + private String GetCustomColumnValue(String columnName, BasicDBObject story) { + String result = null; + List customColumns = NoSQLUtils.asList(asDBList(story, CUSTOM_COLUMNS)); + for (BasicDBObject customColumn : customColumns) { + if (!customColumn.containsKey(LABEL)) + continue; + String currentName = customColumn.getString(LABEL); + if (currentName == null) + continue; + if (!currentName.toLowerCase().equals(columnName.toLowerCase())) + continue; + if (!customColumn.containsKey(VALUE)) + continue; + result = customColumn.getString(VALUE); + break; + } + return result; + } + private Date getLastUpdateTime() { Date result = null; DBCollection collection = db.getCollection(TIME_COLLECTION_NAME); @@ -475,16 +497,6 @@ public class OctopusDataMiner implements Runnable { logger.trace(FINISHED); } - public void setLastUpdateTime(Date lastUpdateTime) { - DBCollection collection = db.getCollection(OctopusAPI.TIME_COLLECTION_NAME); - DBObject timeObject = collection.findOne(); - if (timeObject == null) - timeObject = new BasicDBObject(); - timeObject.put(LASTUPDATE_TIME, lastUpdateTime); - - collection.save(timeObject); - } - // private void insertStoryFoldersToDB2() { // DBCollection collection = db.getCollection(STORY_FOLDER_COLLECTION_NAME); // Set storyKeys = storyFolders.keySet(); @@ -554,6 +566,16 @@ public class OctopusDataMiner implements Runnable { // storyFolders = converter.convertBasicDBObjectFromJson(result); // } + public void setLastUpdateTime(Date lastUpdateTime) { + DBCollection collection = db.getCollection(OctopusAPI.TIME_COLLECTION_NAME); + DBObject timeObject = collection.findOne(); + if (timeObject == null) + timeObject = new BasicDBObject(); + timeObject.put(LASTUPDATE_TIME, lastUpdateTime); + + collection.save(timeObject); + } + private void storeRundown(BasicDBObject rundown, Date lastUpdateTime) { logger.trace(ENTER); long rundownID = rundown.getLong(ID); @@ -647,6 +669,12 @@ public class OctopusDataMiner implements Runnable { story.remove(MOS_OBJECTS); } else story.put(MOS_OBJECTS, modifiedMOS); + + String parentSoryId = GetCustomColumnValue(PARENT_STORY_ID, story); + if (parentSoryId == null) + story.append(PARENT_STORY_ID, storyID); + else + story.append(PARENT_STORY_ID, parentSoryId); logger.debug(SAVING_STORY_ID, storyID); collection.save(story); logger.trace(EXIT); diff --git a/server/user.jobengine.osgi.server/pages/index.zul b/server/user.jobengine.osgi.server/pages/index.zul index 951f430b..66adf193 100644 --- a/server/user.jobengine.osgi.server/pages/index.zul +++ b/server/user.jobengine.osgi.server/pages/index.zul @@ -57,7 +57,7 @@ - +
diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java index 047cb7cc..e2ee6cf2 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java @@ -45,6 +45,8 @@ import user.jobengine.server.messages.JobStepCompletedMessage; import user.jobengine.server.messages.UserReplyMessage; import user.jobengine.server.scheduler.SchedulerService; import user.jobengine.server.steps.IJobStep; +import user.tsm.client.TSMClient; +import user.tsm.client.TSMException; /** * MAM motor implementáció. @@ -718,6 +720,13 @@ public class JobEngine implements IJobEngine { worker.shutDown(); dispatcher.shutDown(); shutdownExecutors(); + + try { + TSMClient.CleanUpMultithread(); + } catch (TSMException e) { + logger.catching(e); + } + logger.info("JobEngine stopped"); } @@ -741,6 +750,7 @@ public class JobEngine implements IJobEngine { schedulerService = new SchedulerService(this); schedulerService.statrtup(); bootstrap(); + TSMClient.SetUpMultithread(); } catch (Exception e) { logger.error(e); } 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 3d04d264..5b187754 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 @@ -151,14 +151,31 @@ public class OctopusRESTService { } @GET - @Path("/getStoriesByIDRegex/{id}") + @Path("/getStoriesByID/{id}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public Response getStoriesByIDRegex(@PathParam("id") String id) { + public Response getStoriesByID(@PathParam("id") String id) { logger.trace("Entry"); Response result = null; try { - List stories = octopusService.getStoriesByIDRegex(id); + List stories = octopusService.getStoriesByID(id); + result = Response.ok(stories).build(); + } catch (Exception e) { + result = createErrorResponse(e); + } + logger.trace("Exit"); + return result; + } + + @GET + @Path("/getStoriesByParentStoryID/{id}") + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + public Response getStoriesByParentStoryID(@PathParam("id") String id) { + logger.trace("Entry"); + Response result = null; + try { + List stories = octopusService.getStoriesByParentStoryID(id); result = Response.ok(stories).build(); } catch (Exception e) { result = createErrorResponse(e);