]> 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/execution/Module.js
8e69c92b2b3b574294c78a2857bcc05bf893690f
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-lib / slc / class / org / argeo / slc / ria / execution / Module.js
1 /**
2 * Wrapper for ExecutionModule server object
3 */
4 qx.Class.define("org.argeo.slc.ria.execution.Module", {
5
6 extend : qx.core.Object,
7
8 properties : {
9 /**
10 * The name of the module
11 */
12 name : {
13 check : "String",
14 init : ""
15 },
16 /**
17 * The version of the module
18 */
19 version : {
20 check : "String",
21 init : ""
22 },
23 /**
24 * All execution flows registered by their name
25 */
26 executionFlows : {
27 check : "Map",
28 init : {}
29 },
30 /**
31 * All execution specs registered by their name
32 */
33 executionSpecs : {
34 check : "Map",
35 init : {}
36 },
37 /**
38 * XML description (castor)
39 */
40 xmlNode : {
41 apply : "_applyXmlNode"
42 }
43 },
44
45 statics : {
46 XPATH_NAME : "slc:execution-module-descriptor/slc:name",
47 XPATH_VERSION : "slc:execution-module-descriptor/slc:version",
48 XPATH_EXECUTION_FLOWS : "slc:execution-module-descriptor/slc:executionFlows/slc:execution-flow-descriptor",
49 XPATH_EXECUTION_SPECS : "slc:execution-module-descriptor/slc:executionSpecs/slc:simple-execution-spec"
50 },
51
52 construct : function(){},
53
54 members : {
55 /**
56 * Add an execution flow to this module
57 * @param executionFlow {org.argeo.slc.ria.execution.Flow}
58 */
59 addExecutionFlow : function(executionFlow){
60 var spec = this.getExecutionSpecByName(executionFlow.getExecutionSpecName());
61 if(spec){
62 executionFlow.setExecutionSpec(spec);
63 }else{
64 this.error("Warning, reference to an unknown ExecutionSpec : "+executionFlow.getExecutionSpecName());
65 }
66 this.getExecutionFlows()[executionFlow.getName()] = executionFlow;
67 },
68
69 /**
70 * Add an execution Spec to this module
71 * @param executionSpec {org.argeo.slc.ria.execution.Spec}
72 */
73 addExecutionSpec : function(executionSpec){
74 this.getExecutionSpecs()[executionSpec.getName()] = executionSpec;
75 },
76
77 getExecutionSpecByName : function(name){
78 return this.getExecutionSpecs()[name];
79 },
80
81 getExecutionFlowByName : function(name){
82 return this.getExecutionFlows()[name];
83 },
84
85 /**
86 * An xml node containing the castor mapped description of this object
87 * @param xmlNode {Node}
88 */
89 _applyXmlNode : function(xmlNode){
90 // Parse now
91 this.setName(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_NAME));
92 this.setVersion(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_VERSION));
93 // Parse Specs first
94 var specs = org.argeo.ria.util.Element.selectNodes(xmlNode, this.self(arguments).XPATH_EXECUTION_SPECS);
95 for(i=0; i< specs.length;i++){
96 var execSpec = new org.argeo.slc.ria.execution.Spec();
97 execSpec.setXmlNode(specs[i]);
98 this.addExecutionSpec(execSpec);
99 }
100 // Now parse Flows : to do AFTER specs
101 var flows = org.argeo.ria.util.Element.selectNodes(xmlNode, this.self(arguments).XPATH_EXECUTION_FLOWS);
102 for(var i=0;i<flows.length;i++){
103 var execFlow = new org.argeo.slc.ria.execution.Flow();
104 execFlow.setXmlNode(flows[i]);
105 this.addExecutionFlow(execFlow);
106 }
107 }
108
109 }
110
111 });