]> git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/main/webapp/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/Flow.js
Create Argeo SLC RIA project
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / main / webapp / 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 },
41 /**
42 * Castor representation of the object
43 */
44 xmlNode : {
45 apply : "_applyXmlNode"
46 }
47 },
48
49 statics : {
50 /**
51 * Xpath to the name
52 */
53 XPATH_NAME : "@name",
54 /**
55 * XPath to the ExecutionSpec name
56 */
57 XPATH_EXEC_SPEC_NAME : "@executionSpec",
58 /**
59 * XPath to the values
60 */
61 XPATH_VALUES : "slc:values",
62 /**
63 * An optional hierarchical path
64 */
65 XPATH_PATH : "@path"
66 },
67
68 construct : function(){
69 this.base(arguments);
70 },
71
72 members : {
73 /**
74 * Init the object from an XML representation
75 * @param xmlNode {Node} Castor representation of this object
76 */
77 _applyXmlNode : function(xmlNode){
78 this.set({
79 name : org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_NAME),
80 path : org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_PATH),
81 executionSpecName : org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_EXEC_SPEC_NAME)
82 });
83 var values = org.argeo.ria.util.Element.selectNodes(xmlNode, this.self(arguments).XPATH_VALUES);
84 this.setValues(values[0]);
85 },
86 /**
87 * Get a given value inside the values map
88 * @param key {String} The key of the value
89 * @param specType {String} Expected type (currently "primitive" and "ref" are supported)
90 * @param specSubType {String} Expected subtype (depends on the type)
91 * @return {String} Value if it is set.
92 */
93 getValue: function(key, specType, specSubType){
94 var xpath;
95 if(specType == "primitive"){
96 xpath = 'slc:value[@key="'+key+'"]/slc:primitive-value[@type="'+specSubType+'"]';
97 }else if(specType == "ref"){
98 xpath = 'slc:value[@key="'+key+'"]/slc:ref-value/slc:label';
99 }
100 return org.argeo.ria.util.Element.getSingleNodeText(this.getValues(), xpath);
101 }
102 }
103
104 });