]>
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/Value.js
2 * Wrapper for SlcValue object
4 qx
.Class
.define("org.argeo.slc.ria.execution.Value", {
6 extend
: qx
.core
.Object
,
10 * Name of this Execution Flow
17 * The type of this value, for the moment "primitive" and "ref" are supported
24 * Subtype, depending on the "type".
30 * Whether it is a parameter or not
36 * Whether it is frozen on the server, i.e. disabled in the form
42 * Should not be editable nor seeable, thus hidden
54 * Castor representation of the object
57 apply
: "_applyXmlSpecNode"
65 construct : function(){
71 * Init the object from an XML representation
72 * @param xmlNode {Node} Castor representation of this object
74 _applyXmlSpecNode : function(xmlNode
){
75 this.setKey(org
.argeo
.ria
.util
.Element
.getSingleNodeText(xmlNode
, "@key"));
76 var childs
= xmlNode
.childNodes
;
77 for(var i
=0;i
<childs
.length
;i
++){
78 var child
= childs
[i
];
79 if(child
.nodeType
!= 1) continue;
80 if(child
.nodeName
== "slc:primitive-spec-attribute"){
81 this.setSpecType("primitive");
82 this.setSpecSubType(org
.argeo
.ria
.util
.Element
.getSingleNodeText(child
, "@type"));
83 if(org
.argeo
.ria
.util
.Element
.getSingleNodeText(child
, ".")){
84 this.setValue(org
.argeo
.ria
.util
.Element
.getSingleNodeText(child
, "."));
86 }else if(child
.nodeName
== "slc:ref-spec-attribute"){
87 this.setSpecType("ref");
88 this.setSpecSubType(org
.argeo
.ria
.util
.Element
.getSingleNodeText(child
, "@targetClassName"));
91 parameter
: (org
.argeo
.ria
.util
.Element
.getSingleNodeText(child
, "@isParameter")=="true"?true:false),
92 frozen
: (org
.argeo
.ria
.util
.Element
.getSingleNodeText(child
, "@isFrozen")=="true"?true:false),
93 hidden
: (org
.argeo
.ria
.util
.Element
.getSingleNodeText(child
, "@isHidden")=="true"?true:false)
99 * Create an XML Representation of this value
100 * @return {String} The XML String
102 toAttributeXml : function(){
104 var specAttribute
= '';
105 if(this.getSpecType() == "primitive"){
106 valueTag
= (this.getValue()?this.getValue():'');
107 specAttribute
= '<slc:primitive-spec-attribute isParameter="'+(this.getParameter()?"true":"false")+'" isFrozen="'+(this.getFrozen()?"true":"false")+'" isHidden="'+(this.getHidden()?"true":"false")+'" type="'+this.getSpecSubType()+'">'+valueTag
+'</slc:primitive-spec-attribute>';
108 }else if(this.getSpecType() == "ref"){
109 valueTag
= (this.getValue()?'<slc:label>'+this.getValue()+'</slc:label>':'');
110 specAttribute
= '<slc:ref-spec-attribute isParameter="'+(this.getParameter()?"true":"false")+'" isFrozen="'+(this.getFrozen()?"true":"false")+'" isHidden="'+(this.getHidden()?"true":"false")+'" targetClassName="'+this.getSpecSubType()+'">'+valueTag
+'</slc:ref-spec-attribute>';
112 return '<slc:value key="'+this.getKey()+'">'+specAttribute
+'</slc:value>';
115 toValueXml : function(){
117 var specAttribute
= '';
118 if(this.getSpecType() == "primitive"){
119 valueTag
= this.getValue();
120 specAttribute
= '<slc:primitive-value type="'+this.getSpecSubType()+'">'+valueTag
+'</slc:primitive-value>';
121 }else if(this.getSpecType() == "ref"){
122 valueTag
= '<slc:label>'+this.getValue()+'</slc:label>';
123 specAttribute
= '<slc:ref-value >'+valueTag
+'</slc:ref-value>';
125 return '<slc:value key="'+this.getKey()+'">'+specAttribute
+'</slc:value>';