X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.webapp%2Fsrc%2Fmain%2Fwebapp%2Fargeo-ria-lib%2Fslc%2Fclass%2Forg%2Fargeo%2Fslc%2Fria%2FSlcApi.js;h=f59edc9b6673eba84207ce2d09a18852db6003f8;hb=68ed7317e5fefb71258b552c1fb2ccd1c1f8cbc5;hp=dd3632594d06764bdf2e59347af0026ec40c30cb;hpb=c58a78133506154b20a357921ea48f710f06e1bc;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js index dd3632594..f59edc9b6 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/SlcApi.js @@ -1,3 +1,12 @@ +/** + * SLC API Client implementation : + * This class encapsulate the various SLC services available. It just creates the Request object + * and return them, it does not execute them. + * Available services are : + * + loadResult / removeResult / addResult + * + listCollection / listResults + * When using it, be sure the static constant DEFAULT_CONTEXT is pointing to the right URL. + */ qx.Class.define("org.argeo.slc.ria.SlcApi", { extend : qx.core.Object, @@ -8,8 +17,16 @@ qx.Class.define("org.argeo.slc.ria.SlcApi", REMOVE_RESULT_FROM_COLL_SERVICE : "removeResultFromCollection.service", ADD_RESULT_TO_COLL_SERVICE : "addResultToCollection.service", LIST_COLLECTIONS_SERVICE : "listCollectionRefs.service", + COPY_COLLECTION_TO_COLL_SERVICE : "copyCollectionToCollection.service", LIST_RESULTS_SERVICE : "listResultAttributes.service", GET_RESULT_SERVICE : "getResult.service", + LIST_SLCEXEC_SERVICE : "listSlcExecutions.service", + + LIST_AGENTS_SERVICE : "listAgents.service", + LIST_MODULES_SERVICE : "listModulesDescriptors.service", + GET_EXECUTION_DESC_SERVICE : "getExecutionDescriptor.service", + RELOAD_BUNDLE_SERVICE : "reloadBundle.service", + AMQ_SERVICE : "amq", /** * Standard Request getter @@ -48,6 +65,29 @@ qx.Class.define("org.argeo.slc.ria.SlcApi", return request; }, + /** + * Remove a set of results from a collection. Either filtered by a given pattern, or the whole collection. + * @param collectionId {String} The id of the collection + * @param patternAttribute {String} An optional attribute name on which to filter + * @param patternValue {String} The pattern to use for filtering a subset of result + * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent + * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update + * @return {qx.io.remote.Request} The Request object + */ + getRemoveFromCollectionService : function(collectionId, patternAttribute, patternValue, fireReloadEventType, iLoadStatusables){ + var request = org.argeo.slc.ria.SlcApi.getServiceRequest( + org.argeo.slc.ria.SlcApi.REMOVE_RESULT_FROM_COLL_SERVICE, + fireReloadEventType, + iLoadStatusables + ); + request.setParameter("collectionId", collectionId); + if(patternAttribute && patternValue){ + request.setParameter("attrName", patternAttribute); + request.setParameter("attrPattern", patternValue); + } + return request; + }, + /** * Add a result to a given collection * @param collectionId {String} Id of the destination collection @@ -81,6 +121,31 @@ qx.Class.define("org.argeo.slc.ria.SlcApi", ); }, + /** + * 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. + * @param sourceCollectionId {String} The current collection from which to copy + * @param targetCollectionId {String} The target collection. If unknown, it will be created. + * @param patternAttribute {String} An optional attribute on which a filter can be applied to create a subset. + * @param patternValue {String} The associated pattern to filter on the atttribute's value. + * @param fireReloadEventType {String} Whether query should trigger a ReloadEvent + * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update + * @return {qx.io.remote.Request} The request object + */ + getCopyCollectionService : function(sourceCollectionId, targetCollectionId, patternAttribute, patternValue, fireReloadEventType, iLoadStatusables){ + var request = org.argeo.slc.ria.SlcApi.getServiceRequest( + org.argeo.slc.ria.SlcApi.COPY_COLLECTION_TO_COLL_SERVICE, + fireReloadEventType, + iLoadStatusables + ); + request.setParameter("sourceCollectionId", sourceCollectionId); + request.setParameter("targetCollectionId", targetCollectionId); + if(patternAttribute && patternValue){ + request.setParameter("attrName", patternAttribute); + request.setParameter("attrPattern", patternValue); + } + return request; + }, + /** * List all results or results of a given collection * @param collectionId {String} Id of the collection to load @@ -115,6 +180,108 @@ qx.Class.define("org.argeo.slc.ria.SlcApi", ); request.setParameter("uuid", resultId); return request; + }, + + /** + * List currently registered SlcExecutions. + * @param fireReloadEventType {String} Event type to trigger (optionnal) + * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update + * @return {qx.io.remote.Request} + */ + getListSlcExecutionsService:function(fireReloadEventType, iLoadStatusables){ + return org.argeo.slc.ria.SlcApi.getServiceRequest( + org.argeo.slc.ria.SlcApi.LIST_SLCEXEC_SERVICE, + fireReloadEventType, + iLoadStatusables + ); + }, + + + /** + * List currently available agents queues. + * @param fireReloadEventType {String} Event type to trigger (optionnal) + * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update + * @return {qx.io.remote.Request} + */ + getListAgentsService:function(fireReloadEventType, iLoadStatusables){ + return org.argeo.slc.ria.SlcApi.getServiceRequest( + org.argeo.slc.ria.SlcApi.LIST_AGENTS_SERVICE, + fireReloadEventType, + iLoadStatusables + ); + }, + + /** + * Load the module descriptors + * @param fireReloadEventType {String} Event type to trigger (optionnal) + * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update + * @return {qx.io.remote.Request} + */ + getListModulesService : function(fireReloadEventType, iLoadStatusables){ + return org.argeo.slc.ria.SlcApi.getServiceRequest( + org.argeo.slc.ria.SlcApi.LIST_MODULES_SERVICE, + fireReloadEventType, + iLoadStatusables + ); + }, + + /** + * Get an execution module descriptor by its name and version + * @param moduleName {String} The name of the module to get + * @param moduleVersion {String} Its version, passed directly as a string + * @param fireReloadEventType {String} Event type to trigger (optionnal) + * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update + * @return {qx.io.remote.Request} + */ + getLoadExecutionDescriptorService : function(moduleName, moduleVersion, fireReloadEventType, iLoadStatusables){ + var req = org.argeo.slc.ria.SlcApi.getServiceRequest( + org.argeo.slc.ria.SlcApi.GET_EXECUTION_DESC_SERVICE, + fireReloadEventType, + iLoadStatusables + ); + req.setParameter("moduleName", moduleName); + req.setParameter("version", moduleVersion); + return req; + }, + + /** + * Fire the reload of an OSGI bundle. + * @param fireReloadEventType {String} Event type to trigger (optionnal) + * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update + * @return {qx.io.remote.Request} + */ + getReloadBundleService : function(bundleName, bundleVersion, fireReloadEventType, iLoadStatusables){ + var req = org.argeo.slc.ria.SlcApi.getServiceRequest( + org.argeo.slc.ria.SlcApi.RELOAD_BUNDLE_SERVICE, + fireReloadEventType, + iLoadStatusables + ); + req.setParameter("bundleName", bundleName); + req.setParameter("bundleVersion", bundleVersion); + return req; + }, + + + + /** + * Send a JMS message to the AMQ_CONTEXT + * @param destination {String} The destination queue, in the form "topic://destination" + * @param message {org.argeo.slc.ria.SlcExecutionMessage} The message object + * @param iLoadStatusables {org.argeo.ria.components.ILoadStatusables[]} Gui parts to update + */ + getSendAmqMessageRequest : function(destination, message, iLoadStatusables){ + var serviceManager = org.argeo.ria.remote.RequestManager.getInstance(); + var request = serviceManager.getRequest( + org.argeo.slc.ria.SlcApi.DEFAULT_CONTEXT+"/"+org.argeo.slc.ria.SlcApi.AMQ_SERVICE, + "POST", + "text/plain", + null, + iLoadStatusables + ); + request.setParameter("destination", destination); + request.setParameter("message", message.toXml()); + request.setParameter("type", "send"); + return request; } }