]> 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/Spec.js
Move to src
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / argeo-ria-lib / slc / class / org / argeo / slc / ria / execution / Spec.js
1 /**
2 * Wrapper for ExecutionSpec server object
3 */
4 qx.Class.define("org.argeo.slc.ria.execution.Spec", {
5
6 extend : qx.core.Object,
7
8 properties : {
9 /**
10 * Unique name of this spec
11 */
12 name : {
13 check : "String",
14 init : ""
15 },
16 /**
17 * Defined parameters
18 */
19 values : {
20 check : "Map"
21 },
22 /**
23 * Castor representation of this object
24 */
25 xmlNode : {
26 apply : "_applyXmlNode"
27 }
28 },
29
30 statics : {
31 XPATH_NAME : "@name",
32 XPATH_VALUES : "slc:values/slc:value"
33 },
34
35 construct : function(){
36 this.base(arguments);
37 this.setValues({});
38 },
39
40 members : {
41 /**
42 * Init the object from an XML representation
43 * @param xmlNode {Node} Castor representation of this object
44 */
45 _applyXmlNode : function(xmlNode){
46 // Parse now
47 this.setName(org.argeo.ria.util.Element.getSingleNodeText(xmlNode, this.self(arguments).XPATH_NAME));
48 var values = org.argeo.ria.util.Element.selectNodes(xmlNode, this.self(arguments).XPATH_VALUES);
49 var parsedValues = {};
50 for(var i=0;i<values.length;i++){
51 //var valueNode = values[i];
52 var value = new org.argeo.slc.ria.execution.Value();
53 value.setXmlSpecNode(values[i]);
54 parsedValues[value.getKey()] = value;
55 }
56 this.setValues(parsedValues);
57 },
58 /**
59 * XML Representation of this object.
60 * @return {String} An XML String
61 */
62 toXml : function(){
63 var valuesXml = '';
64 var values = this.getValues();
65 for(var key in values){
66 valuesXml += values[key].toAttributeXml();
67 }
68 return '<slc:default-execution-spec name="'+this.getName()+'"><slc:values>'+valuesXml+'</slc:values></slc:default-execution-spec>';
69 }
70 }
71
72 });