]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js
Implement real services
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-lib / slc / class / org / argeo / slc / ria / SlcApi.js
1 /**
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.
9 */
10 qx.Class.define("org.argeo.slc.ria.SlcApi",
11 {
12 extend : qx.core.Object,
13
14 statics : {
15 DEFAULT_CONTEXT : "/org.argeo.slc.webapp",
16
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
25 LIST_AGENTS_SERVICE : "listAgents.service",
26 LIST_MODULES_SERVICE : "listModulesDescriptors.service",
27 GET_EXECUTION_DESC_SERVICE : "getExecutionDescriptor.service",
28 AMQ_SERVICE : "amq",
29
30 /**
31 * Standard Request getter
32 * @param serviceName {String} The name of the service to call (without base context)
33 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
34 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
35 * @return {qx.io.remote.Request}
36 */
37 getServiceRequest:function(serviceName, fireReloadEventType, iLoadStatusables){
38 var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();
39 return serviceManager.getRequest(
40 org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+serviceName,
41 "GET",
42 "application/xml",
43 fireReloadEventType,
44 iLoadStatusables
45 );
46 },
47
48 /**
49 * Remove a result from a collection
50 * @param collectionId {String} Id of the destination collection
51 * @param resultId {String} Id of the test result to remove
52 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
53 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
54 * @return {qx.io.remote.Request}
55 */
56 getRemoveResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){
57 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
58 org.argeo.slc.ria.SlcApi.REMOVE_RESULT_FROM_COLL_SERVICE,
59 fireReloadEventType,
60 iLoadStatusables
61 );
62 request.setParameter("collectionId", collectionId);
63 request.setParameter("resultUuid", resultId);
64 return request;
65 },
66
67 /**
68 * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.
69 * @param collectionId {String} The id of the collection
70 * @param patternAttribute {String} An optional attribute name on which to filter
71 * @param patternValue {String} The pattern to use for filtering a subset of result
72 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
73 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
74 * @return {qx.io.remote.Request} The Request object
75 */
76 getRemoveFromCollectionService : function(collectionId, patternAttribute, patternValue, fireReloadEventType, iLoadStatusables){
77 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
78 org.argeo.slc.ria.SlcApi.REMOVE_RESULT_FROM_COLL_SERVICE,
79 fireReloadEventType,
80 iLoadStatusables
81 );
82 request.setParameter("collectionId", collectionId);
83 if(patternAttribute && patternValue){
84 request.setParameter("attrName", patternAttribute);
85 request.setParameter("attrPattern", patternValue);
86 }
87 return request;
88 },
89
90 /**
91 * Add a result to a given collection
92 * @param collectionId {String} Id of the destination collection
93 * @param resultId {String} Id of the test result to add
94 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
95 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
96 * @return {qx.io.remote.Request}
97 */
98 getAddResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){
99 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
100 org.argeo.slc.ria.SlcApi.ADD_RESULT_TO_COLL_SERVICE,
101 fireReloadEventType,
102 iLoadStatusables
103 );
104 request.setParameter("collectionId", collectionId);
105 request.setParameter("resultUuid", resultId);
106 return request;
107 },
108
109 /**
110 * List current collections
111 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
112 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
113 * @return {qx.io.remote.Request}
114 */
115 getListCollectionsService : function(fireReloadEventType, iLoadStatusables){
116 return org.argeo.slc.ria.SlcApi.getServiceRequest(
117 org.argeo.slc.ria.SlcApi.LIST_COLLECTIONS_SERVICE,
118 fireReloadEventType,
119 iLoadStatusables
120 );
121 },
122
123 /**
124 * 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.
125 * @param sourceCollectionId {String} The current collection from which to copy
126 * @param targetCollectionId {String} The target collection. If unknown, it will be created.
127 * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.
128 * @param patternValue {String} The associated pattern to filter on the atttribute's value.
129 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
130 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
131 * @return {qx.io.remote.Request} The request object
132 */
133 getCopyCollectionService : function(sourceCollectionId, targetCollectionId, patternAttribute, patternValue, fireReloadEventType, iLoadStatusables){
134 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
135 org.argeo.slc.ria.SlcApi.COPY_COLLECTION_TO_COLL_SERVICE,
136 fireReloadEventType,
137 iLoadStatusables
138 );
139 request.setParameter("sourceCollectionId", sourceCollectionId);
140 request.setParameter("targetCollectionId", targetCollectionId);
141 if(patternAttribute && patternValue){
142 request.setParameter("attrName", patternAttribute);
143 request.setParameter("attrPattern", patternValue);
144 }
145 return request;
146 },
147
148 /**
149 * List all results or results of a given collection
150 * @param collectionId {String} Id of the collection to load
151 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
152 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
153 * @return {qx.io.remote.Request}
154 */
155 getListResultsService : function(collectionId, fireReloadEventType, iLoadStatusables){
156 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
157 org.argeo.slc.ria.SlcApi.LIST_RESULTS_SERVICE,
158 fireReloadEventType,
159 iLoadStatusables
160 );
161 if(collectionId){
162 request.setParameter("id", collectionId);
163 }
164 return request;
165 },
166
167 /**
168 * Load a result test
169 * @param resultId {String} Id of the test result to load
170 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
171 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
172 * @return {qx.io.remote.Request}
173 */
174 getLoadResultService : function(resultId, fireReloadEventType, iLoadStatusables){
175 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
176 org.argeo.slc.ria.SlcApi.GET_RESULT_SERVICE,
177 fireReloadEventType,
178 iLoadStatusables
179 );
180 request.setParameter("uuid", resultId);
181 return request;
182 },
183
184 /**
185 * List currently registered SlcExecutions.
186 * @param fireReloadEventType {String} Event type to trigger (optionnal)
187 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
188 * @return {qx.io.remote.Request}
189 */
190 getListSlcExecutionsService:function(fireReloadEventType, iLoadStatusables){
191 return org.argeo.slc.ria.SlcApi.getServiceRequest(
192 org.argeo.slc.ria.SlcApi.LIST_SLCEXEC_SERVICE,
193 fireReloadEventType,
194 iLoadStatusables
195 );
196 },
197
198
199 /**
200 * List currently available agents queues.
201 * @param fireReloadEventType {String} Event type to trigger (optionnal)
202 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
203 * @return {qx.io.remote.Request}
204 */
205 getListAgentsService:function(fireReloadEventType, iLoadStatusables){
206 return org.argeo.slc.ria.SlcApi.getServiceRequest(
207 org.argeo.slc.ria.SlcApi.LIST_AGENTS_SERVICE,
208 fireReloadEventType,
209 iLoadStatusables
210 );
211 },
212
213 /**
214 * Load the module descriptors
215 * @param fireReloadEventType {String} Event type to trigger (optionnal)
216 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
217 * @return {qx.io.remote.Request}
218 */
219 getListModulesService : function(fireReloadEventType, iLoadStatusables){
220 return org.argeo.slc.ria.SlcApi.getServiceRequest(
221 org.argeo.slc.ria.SlcApi.LIST_MODULES_SERVICE,
222 fireReloadEventType,
223 iLoadStatusables
224 );
225 },
226
227 /**
228 * Get an execution module descriptor by its name and version
229 * @param moduleName {String} The name of the module to get
230 * @param moduleVersion {String} Its version, passed directly as a string
231 * @param fireReloadEventType {String} Event type to trigger (optionnal)
232 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
233 * @return {qx.io.remote.Request}
234 */
235 getLoadExecutionDescriptorService : function(moduleName, moduleVersion, fireReloadEventType, iLoadStatusables){
236 var req = org.argeo.slc.ria.SlcApi.getServiceRequest(
237 org.argeo.slc.ria.SlcApi.GET_EXECUTION_DESC_SERVICE,
238 fireReloadEventType,
239 iLoadStatusables
240 );
241 req.setParameter("moduleName", moduleName);
242 req.setParameter("version", moduleVersion);
243 return req;
244 },
245
246 /**
247 * Send a JMS message to the AMQ_CONTEXT
248 * @param destination {String} The destination queue, in the form "topic://destination"
249 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
250 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
251 */
252 getSendAmqMessageRequest : function(destination, message, iLoadStatusables){
253 var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();
254 var request = serviceManager.getRequest(
255 org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+org.argeo.slc.ria.SlcApi.AMQ_SERVICE,
256 "POST",
257 "text/plain",
258 null,
259 iLoadStatusables
260 );
261 request.setParameter("destination", destination);
262 request.setParameter("message", message.toXml());
263 request.setParameter("type", "send");
264 return request;
265 }
266
267 }
268 });