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 LIST_RESULTS_LONG_SERVICE
: "listResults.service",
23 GET_RESULT_SERVICE
: "getResult.service",
24 GET_ATTACHEMENT_SERVICE
: "getAttachment.service",
25 LIST_SLCEXEC_SERVICE
: "listSlcExecutions.service",
26 NEW_SLCEXEC_SERVICE
: "newSlcExecution.service",
28 LIST_AGENTS_SERVICE
: "listAgents.service",
29 LIST_MODULES_SERVICE
: "listModulesDescriptors.service",
30 GET_EXECUTION_DESC_SERVICE
: "getExecutionDescriptor.service",
31 GET_SLC_EXECUTION_SERVICE
: "getSlcExecution.service",
32 RELOAD_BUNDLE_SERVICE
: "reloadBundle.service",
35 LIST_MODULAR_DISTRIB_SERVICE
: "listModularDistributions.service",
36 INSTALL_MODULE_SERVICE
: "installModule.service",
37 UNINSTALL_MODULE_SERVICE
: "uninstallModule.service",
40 * Standard Request getter
41 * @param serviceName {String} The name of the service to call (without base context)
42 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
43 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
44 * @return {qx.io.remote.Request}
46 getServiceRequest:function(serviceName
, fireReloadEventType
, iLoadStatusables
){
47 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
48 return serviceManager
.getRequest(
49 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+serviceName
,
58 * Remove a result from a collection
59 * @param collectionId {String} Id of the destination collection
60 * @param resultId {String} Id of the test result to remove
61 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
62 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
63 * @return {qx.io.remote.Request}
65 getRemoveResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
66 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
67 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
71 request
.setParameter("collectionId", collectionId
);
72 request
.setParameter("resultUuid", resultId
);
77 * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.
78 * @param collectionId {String} The id of the collection
79 * @param patternAttribute {String} An optional attribute name on which to filter
80 * @param patternValue {String} The pattern to use for filtering a subset of result
81 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
82 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
83 * @return {qx.io.remote.Request} The Request object
85 getRemoveFromCollectionService : function(collectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
86 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
87 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
91 request
.setParameter("collectionId", collectionId
);
92 if(patternAttribute
&& patternValue
){
93 request
.setParameter("attrName", patternAttribute
);
94 request
.setParameter("attrPattern", patternValue
);
100 * Add a result to a given collection
101 * @param collectionId {String} Id of the destination collection
102 * @param resultId {String} Id of the test result to add
103 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
104 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
105 * @return {qx.io.remote.Request}
107 getAddResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
108 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
109 org
.argeo
.slc
.ria
.SlcApi
.ADD_RESULT_TO_COLL_SERVICE
,
113 request
.setParameter("collectionId", collectionId
);
114 request
.setParameter("resultUuid", resultId
);
119 * List current collections
120 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
121 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
122 * @return {qx.io.remote.Request}
124 getListCollectionsService : function(fireReloadEventType
, iLoadStatusables
){
125 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
126 org
.argeo
.slc
.ria
.SlcApi
.LIST_COLLECTIONS_SERVICE
,
133 * 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.
134 * @param sourceCollectionId {String} The current collection from which to copy
135 * @param targetCollectionId {String} The target collection. If unknown, it will be created.
136 * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.
137 * @param patternValue {String} The associated pattern to filter on the atttribute's value.
138 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
139 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
140 * @return {qx.io.remote.Request} The request object
142 getCopyCollectionService : function(sourceCollectionId
, targetCollectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
143 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
144 org
.argeo
.slc
.ria
.SlcApi
.COPY_COLLECTION_TO_COLL_SERVICE
,
148 request
.setParameter("sourceCollectionId", sourceCollectionId
);
149 request
.setParameter("targetCollectionId", targetCollectionId
);
150 if(patternAttribute
&& patternValue
){
151 request
.setParameter("attrName", patternAttribute
);
152 request
.setParameter("attrPattern", patternValue
);
158 * List all results or results of a given collection with all details
159 * @param collectionId {String} Id of the collection to load
160 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
161 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
162 * @return {qx.io.remote.Request}
164 getListResultsLongService : function(collectionId
, fireReloadEventType
, iLoadStatusables
){
165 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
166 org
.argeo
.slc
.ria
.SlcApi
.LIST_RESULTS_LONG_SERVICE
,
171 request
.setParameter("id", collectionId
);
177 * List all results or results of a given collection
178 * @param collectionId {String} Id of the collection to load
179 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
180 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
181 * @return {qx.io.remote.Request}
183 getListResultsService : function(collectionId
, fireReloadEventType
, iLoadStatusables
){
184 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
185 org
.argeo
.slc
.ria
.SlcApi
.LIST_RESULTS_SERVICE
,
190 request
.setParameter("id", collectionId
);
197 * @param resultId {String} Id of the test result to load
198 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
199 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
200 * @return {qx.io.remote.Request}
202 getLoadResultService : function(resultId
, fireReloadEventType
, iLoadStatusables
){
203 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
204 org
.argeo
.slc
.ria
.SlcApi
.GET_RESULT_SERVICE
,
208 request
.setParameter("uuid", resultId
);
212 buildGetAttachmentUrl : function(attachmentId
, contentType
, name
){
213 return org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+ "/" + org
.argeo
.slc
.ria
.SlcApi
.GET_ATTACHEMENT_SERVICE
214 + "?uuid=" + attachmentId
+ "&contentType=" + contentType
+ "&name=" + name
;
218 * List currently registered SlcExecutions.
219 * @param fireReloadEventType {String} Event type to trigger (optionnal)
220 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
221 * @return {qx.io.remote.Request}
223 getListSlcExecutionsService:function(fireReloadEventType
, iLoadStatusables
){
224 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
225 org
.argeo
.slc
.ria
.SlcApi
.LIST_SLCEXEC_SERVICE
,
232 * List currently registered SlcExecutions.
233 * @param fireReloadEventType {String} Event type to trigger (optionnal)
234 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
235 * @return {qx.io.remote.Request}
237 getListModularDistributionsService:function(fireReloadEventType
, iLoadStatusables
){
238 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
239 org
.argeo
.slc
.ria
.SlcApi
.LIST_MODULAR_DISTRIB_SERVICE
,
245 getInstallModuleService : function(){
246 return org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+ org
.argeo
.slc
.ria
.SlcApi
.INSTALL_MODULE_SERVICE
;
251 * @param resultId {String} Id of the test result to load
252 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
253 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
254 * @return {qx.io.remote.Request}
256 getUninstallModuleService : function(moduleName
, moduleVersion
, fireReloadEventType
, iLoadStatusables
){
257 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
258 org
.argeo
.slc
.ria
.SlcApi
.UNINSTALL_MODULE_SERVICE
,
262 request
.setParameter("name", moduleName
);
263 request
.setParameter("version", moduleVersion
);
271 * @param agentId {String} Agent id target
272 * @param xmlDescription {String} XML of the Slc Execution
273 * @param fireReloadEventType {String} Event type to trigger (optionnal)
274 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
275 * @return {qx.io.remote.Request}
277 getNewSlcExecutionService:function(agentId
, xmlDescription
, fireReloadEventType
, iLoadStatusables
){
278 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
279 org
.argeo
.slc
.ria
.SlcApi
.NEW_SLCEXEC_SERVICE
+ "?slc_agentId="+agentId
,
283 req
.setMethod("POST");
284 //req.setRequestHeader("Content-Type", "text/xml");
285 req
.setData("body=" + encodeURIComponent(xmlDescription
));
289 getSlcExecutionService :function(executionMessageId
, fireReloadEventType
, iLoadStatusables
){
290 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
291 org
.argeo
.slc
.ria
.SlcApi
.GET_SLC_EXECUTION_SERVICE
,
295 request
.setParameter("uuid", executionMessageId
);
300 * List currently available agents queues.
301 * @param fireReloadEventType {String} Event type to trigger (optionnal)
302 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
303 * @return {qx.io.remote.Request}
305 getListAgentsService:function(fireReloadEventType
, iLoadStatusables
){
306 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
307 org
.argeo
.slc
.ria
.SlcApi
.LIST_AGENTS_SERVICE
,
314 * Load the module descriptors
315 * @param fireReloadEventType {String} Event type to trigger (optionnal)
316 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
317 * @return {qx.io.remote.Request}
319 getListModulesService : function(agentId
, fireReloadEventType
, iLoadStatusables
){
320 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
321 org
.argeo
.slc
.ria
.SlcApi
.LIST_MODULES_SERVICE
,
325 req
.setParameter("agentId", agentId
);
330 * Get an execution module descriptor by its name and version
331 * @param moduleName {String} The name of the module to get
332 * @param moduleVersion {String} Its version, passed directly as a string
333 * @param fireReloadEventType {String} Event type to trigger (optionnal)
334 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
335 * @return {qx.io.remote.Request}
337 getLoadExecutionDescriptorService : function(agentId
,moduleName
, moduleVersion
, fireReloadEventType
, iLoadStatusables
){
338 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
339 org
.argeo
.slc
.ria
.SlcApi
.GET_EXECUTION_DESC_SERVICE
,
343 req
.setParameter("agentId", agentId
);
344 req
.setParameter("moduleName", moduleName
);
345 req
.setParameter("version", moduleVersion
);
350 * Fire the reload of an OSGI bundle.
351 * @param fireReloadEventType {String} Event type to trigger (optionnal)
352 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
353 * @return {qx.io.remote.Request}
355 getReloadBundleService : function(bundleName
, bundleVersion
, fireReloadEventType
, iLoadStatusables
){
356 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
357 org
.argeo
.slc
.ria
.SlcApi
.RELOAD_BUNDLE_SERVICE
,
361 req
.setParameter("bundleName", bundleName
);
362 req
.setParameter("bundleVersion", bundleVersion
);
369 * Send a JMS message to the AMQ_CONTEXT
370 * @param destination {String} The destination queue, in the form "topic://destination"
371 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
372 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
374 getSendAmqMessageRequest : function(destination
, message
, iLoadStatusables
){
375 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
376 var request
= serviceManager
.getRequest(
377 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+org
.argeo
.slc
.ria
.SlcApi
.AMQ_SERVICE
,
383 request
.setParameter("destination", destination
);
384 request
.setParameter("message", message
.toXml());
385 request
.setParameter("type", "send");