]> 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
3337b3ca9799432cb50c49bf449e92f3e9beb961
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / 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 },
29 /**
30 * All execution specs registered by their name
31 */
32 executionSpecs : {
33 check : "Map"
34 },
35 /**
36 * XML description (castor)
37 */
38 xmlNode : {
39 apply : "_applyXmlNode"
40 }
41 },
42
43 statics : {
44 XPATH_NAME : "slc:execution-module-descriptor/slc:name",
45 XPATH_VERSION : "slc:execution-module-descriptor/slc:version",
46 XPATH_EXECUTION_FLOWS : "slc:execution-module-descriptor/slc:execution-flows/slc:execution-flow-descriptor",
47 XPATH_EXECUTION_SPECS : "slc:execution-module-descriptor/slc:execution-specs/slc:default-execution-spec"
48 },
49
50 construct : function(){
51 this.base(arguments);
52 this.setExecutionFlows({});
53 this.setExecutionSpecs({});
54 },
55
56 members : {
57 /**
58 * Add an execution flow to this module
59 * @param executionFlow {org.argeo.slc.ria.execution.Flow} An instance of execution.Flow
60 */
61 addExecutionFlow : function(executionFlow){
62 var spec = this.getExecutionSpecByName(executionFlow.getExecutionSpecName());
63 if(spec){
64 executionFlow.setExecutionSpec(spec);
65 }else{
66 this.error("Warning, reference to an unknown ExecutionSpec : "+executionFlow.getExecutionSpecName());
67 }
68 this.getExecutionFlows()[executionFlow.getName()] = executionFlow;
69 },
70
71 /**
72 * Add an execution Spec to this module
73 * @param executionSpec {org.argeo.slc.ria.execution.Spec} An instance of ExecutionSpec
74 */
75 addExecutionSpec : function(executionSpec){
76 this.getExecutionSpecs()[executionSpec.getName()] = executionSpec;
77 },
78 /**
79 * Find an execution spec by its name
80 * @param name {String} Name of the spec
81 * @return {org.argeo.slc.ria.execution.Spec} The spec
82 */
83 getExecutionSpecByName : function(name){
84 return this.getExecutionSpecs()[name];
85 },
86
87 /**
88 * Find an execution flow by its name
89 * @param name {String} name of the flow
90 * @return {org.argeo.slc.ria.execution.Flow} The flow
91 */
92 getExecutionFlowByName : function(name){
93 return this.getExecutionFlows()[name];
94 },
95
96 /**
97 * An xml node containing the castor mapped description of this object
98 * @param xmlNode {Node}
99 */
100 _applyXmlNode : function(xmlNode){
101 // Parse now
102 this.setName(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_NAME) || "Not Found");
103 this.setVersion(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_VERSION));
104 // Parse Specs first
105 var specs = org.argeo.ria.util.Element.selectNodes(xmlNode, this.self(arguments).XPATH_EXECUTION_SPECS);
106 for(i=0; i< specs.length;i++){
107 var execSpec = new org.argeo.slc.ria.execution.Spec();
108 execSpec.setXmlNode(specs[i]);
109 this.addExecutionSpec(execSpec);
110 }
111 // Now parse Flows : to do AFTER specs
112 var flows = org.argeo.ria.util.Element.selectNodes(xmlNode, this.self(arguments).XPATH_EXECUTION_FLOWS);
113 for(var i=0;i<flows.length;i++){
114 var execFlow = new org.argeo.slc.ria.execution.Flow();
115 execFlow.setXmlNode(flows[i]);
116 this.addExecutionFlow(execFlow);
117 }
118 }
119
120 }
121
122 });