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",
25 LIST_AGENTS_SERVICE
: "listAgents.service",
26 LIST_MODULES_SERVICE
: "listModulesDescriptors.service",
27 GET_EXECUTION_DESC_SERVICE
: "getExecutionDescriptor.service",
28 RELOAD_BUNDLE_SERVICE
: "reloadBundle.service",
32 * Standard Request getter
33 * @param serviceName {String} The name of the service to call (without base context)
34 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
35 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
36 * @return {qx.io.remote.Request}
38 getServiceRequest:function(serviceName
, fireReloadEventType
, iLoadStatusables
){
39 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
40 return serviceManager
.getRequest(
41 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+serviceName
,
50 * Remove a result from a collection
51 * @param collectionId {String} Id of the destination collection
52 * @param resultId {String} Id of the test result to remove
53 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
54 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
55 * @return {qx.io.remote.Request}
57 getRemoveResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
58 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
59 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
63 request
.setParameter("collectionId", collectionId
);
64 request
.setParameter("resultUuid", resultId
);
69 * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.
70 * @param collectionId {String} The id of the collection
71 * @param patternAttribute {String} An optional attribute name on which to filter
72 * @param patternValue {String} The pattern to use for filtering a subset of result
73 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
74 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
75 * @return {qx.io.remote.Request} The Request object
77 getRemoveFromCollectionService : function(collectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
78 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
79 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
83 request
.setParameter("collectionId", collectionId
);
84 if(patternAttribute
&& patternValue
){
85 request
.setParameter("attrName", patternAttribute
);
86 request
.setParameter("attrPattern", patternValue
);
92 * Add a result to a given collection
93 * @param collectionId {String} Id of the destination collection
94 * @param resultId {String} Id of the test result to add
95 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
96 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
97 * @return {qx.io.remote.Request}
99 getAddResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
100 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
101 org
.argeo
.slc
.ria
.SlcApi
.ADD_RESULT_TO_COLL_SERVICE
,
105 request
.setParameter("collectionId", collectionId
);
106 request
.setParameter("resultUuid", resultId
);
111 * List current collections
112 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
113 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
114 * @return {qx.io.remote.Request}
116 getListCollectionsService : function(fireReloadEventType
, iLoadStatusables
){
117 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
118 org
.argeo
.slc
.ria
.SlcApi
.LIST_COLLECTIONS_SERVICE
,
125 * 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.
126 * @param sourceCollectionId {String} The current collection from which to copy
127 * @param targetCollectionId {String} The target collection. If unknown, it will be created.
128 * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.
129 * @param patternValue {String} The associated pattern to filter on the atttribute's value.
130 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
131 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
132 * @return {qx.io.remote.Request} The request object
134 getCopyCollectionService : function(sourceCollectionId
, targetCollectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
135 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
136 org
.argeo
.slc
.ria
.SlcApi
.COPY_COLLECTION_TO_COLL_SERVICE
,
140 request
.setParameter("sourceCollectionId", sourceCollectionId
);
141 request
.setParameter("targetCollectionId", targetCollectionId
);
142 if(patternAttribute
&& patternValue
){
143 request
.setParameter("attrName", patternAttribute
);
144 request
.setParameter("attrPattern", patternValue
);
150 * List all results or results of a given collection
151 * @param collectionId {String} Id of the collection to load
152 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
153 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
154 * @return {qx.io.remote.Request}
156 getListResultsService : function(collectionId
, fireReloadEventType
, iLoadStatusables
){
157 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
158 org
.argeo
.slc
.ria
.SlcApi
.LIST_RESULTS_SERVICE
,
163 request
.setParameter("id", collectionId
);
170 * @param resultId {String} Id of the test result to load
171 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
172 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
173 * @return {qx.io.remote.Request}
175 getLoadResultService : function(resultId
, fireReloadEventType
, iLoadStatusables
){
176 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
177 org
.argeo
.slc
.ria
.SlcApi
.GET_RESULT_SERVICE
,
181 request
.setParameter("uuid", resultId
);
186 * List currently registered SlcExecutions.
187 * @param fireReloadEventType {String} Event type to trigger (optionnal)
188 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
189 * @return {qx.io.remote.Request}
191 getListSlcExecutionsService:function(fireReloadEventType
, iLoadStatusables
){
192 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
193 org
.argeo
.slc
.ria
.SlcApi
.LIST_SLCEXEC_SERVICE
,
201 * List currently available agents queues.
202 * @param fireReloadEventType {String} Event type to trigger (optionnal)
203 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
204 * @return {qx.io.remote.Request}
206 getListAgentsService:function(fireReloadEventType
, iLoadStatusables
){
207 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
208 org
.argeo
.slc
.ria
.SlcApi
.LIST_AGENTS_SERVICE
,
215 * Load the module descriptors
216 * @param fireReloadEventType {String} Event type to trigger (optionnal)
217 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
218 * @return {qx.io.remote.Request}
220 getListModulesService : function(fireReloadEventType
, iLoadStatusables
){
221 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
222 org
.argeo
.slc
.ria
.SlcApi
.LIST_MODULES_SERVICE
,
229 * Get an execution module descriptor by its name and version
230 * @param moduleName {String} The name of the module to get
231 * @param moduleVersion {String} Its version, passed directly as a string
232 * @param fireReloadEventType {String} Event type to trigger (optionnal)
233 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
234 * @return {qx.io.remote.Request}
236 getLoadExecutionDescriptorService : function(moduleName
, moduleVersion
, fireReloadEventType
, iLoadStatusables
){
237 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
238 org
.argeo
.slc
.ria
.SlcApi
.GET_EXECUTION_DESC_SERVICE
,
242 req
.setParameter("moduleName", moduleName
);
243 req
.setParameter("version", moduleVersion
);
248 * Fire the reload of an OSGI bundle.
249 * @param fireReloadEventType {String} Event type to trigger (optionnal)
250 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
251 * @return {qx.io.remote.Request}
253 getReloadBundleService : function(bundleName
, bundleVersion
, fireReloadEventType
, iLoadStatusables
){
254 var req
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
255 org
.argeo
.slc
.ria
.SlcApi
.RELOAD_BUNDLE_SERVICE
,
259 req
.setParameter("bundleName", bundleName
);
260 req
.setParameter("bundleVersion", bundleVersion
);
267 * Send a JMS message to the AMQ_CONTEXT
268 * @param destination {String} The destination queue, in the form "topic://destination"
269 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
270 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
272 getSendAmqMessageRequest : function(destination
, message
, iLoadStatusables
){
273 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
274 var request
= serviceManager
.getRequest(
275 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+org
.argeo
.slc
.ria
.SlcApi
.AMQ_SERVICE
,
281 request
.setParameter("destination", destination
);
282 request
.setParameter("message", message
.toXml());
283 request
.setParameter("type", "send");