]> 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
New icons for the tree
[gpl/argeo-slc.git] / server / org.argeo.slc.ria / src / argeo-ria-lib / slc / class / org / argeo / slc / ria / execution / BatchEntrySpec.js
1 /**
2 * Data model for an entry of the Batch list : original Spec, flow and module, and currently computed value.
3 */
4 qx.Class.define("org.argeo.slc.ria.execution.BatchEntrySpec", {
5 extend : org.argeo.slc.ria.execution.Spec,
6
7 properties : {
8 /**
9 * Reference module
10 */
11 module :{},
12 /**
13 * Reference flow
14 */
15 flow : {},
16 /**
17 * Original Spec (values shall stay untouched).
18 */
19 originalSpec : {}
20 },
21
22 /**
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
26 */
27 construct : function(module, flow){
28 this.base(arguments);
29 this.setModule(module);
30 this.setFlow(flow);
31 this.setOriginalSpec(flow.getExecutionSpec());
32 this.setName(flow.getExecutionSpec().getName());
33 this.fetchInstanceValues();
34 },
35
36 members : {
37 /**
38 * Create a label to display in the batch list.
39 * @return {String} The label
40 */
41 getLabel : function(){
42 var label = this.getModule().getName();
43 label += "/" + this.getModule().getVersion();
44 label += "/" + this.getFlow().getName();
45 return label;
46 },
47
48 toXml : function(){
49 var valuesXml = '';
50 var values = this.getValues();
51 for(var key in values){
52 valuesXml += values[key].toValueXml();
53 }
54 var execFlowDescXML = '<slc:execution-flow-descriptor name="'+this.getFlow().getName()+'" executionSpec="'+this.getName()+'"><slc:values>'+valuesXml+'</slc:values></slc:execution-flow-descriptor>';
55
56 var execSpecDescXML = this.getOriginalSpec().toXml();
57
58 var moduleData = '<slc:module-name>'+this.getModule().getName()+'</slc:module-name><slc:module-version>'+this.getModule().getVersion()+'</slc:module-version>';
59
60 return '<slc:realized-flow>'+moduleData + execFlowDescXML + execSpecDescXML +'</slc:realized-flow>';
61
62 },
63
64 /**
65 * Fetch the Spec Values with the Flow Values to make the current instance value
66 */
67 fetchInstanceValues : function(){
68 var specValues = this.getOriginalSpec().getValues();
69 var flow = this.getFlow();
70 var instanceValues = {};
71 for(var key in specValues){
72 var flowValue = flow.getValue(
73 key,
74 specValues[key].getSpecType(),
75 specValues[key].getSpecSubType()
76 );
77 var instValue = specValues[key].clone();
78 if(flowValue){
79 instValue.setValue(flowValue);
80 }
81 instanceValues[key] = instValue;
82 }
83 this.setValues(instanceValues);
84 //this.debug(instanceValues);
85 }
86 }
87 });