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