]> 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
Handle the folders drag'n'drop (dynamic nodes must be loaded, however).
[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 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 RELOAD_BUNDLE_SERVICE : "reloadBundle.service",
29 AMQ_SERVICE : "amq",
30
31 /**
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}
37 */
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,
42 "GET",
43 "application/xml",
44 fireReloadEventType,
45 iLoadStatusables
46 );
47 },
48
49 /**
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}
56 */
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,
60 fireReloadEventType,
61 iLoadStatusables
62 );
63 request.setParameter("collectionId", collectionId);
64 request.setParameter("resultUuid", resultId);
65 return request;
66 },
67
68 /**
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
76 */
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,
80 fireReloadEventType,
81 iLoadStatusables
82 );
83 request.setParameter("collectionId", collectionId);
84 if(patternAttribute && patternValue){
85 request.setParameter("attrName", patternAttribute);
86 request.setParameter("attrPattern", patternValue);
87 }
88 return request;
89 },
90
91 /**
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}
98 */
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,
102 fireReloadEventType,
103 iLoadStatusables
104 );
105 request.setParameter("collectionId", collectionId);
106 request.setParameter("resultUuid", resultId);
107 return request;
108 },
109
110 /**
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}
115 */
116 getListCollectionsService : function(fireReloadEventType, iLoadStatusables){
117 return org.argeo.slc.ria.SlcApi.getServiceRequest(
118 org.argeo.slc.ria.SlcApi.LIST_COLLECTIONS_SERVICE,
119 fireReloadEventType,
120 iLoadStatusables
121 );
122 },
123
124 /**
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
133 */
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,
137 fireReloadEventType,
138 iLoadStatusables
139 );
140 request.setParameter("sourceCollectionId", sourceCollectionId);
141 request.setParameter("targetCollectionId", targetCollectionId);
142 if(patternAttribute && patternValue){
143 request.setParameter("attrName", patternAttribute);
144 request.setParameter("attrPattern", patternValue);
145 }
146 return request;
147 },
148
149 /**
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}
155 */
156 getListResultsService : function(collectionId, fireReloadEventType, iLoadStatusables){
157 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
158 org.argeo.slc.ria.SlcApi.LIST_RESULTS_SERVICE,
159 fireReloadEventType,
160 iLoadStatusables
161 );
162 if(collectionId){
163 request.setParameter("id", collectionId);
164 }
165 return request;
166 },
167
168 /**
169 * Load a result test
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}
174 */
175 getLoadResultService : function(resultId, fireReloadEventType, iLoadStatusables){
176 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
177 org.argeo.slc.ria.SlcApi.GET_RESULT_SERVICE,
178 fireReloadEventType,
179 iLoadStatusables
180 );
181 request.setParameter("uuid", resultId);
182 return request;
183 },
184
185 /**
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}
190 */
191 getListSlcExecutionsService:function(fireReloadEventType, iLoadStatusables){
192 return org.argeo.slc.ria.SlcApi.getServiceRequest(
193 org.argeo.slc.ria.SlcApi.LIST_SLCEXEC_SERVICE,
194 fireReloadEventType,
195 iLoadStatusables
196 );
197 },
198
199
200 /**
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}
205 */
206 getListAgentsService:function(fireReloadEventType, iLoadStatusables){
207 return org.argeo.slc.ria.SlcApi.getServiceRequest(
208 org.argeo.slc.ria.SlcApi.LIST_AGENTS_SERVICE,
209 fireReloadEventType,
210 iLoadStatusables
211 );
212 },
213
214 /**
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}
219 */
220 getListModulesService : function(agentId, fireReloadEventType, iLoadStatusables){
221 var req = org.argeo.slc.ria.SlcApi.getServiceRequest(
222 org.argeo.slc.ria.SlcApi.LIST_MODULES_SERVICE,
223 fireReloadEventType,
224 iLoadStatusables
225 );
226 req.setParameter("agentId", agentId);
227 return req;
228 },
229
230 /**
231 * Get an execution module descriptor by its name and version
232 * @param moduleName {String} The name of the module to get
233 * @param moduleVersion {String} Its version, passed directly as a string
234 * @param fireReloadEventType {String} Event type to trigger (optionnal)
235 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
236 * @return {qx.io.remote.Request}
237 */
238 getLoadExecutionDescriptorService : function(moduleName, moduleVersion, fireReloadEventType, iLoadStatusables){
239 var req = org.argeo.slc.ria.SlcApi.getServiceRequest(
240 org.argeo.slc.ria.SlcApi.GET_EXECUTION_DESC_SERVICE,
241 fireReloadEventType,
242 iLoadStatusables
243 );
244 req.setParameter("moduleName", moduleName);
245 req.setParameter("version", moduleVersion);
246 return req;
247 },
248
249 /**
250 * Fire the reload of an OSGI bundle.
251 * @param fireReloadEventType {String} Event type to trigger (optionnal)
252 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
253 * @return {qx.io.remote.Request}
254 */
255 getReloadBundleService : function(bundleName, bundleVersion, fireReloadEventType, iLoadStatusables){
256 var req = org.argeo.slc.ria.SlcApi.getServiceRequest(
257 org.argeo.slc.ria.SlcApi.RELOAD_BUNDLE_SERVICE,
258 fireReloadEventType,
259 iLoadStatusables
260 );
261 req.setParameter("bundleName", bundleName);
262 req.setParameter("bundleVersion", bundleVersion);
263 return req;
264 },
265
266
267
268 /**
269 * Send a JMS message to the AMQ_CONTEXT
270 * @param destination {String} The destination queue, in the form "topic://destination"
271 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
272 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
273 */
274 getSendAmqMessageRequest : function(destination, message, iLoadStatusables){
275 var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();
276 var request = serviceManager.getRequest(
277 org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+org.argeo.slc.ria.SlcApi.AMQ_SERVICE,
278 "POST",
279 "text/plain",
280 null,
281 iLoadStatusables
282 );
283 request.setParameter("destination", destination);
284 request.setParameter("message", message.toXml());
285 request.setParameter("type", "send");
286 return request;
287 }
288
289 }
290 });