]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/slc/ria/SlcApi.js
move "source" to "argeo-ria-src"
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-src / class / org / argeo / slc / ria / SlcApi.js
diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/slc/ria/SlcApi.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/slc/ria/SlcApi.js
new file mode 100644 (file)
index 0000000..dd36325
--- /dev/null
@@ -0,0 +1,121 @@
+qx.Class.define("org.argeo.slc.ria.SlcApi",\r
+{\r
+  extend : qx.core.Object,\r
+  \r
+  statics : {\r
+       DEFAULT_CONTEXT : "/org.argeo.slc.webapp",\r
+       \r
+       REMOVE_RESULT_FROM_COLL_SERVICE : "removeResultFromCollection.service",\r
+       ADD_RESULT_TO_COLL_SERVICE : "addResultToCollection.service",\r
+       LIST_COLLECTIONS_SERVICE : "listCollectionRefs.service",\r
+       LIST_RESULTS_SERVICE : "listResultAttributes.service",\r
+       GET_RESULT_SERVICE : "getResult.service",\r
+       \r
+       /**\r
+        * Standard Request getter\r
+        * @param serviceName {String} The name of the service to call (without base context)\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}\r
+        */\r
+       getServiceRequest:function(serviceName, fireReloadEventType, iLoadStatusables){\r
+               var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();\r
+               return serviceManager.getRequest(\r
+                       org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+serviceName,\r
+                       "GET",\r
+                       "application/xml",\r
+                       fireReloadEventType,\r
+                       iLoadStatusables\r
+               );\r
+       },\r
+       \r
+       /**\r
+        * Remove a result from a collection\r
+        * @param collectionId {String} Id of the destination collection\r
+        * @param resultId {String} Id of the test result to remove\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}\r
+        */\r
+       getRemoveResultService : function(collectionId, resultId, 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
+               request.setParameter("resultUuid", resultId);\r
+               return request;\r
+       },\r
+       \r
+       /**\r
+        * Add a result to a given collection\r
+        * @param collectionId {String} Id of the destination collection\r
+        * @param resultId {String} Id of the test result to add\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}\r
+        */\r
+       getAddResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){\r
+               var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+                       org.argeo.slc.ria.SlcApi.ADD_RESULT_TO_COLL_SERVICE, \r
+                       fireReloadEventType, \r
+                       iLoadStatusables\r
+               );\r
+               request.setParameter("collectionId", collectionId);\r
+               request.setParameter("resultUuid", resultId);\r
+               return request;\r
+       },\r
+       \r
+       /**\r
+        * List current collections\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}\r
+        */\r
+       getListCollectionsService : function(fireReloadEventType, iLoadStatusables){\r
+               return org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+                       org.argeo.slc.ria.SlcApi.LIST_COLLECTIONS_SERVICE, \r
+                       fireReloadEventType, \r
+                       iLoadStatusables\r
+               );\r
+       },\r
+       \r
+       /**\r
+        * List all results or results of a given collection \r
+        * @param collectionId {String} Id of the collection to load\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}\r
+        */\r
+       getListResultsService : function(collectionId, fireReloadEventType, iLoadStatusables){\r
+               var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+                       org.argeo.slc.ria.SlcApi.LIST_RESULTS_SERVICE, \r
+                       fireReloadEventType, \r
+                       iLoadStatusables\r
+               );\r
+               if(collectionId){\r
+                       request.setParameter("id", collectionId);\r
+               }\r
+               return request;\r
+       },\r
+       \r
+       /**\r
+        * Load a result test\r
+        * @param resultId {String} Id of the test result to load\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}\r
+        */\r
+       getLoadResultService : function(resultId, fireReloadEventType, iLoadStatusables){\r
+               var request = org.argeo.slc.ria.SlcApi.getServiceRequest(\r
+                       org.argeo.slc.ria.SlcApi.GET_RESULT_SERVICE, \r
+                       fireReloadEventType, \r
+                       iLoadStatusables\r
+               );\r
+               request.setParameter("uuid", resultId);\r
+               return request;\r
+       }\r
+       \r
+  }\r
+});
\ No newline at end of file