]> git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js
Add log4j for server JCR
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / 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 LIST_RESULTS_LONG_SERVICE : "listResults.service",
23 GET_RESULT_SERVICE : "getResult.service",
24 GET_ATTACHEMENT_SERVICE : "getAttachment.service",
25 LIST_SLCEXEC_SERVICE : "listSlcExecutions.service",
26 NEW_SLCEXEC_SERVICE : "newSlcExecution.service",
27
28 LIST_AGENTS_SERVICE : "listAgents.service",
29 LIST_MODULES_SERVICE : "listModulesDescriptors.service",
30 GET_EXECUTION_DESC_SERVICE : "getExecutionDescriptor.service",
31 GET_SLC_EXECUTION_SERVICE : "getSlcExecution.service",
32 RELOAD_BUNDLE_SERVICE : "reloadBundle.service",
33 AMQ_SERVICE : "amq",
34
35 LIST_MODULAR_DISTRIB_SERVICE : "listModularDistributions.service",
36 INSTALL_MODULE_SERVICE : "installModule.service",
37 UNINSTALL_MODULE_SERVICE : "uninstallModule.service",
38
39 /**
40 * Standard Request getter
41 * @param serviceName {String} The name of the service to call (without base context)
42 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
43 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
44 * @return {qx.io.remote.Request}
45 */
46 getServiceRequest:function(serviceName, fireReloadEventType, iLoadStatusables){
47 var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();
48 return serviceManager.getRequest(
49 org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+serviceName,
50 "GET",
51 "application/xml",
52 fireReloadEventType,
53 iLoadStatusables
54 );
55 },
56
57 /**
58 * Remove a result from a collection
59 * @param collectionId {String} Id of the destination collection
60 * @param resultId {String} Id of the test result to remove
61 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
62 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
63 * @return {qx.io.remote.Request}
64 */
65 getRemoveResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){
66 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
67 org.argeo.slc.ria.SlcApi.REMOVE_RESULT_FROM_COLL_SERVICE,
68 fireReloadEventType,
69 iLoadStatusables
70 );
71 request.setParameter("collectionId", collectionId);
72 request.setParameter("resultUuid", resultId);
73 return request;
74 },
75
76 /**
77 * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection.
78 * @param collectionId {String} The id of the collection
79 * @param patternAttribute {String} An optional attribute name on which to filter
80 * @param patternValue {String} The pattern to use for filtering a subset of result
81 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
82 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
83 * @return {qx.io.remote.Request} The Request object
84 */
85 getRemoveFromCollectionService : function(collectionId, patternAttribute, patternValue, fireReloadEventType, iLoadStatusables){
86 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
87 org.argeo.slc.ria.SlcApi.REMOVE_RESULT_FROM_COLL_SERVICE,
88 fireReloadEventType,
89 iLoadStatusables
90 );
91 request.setParameter("collectionId", collectionId);
92 if(patternAttribute && patternValue){
93 request.setParameter("attrName", patternAttribute);
94 request.setParameter("attrPattern", patternValue);
95 }
96 return request;
97 },
98
99 /**
100 * Add a result to a given collection
101 * @param collectionId {String} Id of the destination collection
102 * @param resultId {String} Id of the test result to add
103 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
104 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
105 * @return {qx.io.remote.Request}
106 */
107 getAddResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){
108 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
109 org.argeo.slc.ria.SlcApi.ADD_RESULT_TO_COLL_SERVICE,
110 fireReloadEventType,
111 iLoadStatusables
112 );
113 request.setParameter("collectionId", collectionId);
114 request.setParameter("resultUuid", resultId);
115 return request;
116 },
117
118 /**
119 * List current collections
120 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
121 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
122 * @return {qx.io.remote.Request}
123 */
124 getListCollectionsService : function(fireReloadEventType, iLoadStatusables){
125 return org.argeo.slc.ria.SlcApi.getServiceRequest(
126 org.argeo.slc.ria.SlcApi.LIST_COLLECTIONS_SERVICE,
127 fireReloadEventType,
128 iLoadStatusables
129 );
130 },
131
132 /**
133 * 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.
134 * @param sourceCollectionId {String} The current collection from which to copy
135 * @param targetCollectionId {String} The target collection. If unknown, it will be created.
136 * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset.
137 * @param patternValue {String} The associated pattern to filter on the atttribute's value.
138 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
139 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
140 * @return {qx.io.remote.Request} The request object
141 */
142 getCopyCollectionService : function(sourceCollectionId, targetCollectionId, patternAttribute, patternValue, fireReloadEventType, iLoadStatusables){
143 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
144 org.argeo.slc.ria.SlcApi.COPY_COLLECTION_TO_COLL_SERVICE,
145 fireReloadEventType,
146 iLoadStatusables
147 );
148 request.setParameter("sourceCollectionId", sourceCollectionId);
149 request.setParameter("targetCollectionId", targetCollectionId);
150 if(patternAttribute && patternValue){
151 request.setParameter("attrName", patternAttribute);
152 request.setParameter("attrPattern", patternValue);
153 }
154 return request;
155 },
156
157 /**
158 * List all results or results of a given collection with all details
159 * @param collectionId {String} Id of the collection to load
160 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
161 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
162 * @return {qx.io.remote.Request}
163 */
164 getListResultsLongService : function(collectionId, fireReloadEventType, iLoadStatusables){
165 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
166 org.argeo.slc.ria.SlcApi.LIST_RESULTS_LONG_SERVICE,
167 fireReloadEventType,
168 iLoadStatusables
169 );
170 if(collectionId){
171 request.setParameter("id", collectionId);
172 }
173 return request;
174 },
175
176 /**
177 * List all results or results of a given collection
178 * @param collectionId {String} Id of the collection to load
179 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
180 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
181 * @return {qx.io.remote.Request}
182 */
183 getListResultsService : function(collectionId, fireReloadEventType, iLoadStatusables){
184 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
185 org.argeo.slc.ria.SlcApi.LIST_RESULTS_SERVICE,
186 fireReloadEventType,
187 iLoadStatusables
188 );
189 if(collectionId){
190 request.setParameter("id", collectionId);
191 }
192 return request;
193 },
194
195 /**
196 * Load a result test
197 * @param resultId {String} Id of the test result to load
198 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
199 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
200 * @return {qx.io.remote.Request}
201 */
202 getLoadResultService : function(resultId, fireReloadEventType, iLoadStatusables){
203 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
204 org.argeo.slc.ria.SlcApi.GET_RESULT_SERVICE,
205 fireReloadEventType,
206 iLoadStatusables
207 );
208 request.setParameter("uuid", resultId);
209 return request;
210 },
211
212 buildGetAttachmentUrl : function(attachmentId, contentType, name){
213 return org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT + "/" + org.argeo.slc.ria.SlcApi.GET_ATTACHEMENT_SERVICE
214 + "?uuid=" + attachmentId + "&contentType=" + contentType + "&name=" + name;
215 },
216
217 /**
218 * List currently registered SlcExecutions.
219 * @param fireReloadEventType {String} Event type to trigger (optionnal)
220 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
221 * @return {qx.io.remote.Request}
222 */
223 getListSlcExecutionsService:function(fireReloadEventType, iLoadStatusables){
224 return org.argeo.slc.ria.SlcApi.getServiceRequest(
225 org.argeo.slc.ria.SlcApi.LIST_SLCEXEC_SERVICE,
226 fireReloadEventType,
227 iLoadStatusables
228 );
229 },
230
231 /**
232 * List currently registered SlcExecutions.
233 * @param fireReloadEventType {String} Event type to trigger (optionnal)
234 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
235 * @return {qx.io.remote.Request}
236 */
237 getListModularDistributionsService:function(fireReloadEventType, iLoadStatusables){
238 return org.argeo.slc.ria.SlcApi.getServiceRequest(
239 org.argeo.slc.ria.SlcApi.LIST_MODULAR_DISTRIB_SERVICE,
240 fireReloadEventType,
241 iLoadStatusables
242 );
243 },
244
245 getInstallModuleService : function(){
246 return org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT +"/"+ org.argeo.slc.ria.SlcApi.INSTALL_MODULE_SERVICE;
247 },
248
249 /**
250 * Load a result test
251 * @param resultId {String} Id of the test result to load
252 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
253 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
254 * @return {qx.io.remote.Request}
255 */
256 getUninstallModuleService : function(moduleName, moduleVersion, fireReloadEventType, iLoadStatusables){
257 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
258 org.argeo.slc.ria.SlcApi.UNINSTALL_MODULE_SERVICE,
259 fireReloadEventType,
260 iLoadStatusables
261 );
262 request.setParameter("name", moduleName);
263 request.setParameter("version", moduleVersion);
264 return request;
265 },
266
267
268
269 /**
270 * New SlcExecution
271 * @param agentId {String} Agent id target
272 * @param xmlDescription {String} XML of the Slc Execution
273 * @param fireReloadEventType {String} Event type to trigger (optionnal)
274 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
275 * @return {qx.io.remote.Request}
276 */
277 getNewSlcExecutionService:function(agentId, xmlDescription, fireReloadEventType, iLoadStatusables){
278 var req = org.argeo.slc.ria.SlcApi.getServiceRequest(
279 org.argeo.slc.ria.SlcApi.NEW_SLCEXEC_SERVICE + "?slc_agentId="+agentId,
280 fireReloadEventType,
281 iLoadStatusables
282 );
283 req.setMethod("POST");
284 //req.setRequestHeader("Content-Type", "text/xml");
285 req.setData("body=" + encodeURIComponent(xmlDescription));
286 return req;
287 },
288
289 getSlcExecutionService :function(executionMessageId, fireReloadEventType, iLoadStatusables){
290 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
291 org.argeo.slc.ria.SlcApi.GET_SLC_EXECUTION_SERVICE,
292 fireReloadEventType,
293 iLoadStatusables
294 );
295 request.setParameter("uuid", executionMessageId);
296 return request;
297 },
298
299 /**
300 * List currently available agents queues.
301 * @param fireReloadEventType {String} Event type to trigger (optionnal)
302 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
303 * @return {qx.io.remote.Request}
304 */
305 getListAgentsService:function(fireReloadEventType, iLoadStatusables){
306 return org.argeo.slc.ria.SlcApi.getServiceRequest(
307 org.argeo.slc.ria.SlcApi.LIST_AGENTS_SERVICE,
308 fireReloadEventType,
309 iLoadStatusables
310 );
311 },
312
313 /**
314 * Load the module descriptors
315 * @param fireReloadEventType {String} Event type to trigger (optionnal)
316 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
317 * @return {qx.io.remote.Request}
318 */
319 getListModulesService : function(agentId, fireReloadEventType, iLoadStatusables){
320 var req = org.argeo.slc.ria.SlcApi.getServiceRequest(
321 org.argeo.slc.ria.SlcApi.LIST_MODULES_SERVICE,
322 fireReloadEventType,
323 iLoadStatusables
324 );
325 req.setParameter("agentId", agentId);
326 return req;
327 },
328
329 /**
330 * Get an execution module descriptor by its name and version
331 * @param moduleName {String} The name of the module to get
332 * @param moduleVersion {String} Its version, passed directly as a string
333 * @param fireReloadEventType {String} Event type to trigger (optionnal)
334 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
335 * @return {qx.io.remote.Request}
336 */
337 getLoadExecutionDescriptorService : function(agentId,moduleName, moduleVersion, fireReloadEventType, iLoadStatusables){
338 var req = org.argeo.slc.ria.SlcApi.getServiceRequest(
339 org.argeo.slc.ria.SlcApi.GET_EXECUTION_DESC_SERVICE,
340 fireReloadEventType,
341 iLoadStatusables
342 );
343 req.setParameter("agentId", agentId);
344 req.setParameter("moduleName", moduleName);
345 req.setParameter("version", moduleVersion);
346 return req;
347 },
348
349 /**
350 * Fire the reload of an OSGI bundle.
351 * @param fireReloadEventType {String} Event type to trigger (optionnal)
352 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
353 * @return {qx.io.remote.Request}
354 */
355 getReloadBundleService : function(bundleName, bundleVersion, fireReloadEventType, iLoadStatusables){
356 var req = org.argeo.slc.ria.SlcApi.getServiceRequest(
357 org.argeo.slc.ria.SlcApi.RELOAD_BUNDLE_SERVICE,
358 fireReloadEventType,
359 iLoadStatusables
360 );
361 req.setParameter("bundleName", bundleName);
362 req.setParameter("bundleVersion", bundleVersion);
363 return req;
364 },
365
366
367
368 /**
369 * Send a JMS message to the AMQ_CONTEXT
370 * @param destination {String} The destination queue, in the form "topic://destination"
371 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
372 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
373 */
374 getSendAmqMessageRequest : function(destination, message, iLoadStatusables){
375 var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();
376 var request = serviceManager.getRequest(
377 org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+org.argeo.slc.ria.SlcApi.AMQ_SERVICE,
378 "POST",
379 "text/plain",
380 null,
381 iLoadStatusables
382 );
383 request.setParameter("destination", destination);
384 request.setParameter("message", message.toXml());
385 request.setParameter("type", "send");
386 return request;
387 }
388
389 }
390 });