]> 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
Splitted the LauncherApplet into two different applets. The first one is a generic...
[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 LIST_RESULTS_SERVICE : "listResultAttributes.service",
21 GET_RESULT_SERVICE : "getResult.service",
22 LIST_SLCEXEC_SERVICE : "listSlcExecutions.service",
23
24 LIST_AGENTS_SERVICE : "listAgents.service",
25 AMQ_SERVICE : "amq",
26
27 /**
28 * Standard Request getter
29 * @param serviceName {String} The name of the service to call (without base context)
30 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
31 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
32 * @return {qx.io.remote.Request}
33 */
34 getServiceRequest:function(serviceName, fireReloadEventType, iLoadStatusables){
35 var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();
36 return serviceManager.getRequest(
37 org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+serviceName,
38 "GET",
39 "application/xml",
40 fireReloadEventType,
41 iLoadStatusables
42 );
43 },
44
45 /**
46 * Remove a result from a collection
47 * @param collectionId {String} Id of the destination collection
48 * @param resultId {String} Id of the test result to remove
49 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
50 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
51 * @return {qx.io.remote.Request}
52 */
53 getRemoveResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){
54 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
55 org.argeo.slc.ria.SlcApi.REMOVE_RESULT_FROM_COLL_SERVICE,
56 fireReloadEventType,
57 iLoadStatusables
58 );
59 request.setParameter("collectionId", collectionId);
60 request.setParameter("resultUuid", resultId);
61 return request;
62 },
63
64 /**
65 * Add a result to a given collection
66 * @param collectionId {String} Id of the destination collection
67 * @param resultId {String} Id of the test result to add
68 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
69 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
70 * @return {qx.io.remote.Request}
71 */
72 getAddResultService : function(collectionId, resultId, fireReloadEventType, iLoadStatusables){
73 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
74 org.argeo.slc.ria.SlcApi.ADD_RESULT_TO_COLL_SERVICE,
75 fireReloadEventType,
76 iLoadStatusables
77 );
78 request.setParameter("collectionId", collectionId);
79 request.setParameter("resultUuid", resultId);
80 return request;
81 },
82
83 /**
84 * List current collections
85 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
86 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
87 * @return {qx.io.remote.Request}
88 */
89 getListCollectionsService : function(fireReloadEventType, iLoadStatusables){
90 return org.argeo.slc.ria.SlcApi.getServiceRequest(
91 org.argeo.slc.ria.SlcApi.LIST_COLLECTIONS_SERVICE,
92 fireReloadEventType,
93 iLoadStatusables
94 );
95 },
96
97 /**
98 * List all results or results of a given collection
99 * @param collectionId {String} Id of the collection to load
100 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
101 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
102 * @return {qx.io.remote.Request}
103 */
104 getListResultsService : function(collectionId, fireReloadEventType, iLoadStatusables){
105 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
106 org.argeo.slc.ria.SlcApi.LIST_RESULTS_SERVICE,
107 fireReloadEventType,
108 iLoadStatusables
109 );
110 if(collectionId){
111 request.setParameter("id", collectionId);
112 }
113 return request;
114 },
115
116 /**
117 * Load a result test
118 * @param resultId {String} Id of the test result to load
119 * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent
120 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
121 * @return {qx.io.remote.Request}
122 */
123 getLoadResultService : function(resultId, fireReloadEventType, iLoadStatusables){
124 var request = org.argeo.slc.ria.SlcApi.getServiceRequest(
125 org.argeo.slc.ria.SlcApi.GET_RESULT_SERVICE,
126 fireReloadEventType,
127 iLoadStatusables
128 );
129 request.setParameter("uuid", resultId);
130 return request;
131 },
132
133 /**
134 * List currently registered SlcExecutions.
135 * @param fireReloadEventType {String} Event type to trigger (optionnal)
136 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
137 * @return {qx.io.remote.Request}
138 */
139 getListSlcExecutionsService:function(fireReloadEventType, iLoadStatusables){
140 return org.argeo.slc.ria.SlcApi.getServiceRequest(
141 org.argeo.slc.ria.SlcApi.LIST_SLCEXEC_SERVICE,
142 fireReloadEventType,
143 iLoadStatusables
144 );
145 },
146
147
148 /**
149 * List currently available agents queues.
150 * @param fireReloadEventType {String} Event type to trigger (optionnal)
151 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
152 * @return {qx.io.remote.Request}
153 */
154 getListAgentsService:function(fireReloadEventType, iLoadStatusables){
155 return org.argeo.slc.ria.SlcApi.getServiceRequest(
156 org.argeo.slc.ria.SlcApi.LIST_AGENTS_SERVICE,
157 fireReloadEventType,
158 iLoadStatusables
159 );
160 },
161
162 /**
163 * Send a JMS message to the AMQ_CONTEXT
164 * @param destination {String} The destination queue, in the form "topic://destination"
165 * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object
166 * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update
167 */
168 getSendAmqMessageRequest : function(destination, message, iLoadStatusables){
169 var serviceManager = org.argeo.ria.remote.RequestManager.getInstance();
170 var request = serviceManager.getRequest(
171 org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+org.argeo.slc.ria.SlcApi.AMQ_SERVICE,
172 "POST",
173 "text/plain",
174 null,
175 iLoadStatusables
176 );
177 request.setParameter("destination", destination);
178 request.setParameter("message", message.toXml());
179 request.setParameter("type", "send");
180 return request;
181 }
182
183 }
184 });