]> 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/Flow.js
New icons for the tree
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / argeo-ria-lib / slc / class / org / argeo / slc / ria / execution / Flow.js
1 /**
2 * Wrapper for ExecutionFlow server object
3 */
4 qx.Class.define("org.argeo.slc.ria.execution.Flow", {
5
6 extend : qx.core.Object,
7
8 properties : {
9 /**
10 * Name of this Execution Flow
11 */
12 name : {
13 check : "String",
14 init : ""
15 },
16 /**
17 * An optional path describing this flow
18 */
19 path : {
20 check : "String",
21 nullable : true
22 },
23 /**
24 * Name of the associated spec, to be found in the module
25 */
26 executionSpecName : {
27 check : "String"
28 },
29 /**
30 * Reference the actual ExecutionSpec object
31 */
32 executionSpec : {
33 check : "org.argeo.slc.ria.execution.Spec"
34 },
35 /**
36 * The values to init the ExecutionSpec
37 */
38 values : {
39 check : "Node",
40 nullable : true
41 },
42 /**
43 * Castor representation of the object
44 */
45 xmlNode : {
46 apply : "_applyXmlNode"
47 }
48 },
49
50 statics : {
51 /**
52 * Xpath to the name
53 */
54 XPATH_NAME : "@name",
55 /**
56 * XPath to the ExecutionSpec name
57 */
58 XPATH_EXEC_SPEC_NAME : "@executionSpec",
59 /**
60 * XPath to the values
61 */
62 XPATH_VALUES : "slc:values",
63 /**
64 * An optional hierarchical path
65 */
66 XPATH_PATH : "@path"
67 },
68
69 construct : function(){
70 this.base(arguments);
71 },
72
73 members : {
74 /**
75 * Init the object from an XML representation
76 * @param xmlNode {Node} Castor representation of this object
77 */
78 _applyXmlNode : function(xmlNode){
79 this.set({
80 name : org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_NAME),
81 path : org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_PATH),
82 executionSpecName : org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_EXEC_SPEC_NAME)
83 });
84 var values = org.argeo.ria.util.Element.selectNodes(xmlNode, this.self(arguments).XPATH_VALUES);
85 if(values[0]){
86 this.setValues(values[0]);
87 }
88 },
89 /**
90 * Get a given value inside the values map
91 * @param key {String} The key of the value
92 * @param specType {String} Expected type (currently "primitive" and "ref" are supported)
93 * @param specSubType {String} Expected subtype (depends on the type)
94 * @return {String} Value if it is set.
95 */
96 getValue: function(key, specType, specSubType){
97 var xpath;
98 if(specType == "primitive"){
99 xpath = 'slc:value[@key="'+key+'"]/slc:primitive-value[@type="'+specSubType+'"]';
100 }else if(specType == "ref"){
101 xpath = 'slc:value[@key="'+key+'"]/slc:ref-value/slc:label';
102 }
103 return org.argeo.ria.util.Element.getSingleNodeText(this.getValues(), xpath);
104 }
105 }
106
107 });