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",
29 * Standard Request getter
30 * @param serviceName {String} The name of the service to call (without base context)
31 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
32 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
33 * @return {qx.io.remote.Request}
35 getServiceRequest:function(serviceName
, fireReloadEventType
, iLoadStatusables
){
36 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
37 return serviceManager
.getRequest(
38 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+serviceName
,
47 * Remove a result from a collection
48 * @param collectionId {String} Id of the destination collection
49 * @param resultId {String} Id of the test result to remove
50 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
51 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
52 * @return {qx.io.remote.Request}
54 getRemoveResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
55 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
56 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
60 request
.setParameter("collectionId", collectionId
);
61 request
.setParameter("resultUuid", resultId
);
66 * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.
67 * @param collectionId {String} The id of the collection
68 * @param patternAttribute {String} An optional attribute name on which to filter
69 * @param patternValue {String} The pattern to use for filtering a subset of result
70 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
71 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
72 * @return {qx.io.remote.Request} The Request object
74 getRemoveFromCollectionService : function(collectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
75 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
76 org
.argeo
.slc
.ria
.SlcApi
.REMOVE_RESULT_FROM_COLL_SERVICE
,
80 request
.setParameter("collectionId", collectionId
);
81 if(patternAttribute
&& patternValue
){
82 request
.setParameter("attrName", patternAttribute
);
83 request
.setParameter("attrPattern", patternValue
);
89 * Add a result to a given collection
90 * @param collectionId {String} Id of the destination collection
91 * @param resultId {String} Id of the test result to add
92 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
93 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
94 * @return {qx.io.remote.Request}
96 getAddResultService : function(collectionId
, resultId
, fireReloadEventType
, iLoadStatusables
){
97 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
98 org
.argeo
.slc
.ria
.SlcApi
.ADD_RESULT_TO_COLL_SERVICE
,
102 request
.setParameter("collectionId", collectionId
);
103 request
.setParameter("resultUuid", resultId
);
108 * List current collections
109 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
110 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
111 * @return {qx.io.remote.Request}
113 getListCollectionsService : function(fireReloadEventType
, iLoadStatusables
){
114 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
115 org
.argeo
.slc
.ria
.SlcApi
.LIST_COLLECTIONS_SERVICE
,
122 * 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.
123 * @param sourceCollectionId {String} The current collection from which to copy
124 * @param targetCollectionId {String} The target collection. If unknown, it will be created.
125 * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.
126 * @param patternValue {String} The associated pattern to filter on the atttribute's value.
127 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
128 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
129 * @return {qx.io.remote.Request} The request object
131 getCopyCollectionService : function(sourceCollectionId
, targetCollectionId
, patternAttribute
, patternValue
, fireReloadEventType
, iLoadStatusables
){
132 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
133 org
.argeo
.slc
.ria
.SlcApi
.COPY_COLLECTION_TO_COLL_SERVICE
,
137 request
.setParameter("sourceCollectionId", sourceCollectionId
);
138 request
.setParameter("targetCollectionId", targetCollectionId
);
139 if(patternAttribute
&& patternValue
){
140 request
.setParameter("attrName", patternAttribute
);
141 request
.setParameter("attrPattern", patternValue
);
147 * List all results or results of a given collection
148 * @param collectionId {String} Id of the collection to load
149 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
150 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
151 * @return {qx.io.remote.Request}
153 getListResultsService : function(collectionId
, fireReloadEventType
, iLoadStatusables
){
154 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
155 org
.argeo
.slc
.ria
.SlcApi
.LIST_RESULTS_SERVICE
,
160 request
.setParameter("id", collectionId
);
167 * @param resultId {String} Id of the test result to load
168 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
169 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
170 * @return {qx.io.remote.Request}
172 getLoadResultService : function(resultId
, fireReloadEventType
, iLoadStatusables
){
173 var request
= org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
174 org
.argeo
.slc
.ria
.SlcApi
.GET_RESULT_SERVICE
,
178 request
.setParameter("uuid", resultId
);
183 * List currently registered SlcExecutions.
184 * @param fireReloadEventType {String} Event type to trigger (optionnal)
185 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
186 * @return {qx.io.remote.Request}
188 getListSlcExecutionsService:function(fireReloadEventType
, iLoadStatusables
){
189 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
190 org
.argeo
.slc
.ria
.SlcApi
.LIST_SLCEXEC_SERVICE
,
198 * List currently available agents queues.
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 getListAgentsService:function(fireReloadEventType
, iLoadStatusables
){
204 return org
.argeo
.slc
.ria
.SlcApi
.getServiceRequest(
205 org
.argeo
.slc
.ria
.SlcApi
.LIST_AGENTS_SERVICE
,
212 * Send a JMS message to the AMQ_CONTEXT
213 * @param destination {String} The destination queue, in the form "topic://destination"
214 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
215 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
217 getSendAmqMessageRequest : function(destination
, message
, iLoadStatusables
){
218 var serviceManager
= org
.argeo
.ria
.remote
.RequestManager
.getInstance();
219 var request
= serviceManager
.getRequest(
220 org
.argeo
.slc
.ria
.SlcApi
.DEFAULT_CONTEXT
+"/"+org
.argeo
.slc
.ria
.SlcApi
.AMQ_SERVICE
,
226 request
.setParameter("destination", destination
);
227 request
.setParameter("message", message
.toXml());
228 request
.setParameter("type", "send");