]> 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/Value.js
Reopening Realized Flows (using a window caching for the moment)
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / argeo-ria-lib / slc / class / org / argeo / slc / ria / execution / Value.js
1 /**
2 * Wrapper for SlcValue object
3 */
4 qx.Class.define("org.argeo.slc.ria.execution.Value", {
5
6 extend : qx.core.Object,
7
8 properties : {
9 /**
10 * Name of this Execution Flow
11 */
12 key : {
13 check : "String",
14 init : ""
15 },
16 /**
17 * The type of this value, for the moment "primitive" and "ref" are supported
18 */
19 specType : {
20 check : "String",
21 init : ""
22 },
23 /**
24 * Subtype, depending on the "type".
25 */
26 specSubType : {
27 check : "String"
28 },
29 /**
30 * Whether it is a parameter or not
31 */
32 parameter : {
33 check : "Boolean"
34 },
35 /**
36 * Whether it is frozen on the server, i.e. disabled in the form
37 */
38 frozen : {
39 check : "Boolean"
40 },
41 /**
42 * Should not be editable nor seeable, thus hidden
43 */
44 hidden : {
45 check : "Boolean"
46 },
47 /**
48 * The real value
49 */
50 value : {
51 nullable : true
52 },
53 /**
54 * Castor representation of the object
55 */
56 xmlSpecNode : {
57 apply : "_applyXmlSpecNode"
58 },
59 refList : {
60 check : "Array"
61 }
62 },
63
64 statics : {
65 XPATH_KEY : "@key"
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 _applyXmlSpecNode : function(xmlNode){
78 this.setKey(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, "@key"));
79 var childs = xmlNode.childNodes;
80 for(var i=0;i<childs.length;i++){
81 var child = childs[i];
82 if(child.nodeType != 1) continue;
83 if(child.nodeName == "slc:primitive-spec-attribute"){
84 this.setSpecType("primitive");
85 this.setSpecSubType(org.argeo.ria.util.Element.getSingleNodeText(child, "@type")||"");
86 if(org.argeo.ria.util.Element.getSingleNodeText(child, ".")){
87 this.setValue(org.argeo.ria.util.Element.getSingleNodeText(child, "."));
88 }
89 }else if(child.nodeName == "slc:ref-spec-attribute"){
90 this.setSpecType("ref");
91 this.setSpecSubType(org.argeo.ria.util.Element.getSingleNodeText(child, "@targetClassName")||"");
92 var choices = org.argeo.ria.util.Element.selectNodes(child, "slc:choices/slc:ref-value-choice");
93 var refList = [];
94 for(var k=0;k<choices.length;k++){
95 var choice = choices[k];
96 var name = org.argeo.ria.util.Element.getSingleNodeText(choice, "@name");
97 var description = org.argeo.ria.util.Element.getSingleNodeText(choice, "slc:description");
98 refList.push([name, (description||"")]);
99 }
100 this.setRefList(refList);
101 }
102 this.set({
103 parameter : (org.argeo.ria.util.Element.getSingleNodeText(child, "@isParameter")=="true"?true:false),
104 frozen : (org.argeo.ria.util.Element.getSingleNodeText(child, "@isFrozen")=="true"?true:false),
105 hidden : (org.argeo.ria.util.Element.getSingleNodeText(child, "@isHidden")=="true"?true:false)
106 });
107 }
108 },
109
110 toValueXml : function(){
111 var valueTag = '';
112 var specAttribute = '';
113 if(this.getSpecType() == "primitive"){
114 valueTag = this.getValue();
115 specAttribute = '<slc:primitive-value type="'+this.getSpecSubType()+'">'+valueTag+'</slc:primitive-value>';
116 }else if(this.getSpecType() == "ref"){
117 specAttribute = '<slc:ref-value ref="'+this.getValue()+'" type="beanName" />';
118 }
119 return '<slc:value key="'+this.getKey()+'">'+specAttribute+'</slc:value>';
120 }
121 }
122
123 });