]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js
Fetch Spec & Flow values
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-lib / slc / class / org / argeo / slc / ria / SlcApi.js
index dd3632594d06764bdf2e59347af0026ec40c30cb..687ae6acd5a5ed56a1f9b1492c0b031512dfff87 100644 (file)
@@ -1,3 +1,12 @@
+/**\r
+ * SLC API Client implementation :\r
+ * This class encapsulate the various SLC services available. It just creates the Request object\r
+ * and return them, it does not execute them. \r
+ * Available services are : \r
+ * + loadResult / removeResult / addResult\r
+ * + listCollection / listResults\r
+ * When using it, be sure the static constant DEFAULT_CONTEXT is pointing to the right URL.\r
+ */\r
 qx.Class.define("org.argeo.slc.ria.SlcApi",\r
 {\r
   extend : qx.core.Object,\r
@@ -8,8 +17,13 @@ qx.Class.define("org.argeo.slc.ria.SlcApi",
        REMOVE_RESULT_FROM_COLL_SERVICE : "removeResultFromCollection.service",\r
        ADD_RESULT_TO_COLL_SERVICE : "addResultToCollection.service",\r
        LIST_COLLECTIONS_SERVICE : "listCollectionRefs.service",\r
+       COPY_COLLECTION_TO_COLL_SERVICE : "copyCollectionToCollection.service",\r
        LIST_RESULTS_SERVICE : "listResultAttributes.service",\r
        GET_RESULT_SERVICE : "getResult.service",\r
+       LIST_SLCEXEC_SERVICE : "listSlcExecutions.service",\r
+       \r
+       LIST_AGENTS_SERVICE : "listAgents.service",     \r
+       AMQ_SERVICE : "amq",\r
        \r
        /**\r
         * Standard Request getter\r
@@ -48,6 +62,29 @@ qx.Class.define("org.argeo.slc.ria.SlcApi",
                return request;\r
        },\r
        \r
+       /**\r
+        * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.\r
+        * @param collectionId {String} The id of the collection\r
+        * @param patternAttribute {String} An optional attribute name on which to filter\r
+        * @param patternValue {String} The pattern to use for filtering a subset of result\r
+        * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
+        * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
+        * @return {qx.io.remote.Request} The Request object\r
+        */\r
+       getRemoveFromCollectionService : function(collectionId, patternAttribute, patternValue, fireReloadEventType, iLoadStatusables){\r
+               var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+                       org.argeo.slc.ria.SlcApi.REMOVE_RESULT_FROM_COLL_SERVICE, \r
+                       fireReloadEventType, \r
+                       iLoadStatusables\r
+               );\r
+               request.setParameter("collectionId", collectionId);\r
+               if(patternAttribute && patternValue){\r
+                       request.setParameter("attrName", patternAttribute);\r
+                       request.setParameter("attrPattern", patternValue);\r
+               }\r
+               return request;\r
+       },\r
+       \r
        /**\r
         * Add a result to a given collection\r
         * @param collectionId {String} Id of the destination collection\r
@@ -81,6 +118,31 @@ qx.Class.define("org.argeo.slc.ria.SlcApi",
                );\r
        },\r
        \r
+       /**\r
+        * Copy a whole collection or a subset of it to another collection. If a new id is provided for the target, it will be created.\r
+        * @param sourceCollectionId {String} The current collection from which to copy\r
+        * @param targetCollectionId {String} The target collection. If unknown, it will be created.\r
+        * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.\r
+        * @param patternValue {String} The associated pattern to filter on the atttribute's value.\r
+        * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent\r
+        * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
+        * @return {qx.io.remote.Request} The request object\r
+        */\r
+       getCopyCollectionService : function(sourceCollectionId, targetCollectionId, patternAttribute, patternValue, fireReloadEventType, iLoadStatusables){\r
+               var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+                       org.argeo.slc.ria.SlcApi.COPY_COLLECTION_TO_COLL_SERVICE, \r
+                       fireReloadEventType, \r
+                       iLoadStatusables                        \r
+               );\r
+               request.setParameter("sourceCollectionId", sourceCollectionId);\r
+               request.setParameter("targetCollectionId", targetCollectionId);\r
+               if(patternAttribute && patternValue){\r
+                       request.setParameter("attrName", patternAttribute);\r
+                       request.setParameter("attrPattern", patternValue);\r
+               }\r
+               return request;\r
+       },\r
+       \r
        /**\r
         * List all results or results of a given collection \r
         * @param collectionId {String} Id of the collection to load\r
@@ -115,6 +177,56 @@ qx.Class.define("org.argeo.slc.ria.SlcApi",
                );\r
                request.setParameter("uuid", resultId);\r
                return request;\r
+       },\r
+\r
+       /**\r
+        * List currently registered SlcExecutions.\r
+        * @param fireReloadEventType {String} Event type to trigger (optionnal)\r
+        * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update \r
+        * @return {qx.io.remote.Request}\r
+        */\r
+       getListSlcExecutionsService:function(fireReloadEventType, iLoadStatusables){\r
+               return org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+                       org.argeo.slc.ria.SlcApi.LIST_SLCEXEC_SERVICE,\r
+                       fireReloadEventType,\r
+                       iLoadStatusables\r
+               );\r
+       },\r
+       \r
+       \r
+       /**\r
+        * List currently available agents queues.\r
+        * @param fireReloadEventType {String} Event type to trigger (optionnal)\r
+        * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update \r
+        * @return {qx.io.remote.Request}\r
+        */\r
+       getListAgentsService:function(fireReloadEventType, iLoadStatusables){\r
+               return org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+                       org.argeo.slc.ria.SlcApi.LIST_AGENTS_SERVICE,\r
+                       fireReloadEventType,\r
+                       iLoadStatusables\r
+               );\r
+       },\r
+       \r
+       /**\r
+        * Send a JMS message to the AMQ_CONTEXT\r
+        * @param destination {String} The destination queue, in the form "topic://destination" \r
+        * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object\r
+        * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update\r
+        */\r
+       getSendAmqMessageRequest : function(destination, message, iLoadStatusables){\r
+               var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();\r
+               var request = serviceManager.getRequest(\r
+                       org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+org.argeo.slc.ria.SlcApi.AMQ_SERVICE,\r
+                       "POST",\r
+                       "text/plain",\r
+                       null,\r
+                       iLoadStatusables\r
+               );\r
+               request.setParameter("destination", destination);\r
+               request.setParameter("message", message.toXml());\r
+               request.setParameter("type", "send");\r
+               return request;\r
        }\r
        \r
   }\r