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",
24 NEW_SLCEXEC_SERVICE
: "newSlcExecution.service",
26 LIST_AGENTS_SERVICE
: "listAgents.service",
27 LIST_MODULES_SERVICE
: "listModulesDescriptors.service",
28 GET_EXECUTION_DESC_SERVICE
: "getExecutionDescriptor.service",
29 RELOAD_BUNDLE_SERVICE
: "reloadBundle.service",
33 * Standard Request getter
34 * @param serviceName {String} The name of the service to call (without base context)
35 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
36 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
37 * @return {qx.io.remote.Request}
39 getServiceRequest:function(serviceName
, fireReloadEventType
, iLoadStatusables
){
40 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
41 return serviceManager
.getRequest(
42 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+serviceName
,
51 * Remove a result from a collection
52 * @param collectionId {String} Id of the destination collection
53 * @param resultId {String} Id of the test result to remove
54 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
55 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
56 * @return {qx.io.remote.Request}
58 getRemoveResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
59 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
60 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
64 request
.setParameter("collectionId", collectionId
);
65 request
.setParameter("resultUuid", resultId
);
70 * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.
71 * @param collectionId {String} The id of the collection
72 * @param patternAttribute {String} An optional attribute name on which to filter
73 * @param patternValue {String} The pattern to use for filtering a subset of result
74 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
75 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
76 * @return {qx.io.remote.Request} The Request object
78 getRemoveFromCollectionService : function(collectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
79 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
80 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
84 request
.setParameter("collectionId", collectionId
);
85 if(patternAttribute
&& patternValue
){
86 request
.setParameter("attrName", patternAttribute
);
87 request
.setParameter("attrPattern", patternValue
);
93 * Add a result to a given collection
94 * @param collectionId {String} Id of the destination collection
95 * @param resultId {String} Id of the test result to add
96 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
97 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
98 * @return {qx.io.remote.Request}
100 getAddResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
101 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
102 org
.argeo
.slc
.ria
.SlcApi
.ADD_RESULT_TO_COLL_SERVICE
,
106 request
.setParameter("collectionId", collectionId
);
107 request
.setParameter("resultUuid", resultId
);
112 * List current collections
113 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
114 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
115 * @return {qx.io.remote.Request}
117 getListCollectionsService : function(fireReloadEventType
, iLoadStatusables
){
118 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
119 org
.argeo
.slc
.ria
.SlcApi
.LIST_COLLECTIONS_SERVICE
,
126 * 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.
127 * @param sourceCollectionId {String} The current collection from which to copy
128 * @param targetCollectionId {String} The target collection. If unknown, it will be created.
129 * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.
130 * @param patternValue {String} The associated pattern to filter on the atttribute's value.
131 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
132 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
133 * @return {qx.io.remote.Request} The request object
135 getCopyCollectionService : function(sourceCollectionId
, targetCollectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
136 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
137 org
.argeo
.slc
.ria
.SlcApi
.COPY_COLLECTION_TO_COLL_SERVICE
,
141 request
.setParameter("sourceCollectionId", sourceCollectionId
);
142 request
.setParameter("targetCollectionId", targetCollectionId
);
143 if(patternAttribute
&& patternValue
){
144 request
.setParameter("attrName", patternAttribute
);
145 request
.setParameter("attrPattern", patternValue
);
151 * List all results or results of a given collection
152 * @param collectionId {String} Id of the collection to load
153 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
154 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
155 * @return {qx.io.remote.Request}
157 getListResultsService : function(collectionId
, fireReloadEventType
, iLoadStatusables
){
158 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
159 org
.argeo
.slc
.ria
.SlcApi
.LIST_RESULTS_SERVICE
,
164 request
.setParameter("id", collectionId
);
171 * @param resultId {String} Id of the test result to load
172 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
173 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
174 * @return {qx.io.remote.Request}
176 getLoadResultService : function(resultId
, fireReloadEventType
, iLoadStatusables
){
177 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
178 org
.argeo
.slc
.ria
.SlcApi
.GET_RESULT_SERVICE
,
182 request
.setParameter("uuid", resultId
);
187 * List currently registered SlcExecutions.
188 * @param fireReloadEventType {String} Event type to trigger (optionnal)
189 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
190 * @return {qx.io.remote.Request}
192 getListSlcExecutionsService:function(fireReloadEventType
, iLoadStatusables
){
193 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
194 org
.argeo
.slc
.ria
.SlcApi
.LIST_SLCEXEC_SERVICE
,
203 * @param agentId {String} Agent id target
204 * @param xmlDescription {String} XML of the Slc Execution
205 * @param fireReloadEventType {String} Event type to trigger (optionnal)
206 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
207 * @return {qx.io.remote.Request}
209 getNewSlcExecutionService:function(agentId
, xmlDescription
, fireReloadEventType
, iLoadStatusables
){
210 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
211 org
.argeo
.slc
.ria
.SlcApi
.NEW_SLCEXEC_SERVICE
+ "?slc_agentId="+agentId
,
215 req
.setMethod("POST");
216 //req.setRequestHeader("Content-Type", "text/xml");
217 req
.setData("body=" + encodeURIComponent(xmlDescription
));
223 * List currently available agents queues.
224 * @param fireReloadEventType {String} Event type to trigger (optionnal)
225 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
226 * @return {qx.io.remote.Request}
228 getListAgentsService:function(fireReloadEventType
, iLoadStatusables
){
229 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
230 org
.argeo
.slc
.ria
.SlcApi
.LIST_AGENTS_SERVICE
,
237 * Load the module descriptors
238 * @param fireReloadEventType {String} Event type to trigger (optionnal)
239 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
240 * @return {qx.io.remote.Request}
242 getListModulesService : function(agentId
, fireReloadEventType
, iLoadStatusables
){
243 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
244 org
.argeo
.slc
.ria
.SlcApi
.LIST_MODULES_SERVICE
,
248 req
.setParameter("agentId", agentId
);
253 * Get an execution module descriptor by its name and version
254 * @param moduleName {String} The name of the module to get
255 * @param moduleVersion {String} Its version, passed directly as a string
256 * @param fireReloadEventType {String} Event type to trigger (optionnal)
257 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
258 * @return {qx.io.remote.Request}
260 getLoadExecutionDescriptorService : function(agentId
,moduleName
, moduleVersion
, fireReloadEventType
, iLoadStatusables
){
261 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
262 org
.argeo
.slc
.ria
.SlcApi
.GET_EXECUTION_DESC_SERVICE
,
266 req
.setParameter("agentId", agentId
);
267 req
.setParameter("moduleName", moduleName
);
268 req
.setParameter("version", moduleVersion
);
273 * Fire the reload of an OSGI bundle.
274 * @param fireReloadEventType {String} Event type to trigger (optionnal)
275 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
276 * @return {qx.io.remote.Request}
278 getReloadBundleService : function(bundleName
, bundleVersion
, fireReloadEventType
, iLoadStatusables
){
279 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
280 org
.argeo
.slc
.ria
.SlcApi
.RELOAD_BUNDLE_SERVICE
,
284 req
.setParameter("bundleName", bundleName
);
285 req
.setParameter("bundleVersion", bundleVersion
);
292 * Send a JMS message to the AMQ_CONTEXT
293 * @param destination {String} The destination queue, in the form "topic://destination"
294 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
295 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
297 getSendAmqMessageRequest : function(destination
, message
, iLoadStatusables
){
298 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
299 var request
= serviceManager
.getRequest(
300 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+org
.argeo
.slc
.ria
.SlcApi
.AMQ_SERVICE
,
306 request
.setParameter("destination", destination
);
307 request
.setParameter("message", message
.toXml());
308 request
.setParameter("type", "send");