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 TAIL_SLCEXEC_STEP_COUNT
: "tailSlcExecutionStepsCount.service",
33 TAIL_SLCEXEC_STEP_OFFSET
: "tailSlcExecutionStepsOffset.service",
34 DOWNLOAD_SLCEXEC_STEPS
: "downloadSlcExecution.service",
36 RELOAD_BUNDLE_SERVICE
: "reloadBundle.service",
39 LIST_MODULAR_DISTRIB_SERVICE
: "listModularDistributions.service",
40 INSTALL_MODULE_SERVICE
: "installModule.service",
41 UNINSTALL_MODULE_SERVICE
: "uninstallModule.service",
44 * Standard Request getter
45 * @param serviceName {String} The name of the service to call (without base context)
46 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
47 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
48 * @return {qx.io.remote.Request}
50 getServiceRequest:function(serviceName
, fireReloadEventType
, iLoadStatusables
){
51 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
52 return serviceManager
.getRequest(
53 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+serviceName
,
62 * Remove a result from a collection
63 * @param collectionId {String} Id of the destination collection
64 * @param resultId {String} Id of the test result to remove
65 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
66 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
67 * @return {qx.io.remote.Request}
69 getRemoveResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
70 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
71 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
75 request
.setParameter("collectionId", collectionId
);
76 request
.setParameter("resultUuid", resultId
);
81 * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.
82 * @param collectionId {String} The id of the collection
83 * @param patternAttribute {String} An optional attribute name on which to filter
84 * @param patternValue {String} The pattern to use for filtering a subset of result
85 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
86 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
87 * @return {qx.io.remote.Request} The Request object
89 getRemoveFromCollectionService : function(collectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
90 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
91 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
95 request
.setParameter("collectionId", collectionId
);
96 if(patternAttribute
&& patternValue
){
97 request
.setParameter("attrName", patternAttribute
);
98 request
.setParameter("attrPattern", patternValue
);
104 * Add a result to a given collection
105 * @param collectionId {String} Id of the destination collection
106 * @param resultId {String} Id of the test result to add
107 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
108 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
109 * @return {qx.io.remote.Request}
111 getAddResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
112 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
113 org
.argeo
.slc
.ria
.SlcApi
.ADD_RESULT_TO_COLL_SERVICE
,
117 request
.setParameter("collectionId", collectionId
);
118 request
.setParameter("resultUuid", resultId
);
123 * List current collections
124 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
125 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
126 * @return {qx.io.remote.Request}
128 getListCollectionsService : function(fireReloadEventType
, iLoadStatusables
){
129 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
130 org
.argeo
.slc
.ria
.SlcApi
.LIST_COLLECTIONS_SERVICE
,
137 * 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.
138 * @param sourceCollectionId {String} The current collection from which to copy
139 * @param targetCollectionId {String} The target collection. If unknown, it will be created.
140 * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.
141 * @param patternValue {String} The associated pattern to filter on the atttribute's value.
142 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
143 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
144 * @return {qx.io.remote.Request} The request object
146 getCopyCollectionService : function(sourceCollectionId
, targetCollectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
147 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
148 org
.argeo
.slc
.ria
.SlcApi
.COPY_COLLECTION_TO_COLL_SERVICE
,
152 request
.setParameter("sourceCollectionId", sourceCollectionId
);
153 request
.setParameter("targetCollectionId", targetCollectionId
);
154 if(patternAttribute
&& patternValue
){
155 request
.setParameter("attrName", patternAttribute
);
156 request
.setParameter("attrPattern", patternValue
);
162 * List all results or results of a given collection with all details
163 * @param collectionId {String} Id of the collection to load
164 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
165 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
166 * @return {qx.io.remote.Request}
168 getListResultsLongService : function(collectionId
, fireReloadEventType
, iLoadStatusables
){
169 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
170 org
.argeo
.slc
.ria
.SlcApi
.LIST_RESULTS_LONG_SERVICE
,
175 request
.setParameter("id", collectionId
);
181 * List all results or results of a given collection
182 * @param collectionId {String} Id of the collection to load
183 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
184 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
185 * @return {qx.io.remote.Request}
187 getListResultsService : function(collectionId
, fireReloadEventType
, iLoadStatusables
){
188 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
189 org
.argeo
.slc
.ria
.SlcApi
.LIST_RESULTS_SERVICE
,
194 request
.setParameter("id", collectionId
);
201 * @param resultId {String} Id of the test result to load
202 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
203 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
204 * @return {qx.io.remote.Request}
206 getLoadResultService : function(resultId
, fireReloadEventType
, iLoadStatusables
){
207 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
208 org
.argeo
.slc
.ria
.SlcApi
.GET_RESULT_SERVICE
,
212 request
.setParameter("uuid", resultId
);
216 buildGetAttachmentUrl : function(attachmentId
, contentType
, name
){
217 return org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+ "/" + org
.argeo
.slc
.ria
.SlcApi
.GET_ATTACHEMENT_SERVICE
218 + "?uuid=" + attachmentId
+ "&contentType=" + contentType
+ "&name=" + name
;
222 * List currently registered SlcExecutions.
223 * @param fireReloadEventType {String} Event type to trigger (optionnal)
224 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
225 * @return {qx.io.remote.Request}
227 getListSlcExecutionsService:function(fireReloadEventType
, iLoadStatusables
){
228 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
229 org
.argeo
.slc
.ria
.SlcApi
.LIST_SLCEXEC_SERVICE
,
236 * List currently registered SlcExecutions.
237 * @param fireReloadEventType {String} Event type to trigger (optionnal)
238 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
239 * @return {qx.io.remote.Request}
241 getListModularDistributionsService:function(fireReloadEventType
, iLoadStatusables
){
242 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
243 org
.argeo
.slc
.ria
.SlcApi
.LIST_MODULAR_DISTRIB_SERVICE
,
249 getInstallModuleService : function(){
250 return org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+ org
.argeo
.slc
.ria
.SlcApi
.INSTALL_MODULE_SERVICE
;
255 * @param resultId {String} Id of the test result to load
256 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
257 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
258 * @return {qx.io.remote.Request}
260 getUninstallModuleService : function(moduleName
, moduleVersion
, fireReloadEventType
, iLoadStatusables
){
261 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
262 org
.argeo
.slc
.ria
.SlcApi
.UNINSTALL_MODULE_SERVICE
,
266 request
.setParameter("name", moduleName
);
267 request
.setParameter("version", moduleVersion
);
275 * @param agentId {String} Agent id target
276 * @param xmlDescription {String} XML of the Slc Execution
277 * @param fireReloadEventType {String} Event type to trigger (optionnal)
278 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
279 * @return {qx.io.remote.Request}
281 getNewSlcExecutionService:function(agentId
, xmlDescription
, fireReloadEventType
, iLoadStatusables
){
282 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
283 org
.argeo
.slc
.ria
.SlcApi
.NEW_SLCEXEC_SERVICE
+ "?slc_agentId="+agentId
,
287 req
.setMethod("POST");
288 //req.setRequestHeader("Content-Type", "text/xml");
289 req
.setData("body=" + encodeURIComponent(xmlDescription
));
293 getSlcExecutionService :function(executionMessageId
, fireReloadEventType
, iLoadStatusables
){
294 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
295 org
.argeo
.slc
.ria
.SlcApi
.GET_SLC_EXECUTION_SERVICE
,
299 request
.setParameter("uuid", executionMessageId
);
303 getTailSlcExecutionStepService : function(executionUuid
, stepCount
, offset
, fireReloadEventType
, iLoadStatusables
){
304 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
305 (offset
?org
.argeo
.slc
.ria
.SlcApi
.TAIL_SLCEXEC_STEP_OFFSET
:org
.argeo
.slc
.ria
.SlcApi
.TAIL_SLCEXEC_STEP_COUNT
),
309 request
.setParameter("uuid", executionUuid
);
311 request
.setParameter("stepOffsetUuid", offset
);
313 request
.setParameter("stepCount", stepCount
);
319 * List currently available agents queues.
320 * @param fireReloadEventType {String} Event type to trigger (optionnal)
321 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
322 * @return {qx.io.remote.Request}
324 getListAgentsService:function(fireReloadEventType
, iLoadStatusables
){
325 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
326 org
.argeo
.slc
.ria
.SlcApi
.LIST_AGENTS_SERVICE
,
333 * Load the module descriptors
334 * @param fireReloadEventType {String} Event type to trigger (optionnal)
335 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
336 * @return {qx.io.remote.Request}
338 getListModulesService : function(agentId
, fireReloadEventType
, iLoadStatusables
){
339 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
340 org
.argeo
.slc
.ria
.SlcApi
.LIST_MODULES_SERVICE
,
344 req
.setParameter("agentId", agentId
);
349 * Get an execution module descriptor by its name and version
350 * @param moduleName {String} The name of the module to get
351 * @param moduleVersion {String} Its version, passed directly as a string
352 * @param fireReloadEventType {String} Event type to trigger (optionnal)
353 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
354 * @return {qx.io.remote.Request}
356 getLoadExecutionDescriptorService : function(agentId
,moduleName
, moduleVersion
, fireReloadEventType
, iLoadStatusables
){
357 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
358 org
.argeo
.slc
.ria
.SlcApi
.GET_EXECUTION_DESC_SERVICE
,
362 req
.setParameter("agentId", agentId
);
363 req
.setParameter("moduleName", moduleName
);
364 req
.setParameter("version", moduleVersion
);
369 * Fire the reload of an OSGI bundle.
370 * @param fireReloadEventType {String} Event type to trigger (optionnal)
371 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
372 * @return {qx.io.remote.Request}
374 getReloadBundleService : function(bundleName
, bundleVersion
, fireReloadEventType
, iLoadStatusables
){
375 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
376 org
.argeo
.slc
.ria
.SlcApi
.RELOAD_BUNDLE_SERVICE
,
380 req
.setParameter("bundleName", bundleName
);
381 req
.setParameter("bundleVersion", bundleVersion
);
388 * Send a JMS message to the AMQ_CONTEXT
389 * @param destination {String} The destination queue, in the form "topic://destination"
390 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
391 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
393 getSendAmqMessageRequest : function(destination
, message
, iLoadStatusables
){
394 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
395 var request
= serviceManager
.getRequest(
396 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+org
.argeo
.slc
.ria
.SlcApi
.AMQ_SERVICE
,
402 request
.setParameter("destination", destination
);
403 request
.setParameter("message", message
.toXml());
404 request
.setParameter("type", "send");