2 * SLC API Client implementation :
3 * This class encapsulate the various SLC services available. It just creates the Request object
4 * and return them, it does not execute them.
5 * Available services are :
6 * + loadResult / removeResult / addResult
7 * + listCollection / listResults
8 * When using it, be sure the static constant DEFAULT_CONTEXT is pointing to the right URL.
10 qx
.Class
.define("org.argeo.slc.ria.SlcApi",
12 extend
: qx
.core
.Object
,
15 DEFAULT_CONTEXT
: "/org.argeo.slc.webapp",
17 REMOVE_RESULT_FROM_COLL_SERVICE
: "removeResultFromCollection.service",
18 ADD_RESULT_TO_COLL_SERVICE
: "addResultToCollection.service",
19 LIST_COLLECTIONS_SERVICE
: "listCollectionRefs.service",
20 COPY_COLLECTION_TO_COLL_SERVICE
: "copyCollectionToCollection.service",
21 LIST_RESULTS_SERVICE
: "listResultAttributes.service",
22 GET_RESULT_SERVICE
: "getResult.service",
23 LIST_SLCEXEC_SERVICE
: "listSlcExecutions.service",
25 LIST_AGENTS_SERVICE
: "listAgents.service",
26 LIST_MODULES_SERVICE
: "listModulesDescriptors.service",
27 GET_EXECUTION_DESC_SERVICE
: "getExecutionDescriptor.service",
31 * Standard Request getter
32 * @param serviceName {String} The name of the service to call (without base context)
33 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
34 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
35 * @return {qx.io.remote.Request}
37 getServiceRequest:function(serviceName
, fireReloadEventType
, iLoadStatusables
){
38 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
39 return serviceManager
.getRequest(
40 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+serviceName
,
49 * Remove a result from a collection
50 * @param collectionId {String} Id of the destination collection
51 * @param resultId {String} Id of the test result to remove
52 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
53 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
54 * @return {qx.io.remote.Request}
56 getRemoveResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
57 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
58 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
62 request
.setParameter("collectionId", collectionId
);
63 request
.setParameter("resultUuid", resultId
);
68 * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.
69 * @param collectionId {String} The id of the collection
70 * @param patternAttribute {String} An optional attribute name on which to filter
71 * @param patternValue {String} The pattern to use for filtering a subset of result
72 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
73 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
74 * @return {qx.io.remote.Request} The Request object
76 getRemoveFromCollectionService : function(collectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
77 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
78 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
82 request
.setParameter("collectionId", collectionId
);
83 if(patternAttribute
&& patternValue
){
84 request
.setParameter("attrName", patternAttribute
);
85 request
.setParameter("attrPattern", patternValue
);
91 * Add a result to a given collection
92 * @param collectionId {String} Id of the destination collection
93 * @param resultId {String} Id of the test result to add
94 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
95 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
96 * @return {qx.io.remote.Request}
98 getAddResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
99 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
100 org
.argeo
.slc
.ria
.SlcApi
.ADD_RESULT_TO_COLL_SERVICE
,
104 request
.setParameter("collectionId", collectionId
);
105 request
.setParameter("resultUuid", resultId
);
110 * List current collections
111 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
112 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
113 * @return {qx.io.remote.Request}
115 getListCollectionsService : function(fireReloadEventType
, iLoadStatusables
){
116 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
117 org
.argeo
.slc
.ria
.SlcApi
.LIST_COLLECTIONS_SERVICE
,
124 * 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.
125 * @param sourceCollectionId {String} The current collection from which to copy
126 * @param targetCollectionId {String} The target collection. If unknown, it will be created.
127 * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.
128 * @param patternValue {String} The associated pattern to filter on the atttribute's value.
129 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
130 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
131 * @return {qx.io.remote.Request} The request object
133 getCopyCollectionService : function(sourceCollectionId
, targetCollectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
134 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
135 org
.argeo
.slc
.ria
.SlcApi
.COPY_COLLECTION_TO_COLL_SERVICE
,
139 request
.setParameter("sourceCollectionId", sourceCollectionId
);
140 request
.setParameter("targetCollectionId", targetCollectionId
);
141 if(patternAttribute
&& patternValue
){
142 request
.setParameter("attrName", patternAttribute
);
143 request
.setParameter("attrPattern", patternValue
);
149 * List all results or results of a given collection
150 * @param collectionId {String} Id of the collection to load
151 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
152 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
153 * @return {qx.io.remote.Request}
155 getListResultsService : function(collectionId
, fireReloadEventType
, iLoadStatusables
){
156 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
157 org
.argeo
.slc
.ria
.SlcApi
.LIST_RESULTS_SERVICE
,
162 request
.setParameter("id", collectionId
);
169 * @param resultId {String} Id of the test result to load
170 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
171 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
172 * @return {qx.io.remote.Request}
174 getLoadResultService : function(resultId
, fireReloadEventType
, iLoadStatusables
){
175 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
176 org
.argeo
.slc
.ria
.SlcApi
.GET_RESULT_SERVICE
,
180 request
.setParameter("uuid", resultId
);
185 * List currently registered SlcExecutions.
186 * @param fireReloadEventType {String} Event type to trigger (optionnal)
187 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
188 * @return {qx.io.remote.Request}
190 getListSlcExecutionsService:function(fireReloadEventType
, iLoadStatusables
){
191 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
192 org
.argeo
.slc
.ria
.SlcApi
.LIST_SLCEXEC_SERVICE
,
200 * List currently available agents queues.
201 * @param fireReloadEventType {String} Event type to trigger (optionnal)
202 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
203 * @return {qx.io.remote.Request}
205 getListAgentsService:function(fireReloadEventType
, iLoadStatusables
){
206 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
207 org
.argeo
.slc
.ria
.SlcApi
.LIST_AGENTS_SERVICE
,
214 * Load the module descriptors
215 * @param fireReloadEventType {String} Event type to trigger (optionnal)
216 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
217 * @return {qx.io.remote.Request}
219 getListModulesService : function(fireReloadEventType
, iLoadStatusables
){
220 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
221 org
.argeo
.slc
.ria
.SlcApi
.LIST_MODULES_SERVICE
,
228 * Get an execution module descriptor by its name and version
229 * @param moduleName {String} The name of the module to get
230 * @param moduleVersion {String} Its version, passed directly as a string
231 * @param fireReloadEventType {String} Event type to trigger (optionnal)
232 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
233 * @return {qx.io.remote.Request}
235 getLoadExecutionDescriptorService : function(moduleName
, moduleVersion
, fireReloadEventType
, iLoadStatusables
){
236 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
237 org
.argeo
.slc
.ria
.SlcApi
.GET_EXECUTION_DESC_SERVICE
,
241 req
.setParameter("moduleName", moduleName
);
242 req
.setParameter("version", moduleVersion
);
247 * Send a JMS message to the AMQ_CONTEXT
248 * @param destination {String} The destination queue, in the form "topic://destination"
249 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
250 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
252 getSendAmqMessageRequest : function(destination
, message
, iLoadStatusables
){
253 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
254 var request
= serviceManager
.getRequest(
255 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+org
.argeo
.slc
.ria
.SlcApi
.AMQ_SERVICE
,
261 request
.setParameter("destination", destination
);
262 request
.setParameter("message", message
.toXml());
263 request
.setParameter("type", "send");