]> 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/Flow.js
Last XML updates
[gpl/argeo-slc.git] / org.argeo.slc.webapp / 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 * Name of the associated spec, to be found in the module
18 */
19 executionSpecName : {
20 check : "String"
21 },
22 /**
23 * Reference the actual ExecutionSpec object
24 */
25 executionSpec : {
26 check : "org.argeo.slc.ria.execution.Spec"
27 },
28 /**
29 * The values to init the ExecutionSpec
30 */
31 values : {
32 check : "Node"
33 },
34 /**
35 * Castor representation of the object
36 */
37 xmlNode : {
38 apply : "_applyXmlNode"
39 }
40 },
41
42 statics : {
43 /**
44 * Xpath to the name
45 */
46 XPATH_NAME : "@name",
47 /**
48 * XPath to the ExecutionSpec name
49 */
50 XPATH_EXEC_SPEC_NAME : "@executionSpec",
51 /**
52 * XPath to the values
53 */
54 XPATH_VALUES : "slc:values"
55 },
56
57 construct : function(){
58 this.base(arguments);
59 },
60
61 members : {
62 /**
63 * Init the object from an XML representation
64 * @param xmlNode {Node} Castor representation of this object
65 */
66 _applyXmlNode : function(xmlNode){
67 this.set({
68 name : org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_NAME),
69 executionSpecName : org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_EXEC_SPEC_NAME)
70 });
71 var values = org.argeo.ria.util.Element.selectNodes(xmlNode, this.self(arguments).XPATH_VALUES);
72 this.setValues(values[0]);
73 },
74 /**
75 * Get a given value inside the values map
76 * @param key {String} The key of the value
77 * @param specType {String} Expected type (currently "primitive" and "ref" are supported)
78 * @param specSubType {String} Expected subtype (depends on the type)
79 * @return {String} Value if it is set.
80 */
81 getValue: function(key, specType, specSubType){
82 var xpath;
83 if(specType == "primitive"){
84 xpath = 'slc:value[@key="'+key+'"]/slc:primitive-value[@type="'+specSubType+'"]';
85 }else if(specType == "ref"){
86 xpath = 'slc:value[@key="'+key+'"]/slc:ref-value/slc:label';
87 }
88 return org.argeo.ria.util.Element.getSingleNodeText(this.getValues(), xpath);
89 }
90 }
91
92 });