]> 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
Data model for batch entry, spec editor basis.
[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 AMQ_SERVICE : "amq",
27
28 /**
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}
34 */
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,
39 "GET",
40 "application/xml",
41 fireReloadEventType,
42 iLoadStatusables
43 );
44 },
45
46 /**
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}
53 */
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,
57 fireReloadEventType,
58 iLoadStatusables
59 );
60 request.setParameter("collectionId", collectionId);
61 request.setParameter("resultUuid", resultId);
62 return request;
63 },
64
65 /**
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
73 */
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,
77 fireReloadEventType,
78 iLoadStatusables
79 );
80 request.setParameter("collectionId", collectionId);
81 if(patternAttribute && patternValue){
82 request.setParameter("attrName", patternAttribute);
83 request.setParameter("attrPattern", patternValue);
84 }
85 return request;
86 },
87
88 /**
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}
95 */
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,
99 fireReloadEventType,
100 iLoadStatusables
101 );
102 request.setParameter("collectionId", collectionId);
103 request.setParameter("resultUuid", resultId);
104 return request;
105 },
106
107 /**
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}
112 */
113 getListCollectionsService : function(fireReloadEventType, iLoadStatusables){
114 return org.argeo.slc.ria.SlcApi.getServiceRequest(
115 org.argeo.slc.ria.SlcApi.LIST_COLLECTIONS_SERVICE,
116 fireReloadEventType,
117 iLoadStatusables
118 );
119 },
120
121 /**
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
130 */
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,
134 fireReloadEventType,
135 iLoadStatusables
136 );
137 request.setParameter("sourceCollectionId", sourceCollectionId);
138 request.setParameter("targetCollectionId", targetCollectionId);
139 if(patternAttribute && patternValue){
140 request.setParameter("attrName", patternAttribute);
141 request.setParameter("attrPattern", patternValue);
142 }
143 return request;
144 },
145
146 /**
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}
152 */
153 getListResultsService : function(collectionId, fireReloadEventType, iLoadStatusables){
154 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
155 org.argeo.slc.ria.SlcApi.LIST_RESULTS_SERVICE,
156 fireReloadEventType,
157 iLoadStatusables
158 );
159 if(collectionId){
160 request.setParameter("id", collectionId);
161 }
162 return request;
163 },
164
165 /**
166 * Load a result test
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}
171 */
172 getLoadResultService : function(resultId, fireReloadEventType, iLoadStatusables){
173 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
174 org.argeo.slc.ria.SlcApi.GET_RESULT_SERVICE,
175 fireReloadEventType,
176 iLoadStatusables
177 );
178 request.setParameter("uuid", resultId);
179 return request;
180 },
181
182 /**
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}
187 */
188 getListSlcExecutionsService:function(fireReloadEventType, iLoadStatusables){
189 return org.argeo.slc.ria.SlcApi.getServiceRequest(
190 org.argeo.slc.ria.SlcApi.LIST_SLCEXEC_SERVICE,
191 fireReloadEventType,
192 iLoadStatusables
193 );
194 },
195
196
197 /**
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}
202 */
203 getListAgentsService:function(fireReloadEventType, iLoadStatusables){
204 return org.argeo.slc.ria.SlcApi.getServiceRequest(
205 org.argeo.slc.ria.SlcApi.LIST_AGENTS_SERVICE,
206 fireReloadEventType,
207 iLoadStatusables
208 );
209 },
210
211 /**
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
216 */
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,
221 "POST",
222 "text/plain",
223 null,
224 iLoadStatusables
225 );
226 request.setParameter("destination", destination);
227 request.setParameter("message", message.toXml());
228 request.setParameter("type", "send");
229 return request;
230 }
231
232 }
233 });