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 RELOAD_BUNDLE_SERVICE
: "reloadBundle.service",
34 * Standard Request getter
35 * @param serviceName {String} The name of the service to call (without base context)
36 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
37 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
38 * @return {qx.io.remote.Request}
40 getServiceRequest:function(serviceName
, fireReloadEventType
, iLoadStatusables
){
41 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
42 return serviceManager
.getRequest(
43 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+serviceName
,
52 * Remove a result from a collection
53 * @param collectionId {String} Id of the destination collection
54 * @param resultId {String} Id of the test result to remove
55 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
56 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
57 * @return {qx.io.remote.Request}
59 getRemoveResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
60 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
61 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
65 request
.setParameter("collectionId", collectionId
);
66 request
.setParameter("resultUuid", resultId
);
71 * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.
72 * @param collectionId {String} The id of the collection
73 * @param patternAttribute {String} An optional attribute name on which to filter
74 * @param patternValue {String} The pattern to use for filtering a subset of result
75 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
76 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
77 * @return {qx.io.remote.Request} The Request object
79 getRemoveFromCollectionService : function(collectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
80 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
81 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
85 request
.setParameter("collectionId", collectionId
);
86 if(patternAttribute
&& patternValue
){
87 request
.setParameter("attrName", patternAttribute
);
88 request
.setParameter("attrPattern", patternValue
);
94 * Add a result to a given collection
95 * @param collectionId {String} Id of the destination collection
96 * @param resultId {String} Id of the test result to add
97 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
98 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
99 * @return {qx.io.remote.Request}
101 getAddResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
102 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
103 org
.argeo
.slc
.ria
.SlcApi
.ADD_RESULT_TO_COLL_SERVICE
,
107 request
.setParameter("collectionId", collectionId
);
108 request
.setParameter("resultUuid", resultId
);
113 * List current collections
114 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
115 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
116 * @return {qx.io.remote.Request}
118 getListCollectionsService : function(fireReloadEventType
, iLoadStatusables
){
119 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
120 org
.argeo
.slc
.ria
.SlcApi
.LIST_COLLECTIONS_SERVICE
,
127 * 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.
128 * @param sourceCollectionId {String} The current collection from which to copy
129 * @param targetCollectionId {String} The target collection. If unknown, it will be created.
130 * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.
131 * @param patternValue {String} The associated pattern to filter on the atttribute's value.
132 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
133 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
134 * @return {qx.io.remote.Request} The request object
136 getCopyCollectionService : function(sourceCollectionId
, targetCollectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
137 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
138 org
.argeo
.slc
.ria
.SlcApi
.COPY_COLLECTION_TO_COLL_SERVICE
,
142 request
.setParameter("sourceCollectionId", sourceCollectionId
);
143 request
.setParameter("targetCollectionId", targetCollectionId
);
144 if(patternAttribute
&& patternValue
){
145 request
.setParameter("attrName", patternAttribute
);
146 request
.setParameter("attrPattern", patternValue
);
152 * List all results or results of a given collection
153 * @param collectionId {String} Id of the collection to load
154 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
155 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
156 * @return {qx.io.remote.Request}
158 getListResultsService : function(collectionId
, fireReloadEventType
, iLoadStatusables
){
159 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
160 org
.argeo
.slc
.ria
.SlcApi
.LIST_RESULTS_SERVICE
,
165 request
.setParameter("id", collectionId
);
172 * @param resultId {String} Id of the test result to load
173 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
174 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
175 * @return {qx.io.remote.Request}
177 getLoadResultService : function(resultId
, fireReloadEventType
, iLoadStatusables
){
178 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
179 org
.argeo
.slc
.ria
.SlcApi
.GET_RESULT_SERVICE
,
183 request
.setParameter("uuid", resultId
);
187 buildGetAttachmentUrl : function(attachmentId
, contentType
, name
){
188 return org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+ "/" + org
.argeo
.slc
.ria
.SlcApi
.GET_ATTACHEMENT_SERVICE
189 + "?uuid=" + attachmentId
+ "&contentType=" + contentType
+ "&name=" + name
;
193 * List currently registered SlcExecutions.
194 * @param fireReloadEventType {String} Event type to trigger (optionnal)
195 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
196 * @return {qx.io.remote.Request}
198 getListSlcExecutionsService:function(fireReloadEventType
, iLoadStatusables
){
199 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
200 org
.argeo
.slc
.ria
.SlcApi
.LIST_SLCEXEC_SERVICE
,
209 * @param agentId {String} Agent id target
210 * @param xmlDescription {String} XML of the Slc Execution
211 * @param fireReloadEventType {String} Event type to trigger (optionnal)
212 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
213 * @return {qx.io.remote.Request}
215 getNewSlcExecutionService:function(agentId
, xmlDescription
, fireReloadEventType
, iLoadStatusables
){
216 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
217 org
.argeo
.slc
.ria
.SlcApi
.NEW_SLCEXEC_SERVICE
+ "?slc_agentId="+agentId
,
221 req
.setMethod("POST");
222 //req.setRequestHeader("Content-Type", "text/xml");
223 req
.setData("body=" + encodeURIComponent(xmlDescription
));
229 * List currently available agents queues.
230 * @param fireReloadEventType {String} Event type to trigger (optionnal)
231 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
232 * @return {qx.io.remote.Request}
234 getListAgentsService:function(fireReloadEventType
, iLoadStatusables
){
235 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
236 org
.argeo
.slc
.ria
.SlcApi
.LIST_AGENTS_SERVICE
,
243 * Load the module descriptors
244 * @param fireReloadEventType {String} Event type to trigger (optionnal)
245 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
246 * @return {qx.io.remote.Request}
248 getListModulesService : function(agentId
, fireReloadEventType
, iLoadStatusables
){
249 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
250 org
.argeo
.slc
.ria
.SlcApi
.LIST_MODULES_SERVICE
,
254 req
.setParameter("agentId", agentId
);
259 * Get an execution module descriptor by its name and version
260 * @param moduleName {String} The name of the module to get
261 * @param moduleVersion {String} Its version, passed directly as a string
262 * @param fireReloadEventType {String} Event type to trigger (optionnal)
263 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
264 * @return {qx.io.remote.Request}
266 getLoadExecutionDescriptorService : function(agentId
,moduleName
, moduleVersion
, fireReloadEventType
, iLoadStatusables
){
267 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
268 org
.argeo
.slc
.ria
.SlcApi
.GET_EXECUTION_DESC_SERVICE
,
272 req
.setParameter("agentId", agentId
);
273 req
.setParameter("moduleName", moduleName
);
274 req
.setParameter("version", moduleVersion
);
279 * Fire the reload of an OSGI bundle.
280 * @param fireReloadEventType {String} Event type to trigger (optionnal)
281 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
282 * @return {qx.io.remote.Request}
284 getReloadBundleService : function(bundleName
, bundleVersion
, fireReloadEventType
, iLoadStatusables
){
285 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
286 org
.argeo
.slc
.ria
.SlcApi
.RELOAD_BUNDLE_SERVICE
,
290 req
.setParameter("bundleName", bundleName
);
291 req
.setParameter("bundleVersion", bundleVersion
);
298 * Send a JMS message to the AMQ_CONTEXT
299 * @param destination {String} The destination queue, in the form "topic://destination"
300 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
301 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
303 getSendAmqMessageRequest : function(destination
, message
, iLoadStatusables
){
304 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
305 var request
= serviceManager
.getRequest(
306 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+org
.argeo
.slc
.ria
.SlcApi
.AMQ_SERVICE
,
312 request
.setParameter("destination", destination
);
313 request
.setParameter("message", message
.toXml());
314 request
.setParameter("type", "send");