]>
git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/Module.js
2 * Wrapper for ExecutionModule server object
4 qx
.Class
.define("org.argeo.slc.ria.execution.Module", {
6 extend
: qx
.core
.Object
,
10 * The name of the module
25 * The version of the module
32 * All execution flows registered by their name
38 * All execution specs registered by their name
44 * XML description (castor)
47 apply
: "_applyXmlNode"
52 XPATH_ROOT
: "slc:execution-module-descriptor",
53 XPATH_NAME
: "slc:name",
54 XPATH_LABEL
: "slc:label",
55 XPATH_DESCRIPTION
: "slc:description",
56 XPATH_VERSION
: "slc:version",
57 XPATH_EXECUTION_FLOWS
: "slc:execution-flows/slc:execution-flow-descriptor",
58 XPATH_EXECUTION_SPECS
: "slc:execution-specs/slc:default-execution-spec"
61 construct : function(){
63 this.setExecutionFlows({});
64 this.setExecutionSpecs({});
69 * Add an execution flow to this module
70 * @param executionFlow {org.argeo.slc.ria.execution.Flow} An instance of execution.Flow
72 addExecutionFlow : function(executionFlow
){
73 var spec
= this.getExecutionSpecByName(executionFlow
.getExecutionSpecName());
75 executionFlow
.setExecutionSpec(spec
);
77 this.error("Warning, reference to an unknown ExecutionSpec : "+executionFlow
.getExecutionSpecName());
79 this.getExecutionFlows()[executionFlow
.getName()] = executionFlow
;
83 * Add an execution Spec to this module
84 * @param executionSpec {org.argeo.slc.ria.execution.Spec} An instance of ExecutionSpec
86 addExecutionSpec : function(executionSpec
){
87 this.getExecutionSpecs()[executionSpec
.getName()] = executionSpec
;
90 * Find an execution spec by its name
91 * @param name {String} Name of the spec
92 * @return {org.argeo.slc.ria.execution.Spec} The spec
94 getExecutionSpecByName : function(name
){
95 return this.getExecutionSpecs()[name
];
99 * Find an execution flow by its name
100 * @param name {String} name of the flow
101 * @return {org.argeo.slc.ria.execution.Flow} The flow
103 getExecutionFlowByName : function(name
){
104 return this.getExecutionFlows()[name
];
107 moduleDataToXml : function(){
108 var xmlData
= '<slc:module-name>'+this.getName()+'</slc:module-name>';
109 xmlData
+= '<slc:module-version>'+this.getVersion()+'</slc:module-version>';
114 * An xml node containing the castor mapped description of this object
115 * @param xmlNode {Node}
117 _applyXmlNode : function(xmlNode
){
119 if(xmlNode
.nodeName
!= this.self(arguments
).XPATH_ROOT
){
120 appendRoot
= this.self(arguments
).XPATH_ROOT
+"/";
123 this.setName(org
.argeo
.ria
.util
.Element
.getSingleNodeText(xmlNode
, appendRoot
+ this.self(arguments
).XPATH_NAME
) || "Not Found");
124 this.setVersion(org
.argeo
.ria
.util
.Element
.getSingleNodeText(xmlNode
, appendRoot
+ this.self(arguments
).XPATH_VERSION
));
125 this.setLabel(org
.argeo
.ria
.util
.Element
.getSingleNodeText(xmlNode
, appendRoot
+ this.self(arguments
).XPATH_LABEL
) || this.getName());
126 this.setDescription(org
.argeo
.ria
.util
.Element
.getSingleNodeText(xmlNode
, appendRoot
+ this.self(arguments
).XPATH_DESCRIPTION
) || "");
129 var specs
= org
.argeo
.ria
.util
.Element
.selectNodes(xmlNode
, appendRoot
+ this.self(arguments
).XPATH_EXECUTION_SPECS
);
131 for(i
=0; i
< specs
.length
;i
++){
132 var execSpec
= new org
.argeo
.slc
.ria
.execution
.Spec();
133 execSpec
.setXmlNode(specs
[i
]);
134 this.addExecutionSpec(execSpec
);
137 // Now parse Flows : to do AFTER specs
138 var flows
= org
.argeo
.ria
.util
.Element
.selectNodes(xmlNode
, appendRoot
+ this.self(arguments
).XPATH_EXECUTION_FLOWS
);
140 for(var i
=0;i
<flows
.length
;i
++){
141 var execFlow
= new org
.argeo
.slc
.ria
.execution
.Flow();
142 execFlow
.setXmlNode(flows
[i
]);
143 this.addExecutionFlow(execFlow
);