git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Mon, 13 Nov 2017 17:10:13 +0000 (17:10 +0000)
committerVásáry Dániel <daniel.vasary@userrendszerhaz.hu>
Mon, 13 Nov 2017 17:10:13 +0000 (17:10 +0000)
server/user.jobengine.osgi.commons/src/user/commons/octopus/IOctopusAPI.java
server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusAPI.java
server/user.jobengine.osgi.commons/src/user/commons/octopus/OctopusDataMiner.java
server/user.jobengine.osgi.server/pages/index.zul
server/user.jobengine.osgi.server/src/user/jobengine/server/JobEngine.java
server/user.jobengine.osgi.services/src/user/jobengine/osgi/rest/octopus/OctopusRESTService.java

index 542b8b59620d93850da8729967f5db19a4ee7f87..038a8783fcbe2115ddaafc145b94ab7ac2ab1943 100644 (file)
@@ -7,27 +7,29 @@ import com.ibm.nosql.json.api.DBObject;
 \r
 public interface IOctopusAPI {\r
 \r
+       List<DBObject> getMosObjectsByID(String id);\r
+\r
+       List<DBObject> getRundownByStoryID(long storyID);\r
+\r
        List<DBObject> getRundowns(Date scheduledDate);\r
 \r
+       List<DBObject> getRundownsByPlaceHolderId(String placeHolderID);\r
+\r
+       List<DBObject> getStories();\r
+\r
        List<DBObject> getStories(long rundownID);\r
-       \r
+\r
+       List<DBObject> getStoriesByID(String id);\r
+\r
+       List<DBObject> getStoriesByParentStoryID(String id);\r
+\r
+       List<DBObject> getStoriesByPlaceHolderId(String placeHolderID);\r
+\r
        List<DBObject> getStoriesByStoryFolderId(long storyFolderID);\r
 \r
        List<DBObject> getStoryFolders();\r
 \r
        List<DBObject> getStoryFolders(long storyID);\r
 \r
-       List<DBObject> getRundownByStoryID(long storyID);\r
-\r
-       List<DBObject> getRundownsByPlaceHolderId(String placeHolderID);\r
-\r
        List<DBObject> getStoryFoldersByPlaceHolderId(String placeHolderID);\r
-       \r
-       List<DBObject> getStoriesByPlaceHolderId(String placeHolderID);\r
-       \r
-       List<DBObject> getStories();\r
-       \r
-       List<DBObject> getStoriesByIDRegex(String id);\r
-       \r
-       List<DBObject> getMosObjectsByID(String id);\r
 }\r
index 44f69bf9ab58a7f705a93e434b59a2a98dac6a5b..2b57a447b9a53ae131a179ded88a99343eac01f7 100644 (file)
@@ -5,7 +5,6 @@ import java.util.ArrayList;
 import java.util.Calendar;\r
 import java.util.Date;\r
 import java.util.List;\r
-import java.util.regex.Pattern;\r
 \r
 import org.apache.logging.log4j.LogManager;\r
 import org.apache.logging.log4j.Logger;\r
@@ -130,9 +129,9 @@ public class OctopusAPI implements IOctopusAPI {
                DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME);\r
                DBCollection rundownCollection = db.getCollection(RUNDOWN_COLLECTION_NAME);\r
                List<DBObject> queryedRundownsFromStoryCollection = null;\r
-               BasicDBObject id = new BasicDBObject("id", placeHolderID);\r
+               BasicDBObject id = new BasicDBObject("objId", placeHolderID);\r
                BasicDBObject elemmatch = new BasicDBObject("$elemMatch", id);\r
-               BasicDBObject mosObjects = new BasicDBObject("mosObjects", elemmatch);\r
+               BasicDBObject mosObjects = new BasicDBObject(MOS_OBJECTS, elemmatch);\r
                //db.testStoryCollection.find({"mosObjects": {$elemMatch: {"globalId": "OCTOPUS-ECHOTV-2429902"}}})\r
                DBCursor find = storyCollection.find(mosObjects);\r
                result = getParentsByReferences(find, rundownCollection, queryedRundownsFromStoryCollection, RUNDOWN);\r
@@ -157,8 +156,8 @@ public class OctopusAPI implements IOctopusAPI {
 \r
                // { rundown: { $elemMatch: { id: 44622396 } }}\r
                DBCursor find = collection\r
-                               .find(new BasicDBObject(RUNDOWN, new BasicDBObject("$elemMatch", new BasicDBObject(ID, rundownID))),\r
-                                               new BasicDBObject(ID, 1).append("name", 1).append("modified", 1).append(RUNDOWN, 1).append("format", 1).append("mosObjects", 1))\r
+                               .find(new BasicDBObject(RUNDOWN, new BasicDBObject("$elemMatch", new BasicDBObject(ID, rundownID))), new BasicDBObject(ID, 1)\r
+                                               .append("parentStoryId", 1).append("name", 1).append("modified", 1).append(RUNDOWN, 1).append("format", 1).append("mosObjects", 1))\r
                                .sort(new BasicDBObject("name", 1));\r
                if (find.hasNext())\r
                        result = find.toArray();\r
@@ -166,14 +165,24 @@ public class OctopusAPI implements IOctopusAPI {
        }\r
 \r
        @Override\r
-       public List<DBObject> getStoriesByIDRegex(String id) {\r
+       public List<DBObject> getStoriesByID(String id) {\r
                List<DBObject> result = null;\r
                DBCollection collection = db.getCollection(STORY_COLLECTION_NAME);\r
-               Pattern regex = Pattern.compile(id, Pattern.CASE_INSENSITIVE);\r
-               /*BasicDBObject query = new BasicDBObject("id", new BasicDBObject("$regex", id));*/\r
-               BasicDBObject query = new BasicDBObject("id", Pattern.compile(id));\r
-               logger.info(query);\r
-               DBCursor find = collection.find(query);\r
+               //Pattern regex = Pattern.compile(id, Pattern.CASE_INSENSITIVE);\r
+               //BasicDBObject query = new BasicDBObject("id", Pattern.compile(id));\r
+               DBCursor find = collection.find(new BasicDBObject("id", id));\r
+               if (find.hasNext())\r
+                       result = find.toArray();\r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public List<DBObject> getStoriesByParentStoryID(String id) {\r
+               List<DBObject> result = null;\r
+               DBCollection collection = db.getCollection(STORY_COLLECTION_NAME);\r
+               //Pattern regex = Pattern.compile(id, Pattern.CASE_INSENSITIVE);\r
+               //BasicDBObject query = new BasicDBObject("id", Pattern.compile(id));\r
+               DBCursor find = collection.find(new BasicDBObject("parentStoryId", id));\r
                if (find.hasNext())\r
                        result = find.toArray();\r
                return result;\r
@@ -183,11 +192,9 @@ public class OctopusAPI implements IOctopusAPI {
        public List<DBObject> getStoriesByPlaceHolderId(String placeHolderID) {\r
                List<DBObject> result = new ArrayList<>();\r
                DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME);\r
-               DBCollection rundownCollection = db.getCollection(RUNDOWN_COLLECTION_NAME);\r
-               BasicDBObject globalId = new BasicDBObject("id", placeHolderID);\r
+               BasicDBObject globalId = new BasicDBObject("objId", placeHolderID);\r
                BasicDBObject elemmatch = new BasicDBObject("$elemMatch", globalId);\r
-               BasicDBObject mosObjects = new BasicDBObject("mosObjects", elemmatch);\r
-\r
+               BasicDBObject mosObjects = new BasicDBObject(MOS_OBJECTS, elemmatch);\r
                DBCursor find = storyCollection.find(mosObjects);\r
                if (find.hasNext())\r
                        result.add(find.next());\r
@@ -199,8 +206,8 @@ public class OctopusAPI implements IOctopusAPI {
                List<DBObject> result = null;\r
                DBCollection collection = db.getCollection(STORY_COLLECTION_NAME);\r
                DBCursor find = collection\r
-                               .find(new BasicDBObject(STORY_FOLDER, new BasicDBObject("$elemMatch", new BasicDBObject(ID, storyFolderId))),\r
-                                               new BasicDBObject(ID, 1).append("name", 1).append("modified", 1).append(STORY_FOLDER, 1).append("format", 1).append("mosObjects", 1))\r
+                               .find(new BasicDBObject(STORY_FOLDER, new BasicDBObject("$elemMatch", new BasicDBObject(ID, storyFolderId))), new BasicDBObject(ID, 1)\r
+                                               .append("parentStoryId", 1).append("name", 1).append("modified", 1).append(STORY_FOLDER, 1).append("format", 1).append("mosObjects", 1))\r
                                .sort(new BasicDBObject("name", 1));\r
                if (find.hasNext())\r
                        result = find.toArray();\r
@@ -234,7 +241,7 @@ public class OctopusAPI implements IOctopusAPI {
                DBCollection storyCollection = db.getCollection(STORY_COLLECTION_NAME);\r
                DBCollection rundownCollection = db.getCollection(STORY_FOLDER_COLLECTION_NAME);\r
                List<DBObject> queryedRundownsFromStoryCollection = null;\r
-               BasicDBObject globalId = new BasicDBObject("id", placeHolderID);\r
+               BasicDBObject globalId = new BasicDBObject("objId", placeHolderID);\r
                BasicDBObject elemmatch = new BasicDBObject("$elemMatch", globalId);\r
                BasicDBObject mosObjects = new BasicDBObject("mosObjects", elemmatch);\r
                DBCursor find = storyCollection.find(mosObjects, new BasicDBObject(STORY_FOLDER, 1).append("_id", 0));\r
index 85478e7c7307876e21b44135bc48934b91dbb7f1..844f5e6875ac6ddef5f0cf643a7bb7682c706f1c 100644 (file)
@@ -34,6 +34,9 @@ import user.commons.remotestore.IProgressEventListener;
 import user.commons.remotestore.ProgressEvent;\r
 \r
 public class OctopusDataMiner implements Runnable {\r
+       private static final String PARENT_STORY_ID = "parentStoryId";\r
+       private static final String VALUE = "value";\r
+       private static final String CUSTOM_COLUMNS = "customColumns";\r
        private static final String MOS_ID = "mosId";\r
        private static final String MOS_OBJECTS = "mosObjects";\r
        private static final String NAME = "name";\r
@@ -311,6 +314,25 @@ public class OctopusDataMiner implements Runnable {
        //              return result <= 0;\r
        //      }\r
 \r
+       private String GetCustomColumnValue(String columnName, BasicDBObject story) {\r
+               String result = null;\r
+               List<BasicDBObject> customColumns = NoSQLUtils.asList(asDBList(story, CUSTOM_COLUMNS));\r
+               for (BasicDBObject customColumn : customColumns) {\r
+                       if (!customColumn.containsKey(LABEL))\r
+                               continue;\r
+                       String currentName = customColumn.getString(LABEL);\r
+                       if (currentName == null)\r
+                               continue;\r
+                       if (!currentName.toLowerCase().equals(columnName.toLowerCase()))\r
+                               continue;\r
+                       if (!customColumn.containsKey(VALUE))\r
+                               continue;\r
+                       result = customColumn.getString(VALUE);\r
+                       break;\r
+               }\r
+               return result;\r
+       }\r
+\r
        private Date getLastUpdateTime() {\r
                Date result = null;\r
                DBCollection collection = db.getCollection(TIME_COLLECTION_NAME);\r
@@ -475,16 +497,6 @@ public class OctopusDataMiner implements Runnable {
                logger.trace(FINISHED);\r
        }\r
 \r
-       public void setLastUpdateTime(Date lastUpdateTime) {\r
-               DBCollection collection = db.getCollection(OctopusAPI.TIME_COLLECTION_NAME);\r
-               DBObject timeObject = collection.findOne();\r
-               if (timeObject == null)\r
-                       timeObject = new BasicDBObject();\r
-               timeObject.put(LASTUPDATE_TIME, lastUpdateTime);\r
-\r
-               collection.save(timeObject);\r
-       }\r
-\r
        // private void insertStoryFoldersToDB2() {\r
        // DBCollection collection = db.getCollection(STORY_FOLDER_COLLECTION_NAME);\r
        // Set<String> storyKeys = storyFolders.keySet();\r
@@ -554,6 +566,16 @@ public class OctopusDataMiner implements Runnable {
        // storyFolders = converter.convertBasicDBObjectFromJson(result);\r
        // }\r
 \r
+       public void setLastUpdateTime(Date lastUpdateTime) {\r
+               DBCollection collection = db.getCollection(OctopusAPI.TIME_COLLECTION_NAME);\r
+               DBObject timeObject = collection.findOne();\r
+               if (timeObject == null)\r
+                       timeObject = new BasicDBObject();\r
+               timeObject.put(LASTUPDATE_TIME, lastUpdateTime);\r
+\r
+               collection.save(timeObject);\r
+       }\r
+\r
        private void storeRundown(BasicDBObject rundown, Date lastUpdateTime) {\r
                logger.trace(ENTER);\r
                long rundownID = rundown.getLong(ID);\r
@@ -647,6 +669,12 @@ public class OctopusDataMiner implements Runnable {
                                story.remove(MOS_OBJECTS);\r
                } else\r
                        story.put(MOS_OBJECTS, modifiedMOS);\r
+\r
+               String parentSoryId = GetCustomColumnValue(PARENT_STORY_ID, story);\r
+               if (parentSoryId == null)\r
+                       story.append(PARENT_STORY_ID, storyID);\r
+               else\r
+                       story.append(PARENT_STORY_ID, parentSoryId);\r
                logger.debug(SAVING_STORY_ID, storyID);\r
                collection.save(story);\r
                logger.trace(EXIT);\r
index 951f430bc94de8197bae44e4237ef0aa2611ab2a..66adf1930a63af35be6a11af75a3cc7fc90538c2 100644 (file)
@@ -57,7 +57,7 @@
                                                                <image src="/img/mediacube_logo_v2_50x50.png">\r
 <!--                                                           <custom-attributes org.zkoss.zul.image.preload="true" /> -->\r
                                                                </image>\r
-                                                               <label style="color:#e3e3e3;font-size:20px;font-weight:bold">MediaCube v2.1.2</label>\r
+                                                               <label style="color:#e3e3e3;font-size:20px;font-weight:bold">MediaCube v2.1.3</label>\r
                                                        </div>\r
                                                </west>\r
                                                <center border="0">\r
index 047cb7cc98fe446bf8f6084ecdb07eef4cbd2be7..e2ee6cf23f9723c1d0913740b78e47fd3b94c85d 100644 (file)
@@ -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);
                }
index 3d04d264a43a1b91e58a5037337b2d80fa88ae35..5b1877546a224408492e93111a7e5f566c10a55b 100644 (file)
@@ -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<DBObject> stories = octopusService.getStoriesByIDRegex(id);
+                       List<DBObject> 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<DBObject> stories = octopusService.getStoriesByParentStoryID(id);
                        result = Response.ok(stories).build();
                } catch (Exception e) {
                        result = createErrorResponse(e);