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 GET_ATTACHEMENT_SERVICE
: "getAttachment.service",
24 LIST_SLCEXEC_SERVICE
: "listSlcExecutions.service",
25 NEW_SLCEXEC_SERVICE
: "newSlcExecution.service",
27 LIST_AGENTS_SERVICE
: "listAgents.service",
28 LIST_MODULES_SERVICE
: "listModulesDescriptors.service",
29 GET_EXECUTION_DESC_SERVICE
: "getExecutionDescriptor.service",
30 GET_SLC_EXECUTION_SERVICE
: "getSlcExecution.service",
31 RELOAD_BUNDLE_SERVICE
: "reloadBundle.service",
34 LIST_MODULAR_DISTRIB_SERVICE
: "listModularDistributions.service",
35 INSTALL_MODULE_SERVICE
: "installModule.service",
36 UNINSTALL_MODULE_SERVICE
: "uninstallModule.service",
39 * Standard Request getter
40 * @param serviceName {String} The name of the service to call (without base context)
41 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
42 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
43 * @return {qx.io.remote.Request}
45 getServiceRequest:function(serviceName
, fireReloadEventType
, iLoadStatusables
){
46 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
47 return serviceManager
.getRequest(
48 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+serviceName
,
57 * Remove a result from a collection
58 * @param collectionId {String} Id of the destination collection
59 * @param resultId {String} Id of the test result to remove
60 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
61 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
62 * @return {qx.io.remote.Request}
64 getRemoveResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
65 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
66 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
70 request
.setParameter("collectionId", collectionId
);
71 request
.setParameter("resultUuid", resultId
);
76 * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.
77 * @param collectionId {String} The id of the collection
78 * @param patternAttribute {String} An optional attribute name on which to filter
79 * @param patternValue {String} The pattern to use for filtering a subset of result
80 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
81 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
82 * @return {qx.io.remote.Request} The Request object
84 getRemoveFromCollectionService : function(collectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
85 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
86 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
90 request
.setParameter("collectionId", collectionId
);
91 if(patternAttribute
&& patternValue
){
92 request
.setParameter("attrName", patternAttribute
);
93 request
.setParameter("attrPattern", patternValue
);
99 * Add a result to a given collection
100 * @param collectionId {String} Id of the destination collection
101 * @param resultId {String} Id of the test result to add
102 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
103 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
104 * @return {qx.io.remote.Request}
106 getAddResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
107 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
108 org
.argeo
.slc
.ria
.SlcApi
.ADD_RESULT_TO_COLL_SERVICE
,
112 request
.setParameter("collectionId", collectionId
);
113 request
.setParameter("resultUuid", resultId
);
118 * List current collections
119 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
120 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
121 * @return {qx.io.remote.Request}
123 getListCollectionsService : function(fireReloadEventType
, iLoadStatusables
){
124 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
125 org
.argeo
.slc
.ria
.SlcApi
.LIST_COLLECTIONS_SERVICE
,
132 * 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.
133 * @param sourceCollectionId {String} The current collection from which to copy
134 * @param targetCollectionId {String} The target collection. If unknown, it will be created.
135 * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.
136 * @param patternValue {String} The associated pattern to filter on the atttribute's value.
137 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
138 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
139 * @return {qx.io.remote.Request} The request object
141 getCopyCollectionService : function(sourceCollectionId
, targetCollectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
142 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
143 org
.argeo
.slc
.ria
.SlcApi
.COPY_COLLECTION_TO_COLL_SERVICE
,
147 request
.setParameter("sourceCollectionId", sourceCollectionId
);
148 request
.setParameter("targetCollectionId", targetCollectionId
);
149 if(patternAttribute
&& patternValue
){
150 request
.setParameter("attrName", patternAttribute
);
151 request
.setParameter("attrPattern", patternValue
);
157 * List all results or results of a given collection
158 * @param collectionId {String} Id of the collection to load
159 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
160 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
161 * @return {qx.io.remote.Request}
163 getListResultsService : function(collectionId
, fireReloadEventType
, iLoadStatusables
){
164 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
165 org
.argeo
.slc
.ria
.SlcApi
.LIST_RESULTS_SERVICE
,
170 request
.setParameter("id", collectionId
);
177 * @param resultId {String} Id of the test result to load
178 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
179 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
180 * @return {qx.io.remote.Request}
182 getLoadResultService : function(resultId
, fireReloadEventType
, iLoadStatusables
){
183 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
184 org
.argeo
.slc
.ria
.SlcApi
.GET_RESULT_SERVICE
,
188 request
.setParameter("uuid", resultId
);
192 buildGetAttachmentUrl : function(attachmentId
, contentType
, name
){
193 return org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+ "/" + org
.argeo
.slc
.ria
.SlcApi
.GET_ATTACHEMENT_SERVICE
194 + "?uuid=" + attachmentId
+ "&contentType=" + contentType
+ "&name=" + name
;
198 * List currently registered SlcExecutions.
199 * @param fireReloadEventType {String} Event type to trigger (optionnal)
200 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
201 * @return {qx.io.remote.Request}
203 getListSlcExecutionsService:function(fireReloadEventType
, iLoadStatusables
){
204 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
205 org
.argeo
.slc
.ria
.SlcApi
.LIST_SLCEXEC_SERVICE
,
212 * List currently registered SlcExecutions.
213 * @param fireReloadEventType {String} Event type to trigger (optionnal)
214 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
215 * @return {qx.io.remote.Request}
217 getListModularDistributionsService:function(fireReloadEventType
, iLoadStatusables
){
218 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
219 org
.argeo
.slc
.ria
.SlcApi
.LIST_MODULAR_DISTRIB_SERVICE
,
225 getInstallModuleService : function(){
226 return org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+ org
.argeo
.slc
.ria
.SlcApi
.INSTALL_MODULE_SERVICE
;
231 * @param resultId {String} Id of the test result to load
232 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
233 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
234 * @return {qx.io.remote.Request}
236 getUninstallModuleService : function(moduleName
, moduleVersion
, fireReloadEventType
, iLoadStatusables
){
237 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
238 org
.argeo
.slc
.ria
.SlcApi
.UNINSTALL_MODULE_SERVICE
,
242 request
.setParameter("name", moduleName
);
243 request
.setParameter("version", moduleVersion
);
251 * @param agentId {String} Agent id target
252 * @param xmlDescription {String} XML of the Slc Execution
253 * @param fireReloadEventType {String} Event type to trigger (optionnal)
254 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
255 * @return {qx.io.remote.Request}
257 getNewSlcExecutionService:function(agentId
, xmlDescription
, fireReloadEventType
, iLoadStatusables
){
258 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
259 org
.argeo
.slc
.ria
.SlcApi
.NEW_SLCEXEC_SERVICE
+ "?slc_agentId="+agentId
,
263 req
.setMethod("POST");
264 //req.setRequestHeader("Content-Type", "text/xml");
265 req
.setData("body=" + encodeURIComponent(xmlDescription
));
269 getSlcExecutionService :function(executionMessageId
, fireReloadEventType
, iLoadStatusables
){
270 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
271 org
.argeo
.slc
.ria
.SlcApi
.GET_SLC_EXECUTION_SERVICE
,
275 request
.setParameter("uuid", executionMessageId
);
280 * List currently available agents queues.
281 * @param fireReloadEventType {String} Event type to trigger (optionnal)
282 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
283 * @return {qx.io.remote.Request}
285 getListAgentsService:function(fireReloadEventType
, iLoadStatusables
){
286 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
287 org
.argeo
.slc
.ria
.SlcApi
.LIST_AGENTS_SERVICE
,
294 * Load the module descriptors
295 * @param fireReloadEventType {String} Event type to trigger (optionnal)
296 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
297 * @return {qx.io.remote.Request}
299 getListModulesService : function(agentId
, fireReloadEventType
, iLoadStatusables
){
300 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
301 org
.argeo
.slc
.ria
.SlcApi
.LIST_MODULES_SERVICE
,
305 req
.setParameter("agentId", agentId
);
310 * Get an execution module descriptor by its name and version
311 * @param moduleName {String} The name of the module to get
312 * @param moduleVersion {String} Its version, passed directly as a string
313 * @param fireReloadEventType {String} Event type to trigger (optionnal)
314 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
315 * @return {qx.io.remote.Request}
317 getLoadExecutionDescriptorService : function(agentId
,moduleName
, moduleVersion
, fireReloadEventType
, iLoadStatusables
){
318 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
319 org
.argeo
.slc
.ria
.SlcApi
.GET_EXECUTION_DESC_SERVICE
,
323 req
.setParameter("agentId", agentId
);
324 req
.setParameter("moduleName", moduleName
);
325 req
.setParameter("version", moduleVersion
);
330 * Fire the reload of an OSGI bundle.
331 * @param fireReloadEventType {String} Event type to trigger (optionnal)
332 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
333 * @return {qx.io.remote.Request}
335 getReloadBundleService : function(bundleName
, bundleVersion
, fireReloadEventType
, iLoadStatusables
){
336 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
337 org
.argeo
.slc
.ria
.SlcApi
.RELOAD_BUNDLE_SERVICE
,
341 req
.setParameter("bundleName", bundleName
);
342 req
.setParameter("bundleVersion", bundleVersion
);
349 * Send a JMS message to the AMQ_CONTEXT
350 * @param destination {String} The destination queue, in the form "topic://destination"
351 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
352 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
354 getSendAmqMessageRequest : function(destination
, message
, iLoadStatusables
){
355 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
356 var request
= serviceManager
.getRequest(
357 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+org
.argeo
.slc
.ria
.SlcApi
.AMQ_SERVICE
,
363 request
.setParameter("destination", destination
);
364 request
.setParameter("message", message
.toXml());
365 request
.setParameter("type", "send");