]>
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/SlcExecutionMessage.js
c9194f7f3eedce9d70747d5c1c02d2d87e4d6d3a
2 * A generic JMS slcExecution message encapsulator.
4 qx
.Class
.define("org.argeo.slc.ria.SlcExecutionMessage", {
5 extend
: qx
.core
.Object
,
6 construct : function(uuid
){
12 var itoh
= '0123456789ABCDEF';
13 for (var i
= 0; i
<36; i
++) s
[i
] = Math
.floor(Math
.random()*0x10);
14 s
[14] = 4; // Set 4 high bits of time_high field to version
15 s
[19] = (s
[19] & 0x3) | 0x8; // Specify 2 high bits of clock sequence
16 for (var i
= 0; i
<36; i
++) s
[i
] = itoh
[s
[i
]];
17 s
[8] = s
[13] = s
[18] = s
[23] = '-';
18 this.setUuid(s
.join('').toLowerCase());
20 this.setAttributes({});
24 * The unique id identifying the message
59 init
: new Date().toString()
62 * Additionnal attributes as map of key/values
70 addAttribute: function(attName
, attValue
){
71 var attr
= this.getAttributes();
72 attr
[attName
] = attValue
;
73 this.setAttributes(attr
);
76 * Build the xml formatted message body to send
78 * @return {String} The message content as Xml
81 var builder
= new qx
.util
.StringBuilder();
82 builder
.add('<slc:slc-execution xmlns:slc="http://argeo.org/projects/slc/schemas" uuid="'+this.getUuid()+'">');
83 builder
.add('<slc:status>'+this.getStatus()+'</slc:status>');
84 builder
.add('<slc:type>'+this.getType()+'</slc:type>');
85 builder
.add('<slc:host>'+this.getHost()+'</slc:host>');
86 builder
.add('<slc:user>'+this.getUser()+'</slc:user>');
87 var attr
= this.getAttributes();
88 if(qx
.lang
.Object
.getLength(attr
)){
89 builder
.add('<slc:attributes>');
91 builder
.add('<slc:attribute name="'+key
+'">'+attr
[key
]+'</slc:attribute>');
93 builder
.add('</slc:attributes>');
95 builder
.add('</slc:slc-execution>');
99 fromXml : function(slcExecXml
){
100 var NSMap
= {slc
:"http://argeo.org/projects/slc/schemas"};
101 this.setStatus(org
.argeo
.ria
.util
.Element
.getSingleNodeText(slcExecXml
, "slc:status", NSMap
));
102 this.setType(org
.argeo
.ria
.util
.Element
.getSingleNodeText(slcExecXml
, "slc:type", NSMap
));
103 this.setHost(org
.argeo
.ria
.util
.Element
.getSingleNodeText(slcExecXml
, "slc:host", NSMap
));
104 this.setUser(org
.argeo
.ria
.util
.Element
.getSingleNodeText(slcExecXml
, "slc:user", NSMap
));
105 var attributes
= org
.argeo
.ria
.util
.Element
.selectNodes(slcExecXml
, "slc:attribute", NSMap
);
106 for(var i
=0;i
<attributes
.length
;i
++){
107 this.addAttribute(attribute
.getAttribute("name"), attribute
.firstChild
);
109 var stepsDates
= org
.argeo
.ria
.util
.Element
.selectNodes(slcExecXml
, "slc:steps/slc:slc-execution-step/slc:begin", NSMap
);
110 if(stepsDates
.length
){
111 this.setDate(org
.argeo
.ria
.util
.Element
.getSingleNodeText(stepsDates
[stepsDates
.length
-1], ".", NSMap
));