]>
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/BatchEntrySpec.js
2 * Data model for an entry of the Batch list : original Spec, flow and module, and currently computed value.
4 qx
.Class
.define("org.argeo.slc.ria.execution.BatchEntrySpec", {
5 extend
: org
.argeo
.slc
.ria
.execution
.Spec
,
17 * Original Spec (values shall stay untouched).
23 * Instance of BatchEntrySpec
24 * @param module {org.argeo.slc.ria.execution.Module} Reference module
25 * @param flow {org.argeo.slc.ria.execution.Flow} Reference flow
27 construct : function(module
, flow
, xmlElement
){
30 this.fromXml(xmlElement
);
32 this.setModule(module
);
34 this.setOriginalSpec(flow
.getExecutionSpec());
35 this.setName(flow
.getExecutionSpec().getName());
37 this.fetchInstanceValues();
42 * Create a label to display in the batch list.
43 * @return {String} The label
45 getLabel : function(){
46 var label
= this.getModule().getName();
47 label
+= "/" + this.getModule().getVersion();
48 label
+= "/" + this.getFlow().getName();
54 var values
= this.getValues();
55 for(var key
in values
){
56 if(values
[key
].getValue() == null && !values
[key
].isFrozen() && !values
[key
].isHidden()){
57 throw new Error("Cannot send empty values! (Parameter "+key
+")");
59 valuesXml
+= values
[key
].toValueXml();
61 var execFlowDescXML
= '<slc:execution-flow-descriptor name="'+this.getFlow().getName()+'" executionSpec="'+this.getName()+'">';
62 if(this.getFlow().getDescription()!=""){
63 execFlowDescXML
+= '<slc:description>'+this.getFlow().getDescription()+'</slc:description>';
65 execFlowDescXML
+= '<slc:values>'+valuesXml
+'</slc:values></slc:execution-flow-descriptor>';
67 var execSpecDescXML
= this.getOriginalSpec().toXml();
69 var moduleData
= this.getModule().moduleDataToXml();
71 return '<slc:realized-flow>'+moduleData
+ execFlowDescXML
+ execSpecDescXML
+'</slc:realized-flow>';
75 fromXml : function(xmlElement
){
76 var parser
= org
.argeo
.ria
.util
.Element
;
77 var simpleModule
= new org
.argeo
.slc
.ria
.execution
.Module();
78 simpleModule
.setName(parser
.getSingleNodeText(xmlElement
, "slc:module-name"));
79 simpleModule
.setVersion(parser
.getSingleNodeText(xmlElement
, "slc:module-version"));
80 this.setModule(simpleModule
);
82 var spec
= new org
.argeo
.slc
.ria
.execution
.Spec();
83 var flow
= new org
.argeo
.slc
.ria
.execution
.Flow();
84 spec
.setXmlNode(parser
.selectSingleNode(xmlElement
, "slc:default-execution-spec"));
85 flow
.setXmlNode(parser
.selectSingleNode(xmlElement
, "slc:execution-flow-descriptor"));
86 flow
.setExecutionSpec(spec
);
87 this.setOriginalSpec(spec
);
89 this.setName(spec
.getName());
94 * Fetch the Spec Values with the Flow Values to make the current instance value
96 fetchInstanceValues : function(){
97 var specValues
= this.getOriginalSpec().getValues();
98 var flow
= this.getFlow();
99 var instanceValues
= {};
100 for(var key
in specValues
){
101 var flowValue
= flow
.getValue(
103 specValues
[key
].getSpecType(),
104 specValues
[key
].getSpecSubType()
106 var instValue
= specValues
[key
].clone();
108 instValue
.setValue(flowValue
);
110 instanceValues
[key
] = instValue
;
112 this.setValues(instanceValues
);