blob: e99d649558883f72ce2de99b0fd9c8f060e0f461 [file] [log] [blame]
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -09001function getDgStartNode(nodeList){
2 for(var i=0;i<nodeList.length;i++){
3 if(nodeList[i].type == 'dgstart' && nodeList[i].wires != null && nodeList[i].wires != undefined){
4 return nodeList[i];
5 }
6 }
7 RED.notify("DGSTART node not found.");
8 return null;
9}
10
11
12var loopDetectionEnabled = true;
13
14function detectLoopPrev(){
15 var activeWorkspace=RED.view.getWorkspace();
16 /*
17 RED.nodes.links.filter(function(d) {
18 if(d.source.z == activeWorkspace && d.target.z == activeWorkspace){
19 console.log(d.source.id+":"+d.sourcePort+":"+d.target.id);
20 }
21 });
22 */
23 //console.dir(RED.nodes.links);
24 var nSet=[];
25
26 RED.nodes.eachNode(function(n) {
27 if (n.z == activeWorkspace) {
28 nSet.push({'n':n});
29 }
30 });
31
32 var nodeSet = RED.nodes.createExportableNodeSet(nSet);
33 //console.dir(nodeSet);
34
35 //console.log("nodeSet length:" + nodeSet.length);
36
37 var isLoopDetected = false;
38 var dgStartNode = getDgStartNode(nodeSet);
39 if(dgStartNode == null || dgStartNode == undefined) {
40 console.log("dgstart node not linked.");
41 return true;
42 }
43
44 var wires = dgStartNode.wires;
45 var nodesInPath = {};
46 var dgStartNodeId = dgStartNode.id;
47 if(wires != null && wires != undefined && wires[0] != undefined){
48 for(var k=0;k<wires[0].length;k++){
49 var val = wires[0][k];
50 nodesInPath[dgStartNodeId + "->" + val] = "";
51 }
52 }else{
53 nodesInPath[dgStartNodeId + "->" + ""] = "";
54 }
55
56 //console.dir(nodesInPath);
57 var loopDetectedObj = {};
58 /* the nodes will not be order so will need to loop thru again */
59 for(var m=0;nodeSet != null && m<nodeSet.length;m++){
60 for(var i=0;nodeSet != null && i<nodeSet.length;i++){
61 var link=nodeSet[i].id;
62 //console.log("NAME:" + nodeSet[i].name + ":" + link);
63 if(link == dgStartNodeId) continue;
64 var wires = nodeSet[i].wires;
65 //console.log("link:" + link);
66 var delKeys = [];
67 if(wires != null && wires != undefined && wires[0] != undefined){
68 for(var k=0;k<wires[0].length;k++){
69 var val = (wires[0])[k];
70 var keys = Object.keys(nodesInPath);
71 //console.log("keys:" + keys);
72 for (var j=0;j<keys.length;j++){
73 //console.log("key:" + keys[j]);
74 //console.log("val:" + val);
75 var index = -1;
76 if(keys[j] != null){
77 index = keys[j].indexOf("->" + link);
78 }
79 var lastIndex = keys[j].lastIndexOf("->");
80 if(index != -1 && index == lastIndex){
81 //delete nodesInPath[key];
82 var previousNodeId = keys[j].substr(lastIndex +2);
83 var indexOfArrow = -1;
84 if(previousNodeId != ""){
85 indexOfArrow = previousNodeId.indexOf("->");
86 }
87 if(previousNodeId != null && indexOfArrow != -1){
88 previousNodeId = previousNodeId.substr(0,indexOfArrow);
89 }
90 nodesInPath[keys[j] + "->" + val] = "";
91 //console.log("keys[j]:" + keys[j]);
92 delKeys.push(keys[j]);
93 var prevNodeIdIndex = keys[j].indexOf("->" + previousNodeId);
94 var priorOccurence = keys[j].indexOf(val + "->");
95 if(priorOccurence != -1 && priorOccurence<prevNodeIdIndex){
96 //console.log("previousNodeId:" + previousNodeId);
97 //console.log("val:" + val);
98 var n1 = getNode(nodeSet,previousNodeId);
99 var n2 = getNode(nodeSet,val);
100 //console.log("loop detected for node " + n1.name + " and " + n2.name);
101 loopDetectedObj[n1.name + "->" + n2.name] ="looped";
102 //console.dir(loopDetectedObj);
103 isLoopDetected = true;
104 }
105 }
106 }
107 }
108 }
109 for(var l=0;delKeys != null && l<delKeys.length;l++){
110 delete nodesInPath[delKeys[l]];
111 }
112 }
113
114
115 }
116 if(loopDetectedObj != null ){
117 var msg = "";
118 for(var key in loopDetectedObj){
119 if(loopDetectedObj.hasOwnProperty(key)) {
120 console.log("Loop detected " + key);
121 msg += "<strong>Loop detected for:" + key + "</strong><br>";
122 }
123 }
124 if(msg != ""){
125 isLoopDetected = true;
126 RED.notify(msg);
127 }
128 }
129/*
130 for(var i=0;nodeSet != null && i<nodeSet.length;i++){
131 var foundCount=0;
132 var nodeId = nodeSet[i].id;
133 var nodeName = nodeSet[i].name;
134 for(var j=0;nodeSet != null && j<nodeSet.length;j++){
135 var node = nodeSet[j];
136 if(node.id == nodeId){
137 continue;
138 }
139 var wires = node.wires;
140 console.log(node.type + ":wires:" + wires);
141 for(var k=0;wires != null && wires != undefined && wires[0] != undefined && k<wires[0].length;k++){
142 var id = (wires[0])[k];
143 console.log(nodeName + ":" + nodeId + ":" + id);
144 if(id == nodeId ){
145 foundCount++;
146 if(foundCount>1){
147 console.log("Loop detected for node " + nodeName + "with node:" + node.name);
148 RED.notify("<strong>Flow error detected for node '" + nodeName + "' with node '" + node.name + "'</strong>");
149 //RED.nodes.eachLink(function(d){
150 // if(d.source.id == nodeSet[i] || d.target.id == nodeSet[j]){
151 // d.selected = true;
152 // }else if(d.source.id == nodeSet[j] || d.target.id == nodeSet[i]){
153 // d.selected = true;
154 // }
155 //});
156 //RED.view.redraw();
157 isLoopDetected = true;
158 return true;
159 }
160 }
161 }
162
163 }
164 }
165*/
166 //console.log("isLoopDetected:" + isLoopDetected);
167 return isLoopDetected;
168}
169
170function generateNodePath(nodeIdToNodeObj,nodeId,pathStr,nodesInPath,errList){
171 var node = nodeIdToNodeObj[nodeId];
172 var wires = node.wires;
173 if(wires != null && wires != undefined && wires[0] != undefined){
174 for(var k=0;k<wires[0].length;k++){
175 var val = wires[0][k];
176 if(pathStr.indexOf(val + "->") != -1){
177 //console.log("pathStr:" + pathStr);
178 var n1= nodeIdToNodeObj[nodeId].name;
179 var n2= nodeIdToNodeObj[val].name;
180 errList.push("Loop detected between nodes '" + n1 + "' and " + "'" + n2 + "'");
181 }else{
182 pathStr += "->" + val ;
183 generateNodePath(nodeIdToNodeObj,val,pathStr,nodesInPath,errList);
184 }
185 }
186 }else{
187 //pathStr += nodeId + "->" + "";
188 nodesInPath.push(pathStr);
189 }
190}
191
192function detectLoop(){
193 var activeWorkspace=RED.view.getWorkspace();
194 var nSet=[];
195 var nodeIdToNodeObj = {};
196 RED.nodes.eachNode(function(n) {
197 if (n.z == activeWorkspace) {
198 nSet.push({'n':n});
199 }
200 });
201
202 var nodeSet = RED.nodes.createExportableNodeSet(nSet);
203 nodeIdToNodeObj = getNodeIdToNodeMap(nodeSet);
204 var isLoopDetected = false;
205 //var dgStartNode = getDgStartNode(nodeSet);
206 var dgStartNode = nodeIdToNodeObj["dgstart"];
207 var errList = [];
208 var dgStartNodeId = dgStartNode.id;
209 var nodesInPathArr = [];
210 generateNodePath(nodeIdToNodeObj,dgStartNodeId,dgStartNodeId,nodesInPathArr,errList);
211 if(errList != null && errList != undefined && errList.length > 0){
212 isLoopDetected = true;
213 var htmlStr="<div id='loop-detect-err-list-div'><table id='loopErrListTable' border='1'><tr><th>Error List</th></tr>";
214 for(var j=0;errList != null && j<errList.length;j++){
215 var errSeq = j+1;
216 htmlStr += "<tr><td>" + errSeq + ")" + errList[j] + "</td></tr>";
217 }
218 htmlStr += "</table></div>";
219
220 $("#loop-detection-dialog").dialog({
221 autoOpen : false,
222 modal: true,
223 title: "DG Flow validation Error List ",
224 width: 500,
225 buttons: {
226 Close: function () {
227 $("#loop-detection-dialog").dialog("close");
228 }
229 }
230 }).dialog("open").html(htmlStr); // end dialog div
231 }
232 nodesInPathArr=null;
233 nodeSet ={};
234 nodeIdToNodeObj={};
235 return isLoopDetected;
236}
237
238
239var xmlNumberCnt = 0;
240function processForXmlNumbers(nodeSet,node){
241 if( node != null && node.type != 'dgstart'){
242 if(node.xmlnumber != null && node.xmlnumber){
243 node.xmlnumber.push(++xmlNumberCnt);
244 }else{
245 node.xmlnumber = [++xmlNumberCnt];
246 }
247 }
248
249 if(node != null && node.wires != null && node.wires.length>0){
250 var wiredNodes=node.wires[0];
251 var wiredNodesArr=[];
252 for(var k=0;wiredNodes != undefined && wiredNodes != null && k<wiredNodes.length;k++){
253 wiredNodesArr.push(getNode(nodeSet,wiredNodes[k]));
254 }
255
256 //use this sort to sort by y position
257 wiredNodesArr.sort(function(a, b){
258 return a.y-b.y;
259 });
260
261 for(var k=0;k<wiredNodesArr.length;k++){
262 var n = wiredNodesArr[k];
263 processForXmlNumbers(nodeSet,n);
264 }
265 }
266}
267
268function updateXmlNumbers(){
269 xmlNumberCnt = 0;
270 var nodeSet = getCurrentFlowNodeSet();
271 if(nodeSet == null && nodeSet.length >0){
272 nodeSet.forEach(function(n){
273 if(n.xmlnumber){
274 delete n.xmlnumber;
275 }
276 });
277 }
278 var dgStartNode = getDgStartNode(nodeSet);
279 processForXmlNumbers(nodeSet,dgStartNode);
280 var activeWorkspace=RED.view.getWorkspace();
281 RED.nodes.eachNode(function(n) {
282 //console.log("Node processed in eachNode");
283 if (n.z == activeWorkspace) {
284 if(n != null){
285 var updatedNode = getNode(nodeSet,n.id);
286 //console.log("updated Node processed in eachNode");
287 //console.dir(updatedNode);
288
289 if (n.id == updatedNode.id) {
290 n.xmlnumber = updatedNode.xmlnumber;
291 n.dirty = true;
292 }
293 }
294 }
295 });
296}
297
298function getOutcomeValue(node){
299 var xmlStr = "";
300 if(node != null && node.xml != undefined && node.xml !=""){
301 xmlStr = node.xml + "</outcome>";
302 }
303 var xmlDoc;
304 if (window.DOMParser){
305 try{
306 var parser=new DOMParser();
307 xmlDoc=parser.parseFromString(xmlStr,'text/xml');
308 //console.log("Not IE");
309 var n = xmlDoc.documentElement.nodeName;
310 if(n == "html"){
311 resp=false;
312 console.log("Error parsing");
313 return resp;
314 }
315 }catch(e){
316 console.log("xmlStr:" + xmlStr);
317 console.log("Error parsing" +e);
318 return null;
319 }
320 }else{
321 try{
322 //console.log("IE");
323 // code for IE
324 xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
325 xmlDoc.async=false;
326 xmlDoc.loadXMLString(xmlStr);
327 }catch(e){
328 console.log("xmlStr:" + xmlStr);
329 console.log("Error parsing" +e);
330 return null;
331 }
332 }
333 if(xmlDoc != null){
334 var xmlNode = xmlDoc.documentElement;
335 //console.dir(xmlNode);
336 var processedNode = xmlNode.nodeName;
337 //console.log("processedNode:" + processedNode);
338 var attrs = xmlNode.attributes;
339 for(var i=0;i<attrs.length;i++){
340 if(attrs[i].nodeName == "value"){
341 return attrs[i].value;
342 }
343 }
344 }
345 return null;
346}
347
348var dgNumberCnt = 0;
349function processForDgNumbers(nodeSet,node){
350 var outcomeTypes = [ "already-active", "failure", "not-found", "other", "outcomeFalse", "outcome", "outcomeTrue", "success" ];
351 if( node != null && node.type != 'dgstart' && node.type != 'service-logic' && node.type != 'method' ){
352 //console.log("child of " + parentNodeType + " :" + nodeType);
353 //check if NOT outcome node
354 if(outcomeTypes.indexOf(node.type) == -1){
355 if(node.type == "GenericXML"){
356 if(node.xml != undefined && node.xml != null && node.xml.indexOf("<outcome ") != -1){
357 //this GenericXML node is used for outcome , so need to skip
358 }else{
359 if(node.dgnumber != undefined && node.dgnumber != null && node.dgnumber){
360 node.dgnumber.push(++dgNumberCnt);
361 }else{
362 node.dgnumber = [++dgNumberCnt];
363 }
364 }
365
366 }else{
367 if(node.dgnumber != undefined && node.dgnumber != null && node.dgnumber){
368 node.dgnumber.push(++dgNumberCnt);
369 }else{
370 node.dgnumber = [++dgNumberCnt];
371 }
372 }
373 }
374 }
375
376 var hasOutcomeNodes = false;
377 if(node != null && node.wires != null && node.wires.length>0){
378 var wiredNodes=node.wires[0];
379 var wiredNodesArr=[];
380 for(var k=0;wiredNodes != undefined && wiredNodes != null && k<wiredNodes.length;k++){
381 var wiredNode = getNode(nodeSet,wiredNodes[k]);
382 //check if outcome node
383 if(outcomeTypes.indexOf(wiredNode.type) != -1){
384 hasOutcomeNodes = true;
385 }
386 if(wiredNode.type == "GenericXML"){
387 if( node.xml != undefined && node.xml != null && node.xml.indexOf("<outcome ") != -1){
388 //this GenericXML node is used for outcome
389 hasOutcomeNodes = true;
390 }
391 }
392 wiredNodesArr.push(wiredNode);
393
394 }
395
396 //use this sort to sort by y position
397 wiredNodesArr.sort(function(a, b){
398 return a.y-b.y;
399 });
400
401 /*
402 //USE THIS LOGIC TO SORT BY OUTCOME VALUE FOR SPECIFIC NODES
403 var parentNodeType = node.type;
404 if(hasOutcomeNodes && parentNodeType != 'switchNode' && parentNodeType != 'block' && parentNodeType != 'configure' ){
405 //use the value of outcome to sort the wired nodes
406 wiredNodesArr.sort(function(a, b){
407 var val1 = getOutcomeValue(a);
408 var val2 = getOutcomeValue(b);
409 //console.log("val1:" + val1);
410 //console.log("val2:" + val2);
411 if ( val1 < val2 ){
412 return -1;
413 }else if ( val1 > val2 ){
414 return 1;
415 }else{
416 return 0;
417 }
418 });
419 }else{
420 //use this sort to sort by y position
421 wiredNodesArr.sort(function(a, b){
422 return a.y-b.y;
423 });
424 }
425
426 */
427
428 for(var k=0;k<wiredNodesArr.length;k++){
429 var n = wiredNodesArr[k];
430 processForDgNumbers(nodeSet,n);
431 }
432 }
433}
434
435function updateDgNumbers(){
436 dgNumberCnt = 0;
437 var nodeSet = getCurrentFlowNodeSet();
438 if(nodeSet == null && nodeSet.length >0){
439 nodeSet.forEach(function(n){
440 if(n.dgnumber){
441 delete n.dgnumber;
442 }
443 });
444 }
445 var dgStartNode = getDgStartNode(nodeSet);
446 processForDgNumbers(nodeSet,dgStartNode);
447 var activeWorkspace=RED.view.getWorkspace();
448 RED.nodes.eachNode(function(n) {
449 //console.log("Node processed in eachNode");
450 if (n.z == activeWorkspace) {
451 if(n != null){
452 var updatedNode = getNode(nodeSet,n.id);
453 //console.log("updated Node processed in eachNode");
454 //console.dir(updatedNode);
455
456 if (n.id == updatedNode.id) {
457 //console.log(n.type + ":" + updatedNode.dgnumber);
458 n.dgnumber = updatedNode.dgnumber;
459 n.dirty = true;
460 }
461 }
462 }
463 });
464 return nodeSet;
465}
466
467function customValidation(currNodeSet){
468 //validation to make sure there a block node infront of mutiple dgelogic nodes
469 flowDesignErrors=[];
470 var dgStartCnt=0;
471 var serviceLogicCnt=0;
472 var methodCnt=0;
473 for(var i=0;currNodeSet != null && i<currNodeSet.length;i++){
474 var node = currNodeSet[i];
475 var parentNodeName = node.name;
476 var parentNodeType = node.type;
477 var dgNumber = node.dgnumber;
478 if(parentNodeType == 'dgstart'){
479 dgStartCnt++;
480 }
481 if(parentNodeType == 'service-logic'){
482 serviceLogicCnt++;
483 }
484 if(parentNodeType == 'method'){
485 methodCnt++;
486 }
487 if(parentNodeType == "GenericXML"){
488 if( node.xml != undefined && node.xml != null && node.xml.indexOf("<service-logic ") != -1 ){
489 //this GenericXML node is used for service-logic
490 serviceLogicCnt++;
491 }else if( node.xml != undefined && node.xml != null && node.xml.indexOf("<method ") != -1 ){
492 //this GenericXML node is used for method
493 methodCnt++;
494 }else if( node.xml != undefined && node.xml != null && node.xml.indexOf("<block") != -1 ){
495 //this GenericXML node is used for block
496 parentNodeType = "block";
497 }
498 }
499 if(node != null && node.wires != null && node.wires.length>0){
500 var wiredNodes=node.wires[0];
501 var wiredNodesArr=[];
502 for(var k=0;wiredNodes != undefined && wiredNodes != null && k<wiredNodes.length;k++){
503 wiredNodesArr.push(getNode(currNodeSet,wiredNodes[k]));
504 }
505 var countChildLogicNodes =0;
506 for(var k=0;k<wiredNodesArr.length;k++){
507 var n = wiredNodesArr[k];
508 var nodeType = n.type;
509 var outcomeTypes = [ "already-active", "failure", "not-found", "other", "outcomeFalse", "outcome", "outcomeTrue", "success" ];
510 var isOutcomeOrSetNode = false;
511 if(nodeType == "GenericXML"){
512 if( n.xml != undefined && n.xml != null && (n.xml.indexOf("<outcome ") != -1 || n.xml.indexOf("<set ") != -1)){
513 //this GenericXML node is used for outcome
514 isOutcomeOrSetNode = true;
515 }
516 }
517 //console.log("child of " + parentNodeType + " :" + nodeType);
518 if(outcomeTypes.indexOf(nodeType) > -1 ||nodeType == 'set' || isOutcomeOrSetNode){
519 //its a outcome or set node
520 }else{
521 countChildLogicNodes++;
522 }
523
524 //console.log("parentNodeType:" + parentNodeType);
525 if(countChildLogicNodes >1 && parentNodeType != 'block' && parentNodeType != 'for' ){
526 if(node.dgnumber != undefined && node.dgnumber){
527 flowDesignErrors.push("Warning:May need a block Node after Node. <br><span style='color:red'>Node Name:</span>" + node.name + "<br><span style='color:red'>DG Number:</span>" + node.dgnumber[0] );
528 }else{
529 flowDesignErrors.push("Warning:May need a block Node after Node <br><span style='color:red'>Node name:</span>" + parentNodeName);
530 }
531 break;
532 }
533 }
534 }
535 }
536 if(dgStartCnt > 1){
537 flowDesignErrors.push("Error:There should only be 1 dgstart Node in the current workspace.");
538 }
539
540 if(serviceLogicCnt > 1){
541 flowDesignErrors.push("Error:There should only be 1 service-logic Node in the current workspace.");
542 }
543
544 if(methodCnt > 1){
545 flowDesignErrors.push("Error:There should only be 1 method Node in the current workspace.");
546 }
547
548 if(flowDesignErrors != null && flowDesignErrors.length >0){
549 return false;
550 }
551 return true;
552}
553
554var flowDesignErrors = [];
555function showFlowDesignErrorBox(){
556 if(flowDesignErrors != null && flowDesignErrors.length >0){
557 var htmlStr="<div id='flowpath-err-list-div'><table id='fpeTable' border='1'><tr><th>Error List</th></tr>";
558 for(var j=0;flowDesignErrors != null && j<flowDesignErrors.length;j++){
559 var errSeq = j+1;
560 htmlStr += "<tr><td>" + errSeq + ")" + flowDesignErrors[j] + "</td></tr>";
561 }
562 htmlStr += "</table></div>";
563
564 //$('<div></div>').dialog({
565
566 $('#flow-design-err-dialog').dialog({
567 modal: true,
568 title: "Flow design Error List ",
569 width: 500,
570 /*open: function () {
571 $(this).html(htmlStr);
572 },*/
573 buttons: {
574 Close: function () {
575 $(this).dialog("close");
576 }
577 }
578 }).html(htmlStr); // end dialog div
579 }
580}
581
582
583function getCurrentFlowNodeSet(){
584 var nodeSet=[];
585 //console.dir(RED);
586 //RED.view.dirty();
587 //RED.view.redraw();
588 var activeWorkspace=RED.view.getWorkspace();
589 RED.nodes.eachNode(function(n) {
590 if (n.z == activeWorkspace) {
591 nodeSet.push({'n':n});
592 }
593 });
594
595 var exportableNodeSet = RED.nodes.createExportableNodeSet(nodeSet);
596 //console.dir(exportableNodeSet);
597 //console.log(JSON.stringify(exportableNodeSet));
598 return exportableNodeSet;
599}
600
601function getNode(nodeSet,id){
602 for(var i=0;i<nodeSet.length;i++){
603 if(nodeSet[i].id == id){
604 return nodeSet[i];
605 }
606 }
607 return null;
608}
609function getNodeIdToNodeMap(nodeSet){
610 var nodeIdToNodeMap ={};
611 for(var i=0;i<nodeSet.length;i++){
612 nodeIdToNodeMap[nodeSet[i].id] = nodeSet[i];
613 if(nodeSet[i].type == "dgstart"){
614 nodeIdToNodeMap["dgstart"] = nodeSet[i];
615 }
616 }
617 return nodeIdToNodeMap;
618}
619
620function validateEachNodeXml(){
621 var activeWorkspace=RED.view.getWorkspace();
622 RED.nodes.eachNode(function(n) {
623 if (n.z == activeWorkspace) {
624 var xml = n.xml;
625 if( xml != null && xml != ''){
626 var validationSuccess = validateXML(n.xml);
627 if(validationSuccess){
628 n.status = {fill:"green",shape:"dot",text:"OK"};
629 }else{
630 n.status = {fill:"red",shape:"dot",text:"ERROR"};
631 }
632 }
633 }
634 });
635}
636
637
638function getNodeToXml(inputNodeSet){
639 var exportableNodeSet;
640 //uses inputNodeSet if passed otherwise build the latest nodeSet
641
642 //$("#btn-deploy").removeClass("disabled");
643
644
645 function getNode(id){
646 for(var i=0;i<exportableNodeSet.length;i++){
647 if(exportableNodeSet[i].id == id){
648 return exportableNodeSet[i];
649 }
650 }
651 return null;
652 }
653
654 function getStartTag(node){
655 var startTag="";
656 var xmlStr="";
657 if(node != null && node.type != 'dgstart'){
658 xmlStr=node.xml;
659 var regex = /(<)([\w-]+)(.*)?/;
660 var match = regex.exec(xmlStr);
661 if(match != null){
662 if(match[1] != undefined && match[2] != undefined){
663 startTag = match[2];
664 }
665 }else{
666 console.log("startTag not found.");
667 }
668 }
669 return startTag;
670 }
671
672 if(inputNodeSet == null || inputNodeSet == undefined){
673 exportableNodeSet = getCurrentFlowNodeSet();
674 }else{
675 exportableNodeSet = JSON.parse(inputNodeSet);
676 }
677 var dgstartNode = getDgStartNode(exportableNodeSet);
678
679 var level=0;
680 var fullXmlStr="";
681
682 printXml(dgstartNode);
683
684
685 function printXml(node){
686 var xmlStr="";
687 var startTag = "";
688 if(node != null && node.type != 'dgstart'){
689 var comments=node.comments;
690 if(comments != null && comments != ""){
691 //if xml comments field already has the <!-- and --> remove them
692 comments=comments.replace("<!--","");
693 comments=comments.replace("-->","");
694 xmlStr="<!--" + comments + "-->";
695 }
696 xmlStr+=node.xml;
697 startTag = getStartTag(node);
Chinthakayala,Sheshashailavas(sc2914)8f6a6c42018-06-27 16:11:44 +0000698 //special handling for break node
699 if(xmlStr != undefined && xmlStr != null && xmlStr.trim() == "<break>"){
700 fullXmlStr += "<break/>";
701 }else{
702 fullXmlStr +=xmlStr;
703 }
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -0900704 /*
705 if(level > 0){
706 var spacing = Array(level).join(" ");
707 xmlStr=xmlStr.replace(/\n/g,spacing);
708 fullXmlStr +=xmlStr;
709
710 console.log(xmlStr);
711 }else{
712 fullXmlStr +=xmlStr;
713 console.log(xmlStr);
714 }
715 */
716 }
717
718 //console.log("startTag:" + startTag);
719
720 var wiredNodes = [];
721 var wiredNodesArr = [];
722 if(node != null && node.wires != null && node.wires[0] != null && node.wires[0] != undefined && node.wires[0].length >0 ){
723 wiredNodes=node.wires[0];
724 //console.log("Before sort");
725 for(var k=0;wiredNodes != undefined && wiredNodes != null && k<wiredNodes.length;k++){
726 wiredNodesArr.push(getNode(wiredNodes[k]));
727 }
728 //console.dir(wiredNodesArr);
729 //sort based on y position
730 wiredNodesArr.sort(function(a, b){
731 return a.y-b.y;
732 });
733 //console.log("After sort");
734 //console.dir(wiredNodesArr);
735 }
736
737 for(var k=0;wiredNodesArr != null && k<wiredNodesArr.length;k++){
738 level++;
739 var nd = wiredNodesArr[k];
740 printXml(nd);
741 }
742
743 //append end tag
744 if(startTag != ""){
Chinthakayala,Sheshashailavas(sc2914)8f6a6c42018-06-27 16:11:44 +0000745 if(startTag != "break"){
746 fullXmlStr += "</" + startTag + ">";
747 }
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -0900748 /*
749 if(level >0){
750 var spacing = Array(level).join(" ");
751 fullXmlStr += spacing + "</" + startTag + ">";
752 console.log(spacing + "</" + startTag + ">");
753 }else{
754 fullXmlStr += "</" + startTag + ">";
755 console.log("</" + startTag + ">");
756 }
757 */
758 }
759
760 /*if(level>0){
761 level=level-1;
762 }
763 */
764 //console.log("endTag:" + startTag);
765 //console.log("xml:" + fullXmlStr);
766 }
767 //console.log("fullXmlStr:" + fullXmlStr);
768 return fullXmlStr;
769}
770
771function showFlow(filePath){
772var jqxhr = $.post( "/getSharedFlow",{"filePath":filePath})
773 .done(function(data) {
774 $( "#dgflow-browser-dialog").dialog("close");
775 var migratedNodes = migrateNodes(data);
776 //RED.view.importNodes(data)
777 RED.view.importNodes(JSON.stringify(migratedNodes));
778 //console.log( "import done");
779 })
780 .fail(function() {
781 RED.notify("Could not import user flow .");
782 $( "#dgflow-browser-dialog").dialog("close");
783 console.log( "error occured importing flow.");
784 })
785 .always(function() {
786 //console.log( "complete" );
787 });
788}
789
790function showFlowXml(filePath){
791var jqxhr = $.post( "/getSharedFlow",{"filePath":filePath})
792 .done(function(data) {
793 //console.dir(data);
794 var xmlStr=getNodeToXml(data);
795 showImportedXml(xmlStr,this);
796 })
797 .fail(function() {
798 RED.notify("Could not convert to XML.");
799 $( "#dgflow-browser-dialog").dialog("close");
800 console.log( "error occured importing flow.");
801 })
802 .always(function() {
803 //console.log( "complete" );
804 });
805}
806
807function showFlowFiles(userName){
808 //var divStyle="color:#07c; margin-bottom: 1.2em; font-size: 16px;";
809 //var divStyle="<style>#data-container a { color: #067ab4; font-size: 0.75em;} #data-container a:hover { text-decoration: underline; padding: -15px -15px -15px 15px; } </style>";
810 var divStyle="<style>#data-container a { color: #067ab4; font-size: 0.75em;} #data-container a:hover { text-decoration: underline; padding: -15px -15px -15px 15px; } .header { height: 40px; border-bottom: 1px solid #EEE; background-color: #ffffff; height: 40px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .footer { height: 40px; background-color: whiteSmoke; border-top: 1px solid #DDD; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }</style>";
811
812 var htmlStr=divStyle + "<div class='header'>List of Flow files of User " + userName + "</div><div id='data-container'><ul>" ;
813 $.post( "/getFiles/" + userName)
814 .done(function( data ) {
815 //console.dir(data);
816 //console.log("found " + data.length + " files");
817 if(data != null && data.length != undefined && data.length != 0){
818 if(data != null && data.length>0){
819 for(var k=0;k<data.length;k++){
820 htmlStr += "<li><a href=\"#\" onclick=\"showFlow('" +data[k].filePath + "')\">" + data[k].name + "</a></li>";
821 /*
822 //Use this code to display the View Xml Link
823 htmlStr += "<li><a href=\"#\" onclick=\"showFlow('" +data[k].filePath + "')\">" + data[k].name + "</a><span style=\"margin-left:15px;color:blue\"><a href=\#\" onclick=\"showFlowXml('" +data[k].filePath + "')\">[View Xml]</a></span></li>";
824 */
825 }
826 htmlStr+="</ul></div>";
827 }
828 $( "#dgflow-browser-dialog").html(htmlStr);
829 }else{
830 //console.log("no flow files found for user " + userName);
831 var noFlowFilesHtml = divStyle + "<div id='data-container'><p>No downloaded Flow files found in " + userName + " directory</p><a href='#' onclick='javascript:closeAndShowFlowShareUsers()'>Back to List.</a></div>";
832 $( "#dgflow-browser-dialog").html(noFlowFilesHtml);
833 }
834 })
835 .fail(function(err) {
836 console.log( "error" + err );
837 })
838 .always(function() {
839 //console.log("done");
840 });
841
842}
843
844 function closeAndShowFlowShareUsers(){
845 $("#dgflow-browser-dialog").dialog( "close" );
846 var divStyle="<style>#data-container a { color: #067ab4; font-size: 0.75em;} #data-container a:hover { text-decoration: underline; padding: -15px -15px -15px 15px; } .header { height: 40px; border-bottom: 1px solid #EEE; background-color: #ffffff; height: 40px; -webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px; -moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; } .footer { height: 40px; background-color: whiteSmoke; border-top: 1px solid #DDD; -webkit-border-bottom-left-radius: 5px; -webkit-border-bottom-right-radius: 5px; -moz-border-radius-bottomleft: 5px; -moz-border-radius-bottomright: 5px; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; }</style>";
847 $.get( "/flowShareUsers")
848 .done(function( data ) {
849
850 var header="<div class='header'>List of downloaded DG Flows </div>";
851 var html= divStyle + header + "<div id='data-container'>";
852 html+="<ul>";
853 if(data != null){
854 var users=data.flowShareUsers;
855 users.sort(function (a,b){
856 if(a.name > b.name){
857 return 1;
858 }else if(a.name < b.name){
859 return -1;
860 }else{
861 return 0;
862 }
863 });
864 for(var i=0;users != null && i<users.length;i++){
865 html+="<li><a href=\"#\" onclick=\"showFlowFiles('" + users[i].rootDir + "')\">" + users[i].name + "</a></li>";
866 }
867 }
868 html+="</ul>";
869 html+="</div>";
870 $( "#dgflow-browser-dialog" ).dialog({
871 title: "Dowloaded DG Flow Browser",
872 modal: true,
873 autoOpen: true,
874 width: 530,
875 height: 530,
876 buttons: [
877 {
878 text: "Close",
879 click: function() {
880 $( this ).dialog( "close" );
881 }
882 }
883 ]
884 }).html(html);
885 $("#dgflow-browser-dialog").show();
886 })
887 .fail(function(err) {
888 RED.notify("Failed to get users.");
889 })
890 .always(function() {
891 });
892 }
893
894function showImportedXml(xmlStr,dialogBox){
895 var formattedXml=vkbeautify.xml(xmlStr);
896 var that = dialogBox;
897 require(["orion/editor/edit"], function(edit) {
898 that.editor = edit({
899 parent:document.getElementById('dgflow-browser-dialog'),
900 lang:"html",
901 readonly:true,
902 contents: formattedXml
903 });
904 RED.library.create({
905 url:"functions", // where to get the data from
906 type:"function", // the type of object the library is for
907 editor:that.editor, // the field name the main text body goes to
908 fields:['name','outputs']
909 });
910 });
911}
912
913function getTag(xmlStr){
914 var tag= null ;
915 if(xmlStr != null){
916 xmlStr = xmlStr.trim();
917 }
918 try{
919 var regex = new RegExp("(<)([^ >]+)");
920 var match = regex.exec(xmlStr);
921 if(match != null){
922 if(match[1] != undefined && match[2] != undefined){
923 tag = match[2];
924 }
925 }
926 }catch(e){
927 console.log(e);
928 }
929 return tag;
930
931}
932
933function getAttributeValue(xmlStr,attribute){
934
935 var attrVal=null;
936 try{
937 var myRe = new RegExp(attribute + "[\s+]?=[\s+]?['\"]([^'\"]+)['\"]","m");
938 var myArray = myRe.exec(xmlStr);
939 if(myArray != null && myArray[1] != null){
940 attrVal=myArray[1];
941 }
942 }catch(err){
943 console.log(err);
944 }
945 return attrVal;
946}
947
948function showOrHideTab(checkbox,idVal){
949
950 var activeWorkspace=RED.view.getWorkspace();
951 var table = $("#ftab02");
952 $('td input:checkbox',table).each(function(i){
953 console.log(this.checked);
954 });
955 //console.dir($('td input:checkbox',table).prop('checked',this.checked));
956
957 $(".red-ui-tabs li a").each(function(i){
958 var id=$(this).attr("href").replace('#','');
959 if(id == idVal){
960 $(this).parent().toggle();
961 var isVisible = $(this).parent().is(":visible");
962 if(isVisible){
963 checkbox.checked = true;
964 }else{
965 checkbox.checked = false;
966 }
967 if(activeWorkspace == id){
968 //$("#chart").hide();
969 //var li = ul.find("a[href='#"+id+"']").parent();
970 var li = $(this).parent();
971 if (li.hasClass("active")) {
972 li.removeClass("active");
973 if(li.parent().children().size() != 0){
974 }
975 console.log("has Class active");
976 var tab = li.prev();
977 if (tab.size() === 0) {
978 console.log("li prev size 0");
979 tab = li.next();
980 }
981 if(tab.is(":visible")){
982 console.log("added active");
983 tab.addClass("active");
984 tab.click();
985 //tab.trigger("click");
986 }
987 //console.dir(tab);
988 //tab.parent().addClass("active");
989 //tab.click();
990 }
991 }else{
992 console.log("added active id" +id);
993 if(isVisible){
994 var li = $(this).parent();
995 li.addClass("active");
996 li.click();
997 //console.dir(li);
998 }else{
999 var li = $(this).parent();
1000 li.removeClass("active");
1001 }
1002 }
1003 }
1004 });
1005/*
1006 $(".red-ui-tabs li a").each(function(i){
1007 var id=$(this).attr("href").replace('#','');
1008 if(id != idVal){
1009 $(this).trigger("click");
1010 if(activeWorkspace == idVal){
1011 $("#chart").show();
1012 }
1013 return false;
1014 }
1015 });
1016*/
1017}
1018
1019function performGitCheckout(){
1020 $("#responseId").text("");
1021 if(!event) event = window.event;
1022 var target = $(event.target);
1023 target.val("Processing");
1024 target.css({ "background-image": "url('images/page-loading.gif')" });
1025 target.css({ "background-repeat": "no-repeat" });
1026 target.css({ "background-size": "25px 25px" });
1027
1028 var branch = document.getElementById("branchId").value.trim();
1029 var statusObj = document.getElementById("responseId");
1030 if(branch == null || branch == ''){
1031 statusObj.innerText = "Branch is required.";
1032 return;
1033 }
1034 var urlVal = "/gitcheckout?branch=" + branch;
1035 $.get(urlVal)
1036 .done(function( data ) {
1037 var output = data.output;
1038 if(output != null){
1039 output=output.replace(/\n/g,"<br>");
1040 statusObj.innerHTML = output;
1041 }
1042 })
1043 .fail(function(err) {
1044 statusObj.innerText = "Failed to do git checkout.";
1045 })
1046 .always(function() {
1047 $("#responseId").show();
1048 target.val("Checkout");
1049 target.css({ "background-image": "none" });
1050 });
1051}
1052
1053function performGitPull(){
1054 $("#responseId").text("");
1055 if(!event) event = window.event;
1056 var target = $(event.target);
1057 target.val("Processing");
1058 target.css({ "background-image": "url('images/page-loading.gif')" });
1059 target.css({ "background-repeat": "no-repeat" });
1060 target.css({ "background-size": "25px 25px" });
1061
1062 var statusObj = document.getElementById("responseId");
1063 var urlVal = "/gitpull";
1064 $.get(urlVal)
1065 .done(function( data ) {
1066 var output = data.output;
1067 if(output != null){
1068 output=output.replace(/\n/g,"<br>");
1069 statusObj.innerHTML = output;
1070 }
1071 })
1072 .fail(function(err) {
1073 statusObj.innerText = "Failed to do git pull.";
1074 })
1075 .always(function() {
1076 $("#responseId").show();
1077 target.val("Pull");
1078 target.css({ "background-image": "none" });
1079 });
1080}
1081
1082
1083function activateClickedTab(idVal) {
1084
1085 $("#filter-tabs-dialog").dialog( "close" );
1086 var ul = $("#workspace-tabs");
1087 ul.children().each(function(){
1088 var li = $(this);
1089 var link =li.find("a");
1090 var href = link.prop("href");
1091 var hrefId = href.split("#");
1092 if(hrefId[1] == idVal){
1093 link.trigger("click");
1094 }
1095 });
1096}
1097
1098function deleteOrRenameTab(idVal) {
1099 $("#filter-tabs-dialog").dialog( "close" );
1100 var ul = $("#workspace-tabs");
1101 ul.children().each(function(){
1102 var li = $(this);
1103 var link =li.find("a");
1104 var href = link.prop("href");
1105 var hrefId = href.split("#");
1106 if(hrefId[1] == idVal){
1107 link.trigger("click");
1108 link.trigger("dblclick");
1109 }
1110 });
1111}
1112
1113function deleteSelectedTab(idVal,title,_module,rpc,version){
1114 var dgInfo = "<div><table width='100%' border='1'><tr style='background-color:#65a9d7;color:white;' ><th>Tab Title</th><th>Module</th><th>RPC</th><th>Version</th></tr><tr style='background-color:white'><td>" + title + "</td><td>" + _module +"</td><td>" + rpc + "</td><td>" +version + "</td></tr></table></div><br>";
1115 var alertMsg = dgInfo + "<p>Are you sure you want to Delete this Tab ?</p>";
1116
1117$( "#tabAlertDialog" ).dialog({
1118 dialogClass: "no-close",
1119 modal:true,
1120 draggable : true,
1121 /*dialogClass: "alert",*/
1122 title: "Confirm Tab sheet Delete",
1123 width: 600,
1124 buttons: [
1125 {
1126 text: "Delete",
1127 class:"alertDialogButton",
1128 click: function() {
1129 var ws = RED.nodes.workspace(idVal);
1130 RED.view.removeWorkspace(ws);
1131 var historyEvent = RED.nodes.removeWorkspace(idVal);
1132 historyEvent.t = 'delete';
1133 historyEvent.dirty = true;
1134 historyEvent.workspaces = [ws];
1135 RED.history.push(historyEvent);
1136 RED.view.dirty(true);
1137 $( this ).dialog( "close" );
1138 $("#filter-tabs-dialog").dialog( "close" );
1139 $("#btn-manage-tabs").trigger("click");
1140 }
1141 },
1142 {
1143 text: "Cancel",
1144 class:"alertDialogButton",
1145 click: function() {
1146 $( this ).dialog( "close" );
1147 }
1148 }
1149 ]
1150}).html(alertMsg);
1151}
1152
1153function renameSelectedTab(idVal,title,_module,rpc,version){
1154 var dgInfo = "<div><table width='100%' border='1'><tr style='background-color:#65a9d7;color:white;' ><th>Tab Title</th><th>Module</th><th>RPC</th><th>Version</th></tr><tr style='background-color:white'><td><input id='tab-name-" + idVal + "' type='text' value='" + title + "'></td><td>" + _module +"</td><td>" + rpc + "</td><td>" +version + "</td></tr></table></div><br>";
1155 var alertMsg = dgInfo + "<p>Change the title and click Rename.</p>";
1156
1157$( "#tabAlertDialog" ).dialog({
1158 dialogClass: "no-close",
1159 modal:true,
1160 draggable : true,
1161 /*dialogClass: "alert",*/
1162 title: "Rename Tab sheet",
1163 width: 600,
1164 buttons: [
1165 {
1166 text: "Rename",
1167 class:"alertDialogButton",
1168 click: function() {
1169 var ws = RED.nodes.workspace(idVal);
1170 var label = document.getElementById("tab-name-" + idVal).value;
1171 //console.log("label:" +label);
1172 //console.log("ws.label:" + ws.label);
1173 if (ws.label != label) {
1174 ws.label = label;
1175 var link = $("#workspace-tabs a[href='#"+idVal+"']");
1176 link.attr("title",label);
1177 link.text(label);
1178 RED.view.dirty(true);
1179 }
1180 $("#tabAlertDialog").dialog('destroy').remove();
1181 //$(this).dialog( "close" );
1182 $("#filter-tabs-dialog").dialog( "close" );
1183 $("#btn-manage-tabs").trigger("click");
1184 }
1185 },
1186 {
1187 text: "Cancel",
1188 class:"alertDialogButton",
1189 click: function() {
1190 $( this ).dialog( "close" );
1191 }
1192 }
1193 ]
1194}).html(alertMsg);
1195}
1196
1197function performGitStatus(){
1198 $("#responseId").text("");
1199 if(!event) event = window.event;
1200 var target = $(event.target);
1201 target.val("Processing");
1202 target.css({ "background-image": "url('images/page-loading.gif')" });
1203 target.css({ "background-repeat": "no-repeat" });
1204 target.css({ "background-size": "25px 25px" });
1205
1206 var statusObj = document.getElementById("responseId");
1207 var urlVal = "/gitstatus";
1208 $.get(urlVal)
1209 .done(function( data ) {
1210 var output = data.output;
1211 if(output != null){
1212 output=output.replace(/\n/g,"<br>");
1213 statusObj.innerHTML = output;
1214 }
1215 //statusObj.innerText = data.output;
1216 })
1217 .fail(function(err) {
1218 statusObj.innerText = "Failed to do git status.";
1219 })
1220 .always(function() {
1221 $("#responseId").show();
1222 target.val("Status");
1223 target.css({ "background-image": "none" });
1224 });
1225}
1226
1227function migrateNodes(jsonStr){
1228 var nodes = JSON.parse(jsonStr);
1229 nodes.forEach( function(node) {
1230 if( node.xml != undefined && node.xml != null && node.xml.indexOf("<service-logic") != -1){
1231 //console.log(node.xml);
1232 var module="";
1233 var version="";
1234 module=getAttributeValue(node.xml,"module");
1235 /*
1236 var myRe = new RegExp("module=\"(.*)\" ", "m");
1237 var myArray = myRe.exec(node.xml);
1238 if(myArray != null && myArray[1] != null){
1239 module=myArray[1];
1240 }
1241 myRe = new RegExp("version=\"(.*)\">", "m");
1242 myArray = myRe.exec(node.xml);
1243 if(myArray != null && myArray[1] != null){
1244 version=myArray[1];
1245 //console.dir(myArray);
1246 }
1247 */
1248 version=getAttributeValue(node.xml,"version");
1249 node.type="service-logic";
1250 //node.category="DGEmain";
1251 node.module=module;
1252 node.version=version;
1253 if(module != null && version != null){
1254 node.name=module+ " " + version;
1255 }
1256 console.log("module=" + module);
1257 console.log("version=" + version);
1258 }else if( node.xml != undefined && node.xml != null && node.xml.indexOf("<method") != -1){
1259 var rpc=getAttributeValue(node.xml,"rpc");
1260 node.type="method";
1261 if(rpc != null){
1262 node.name=rpc;
1263 }
1264 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<outcome") != -1){
1265 var uxml = node.xml.toUpperCase();
1266 if(uxml.indexOf("FAILURE") != -1){
1267 node.type="failure";
1268 }else if(uxml.indexOf("SUCCESS") != -1){
1269 node.type="success";
1270 }else if(uxml.indexOf("TRUE") != -1){
1271 node.type="outcomeTrue";
1272 }else if(uxml.indexOf("FALSE") != -1){
1273 node.type="outcomeFalse";
1274 }else if(uxml.indexOf("ALREADY-ACTIVE") != -1){
1275 node.type="already-active";
1276 }else if(uxml.indexOf("NOT-FOUND") != -1){
1277 node.type="not-found";
1278 }else{
1279 node.type="other";
1280 }
1281 }else if( node.xml != undefined &&node.xml != null && node.xml.indexOf("<return") != -1){
1282 var uxml = node.xml.toUpperCase();
1283 if(uxml.indexOf("FAILURE") != -1){
1284 node.type="returnFailure";
1285 }else if(uxml.indexOf("SUCCESS") != -1){
1286 node.type="returnSuccess";
1287 }
1288 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<exists") != -1){
1289 node.type="exists";
Chinthakayala,Sheshashailavas(sc2914)8f6a6c42018-06-27 16:11:44 +00001290 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<break") != -1){
1291 node.type="break";
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -09001292 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<block") != -1){
1293 node.type="block";
1294 var atomic=getAttributeValue(node.xml,"atomic");
1295
1296 if(atomic=='true'){
1297 node.atomic="true";
1298 node.name="block : atomic";
1299 }else{
1300 node.atomic="false";
1301 node.name="block";
1302 }
1303 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<save") != -1){
1304 node.type="save";
Chinthakayala,Sheshashailavas(sc2914)8f6a6c42018-06-27 16:11:44 +00001305 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<while") != -1){
1306 node.type="while";
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -09001307 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<switch") != -1){
1308 node.type="switchNode";
1309 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<record") != -1){
1310 node.type="record";
1311 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<call") != -1){
1312 node.type="call";
1313 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<release") != -1){
1314 node.type="release";
1315 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<set") != -1){
1316 node.type="set";
1317 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<for") != -1){
1318 node.type="for";
1319 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<is-available") != -1){
1320 node.type="is-available";
1321 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<reserve") != -1){
1322 node.type="reserve";
1323 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<get-resource") != -1){
1324 node.type="get-resource";
1325 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<configure") != -1){
1326 node.type="configure";
1327 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<delete") != -1){
1328 node.type="delete";
1329 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<execute") != -1){
1330 node.type="execute";
1331 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<notify") != -1){
1332 node.type="notify";
1333 }else if(node.xml != undefined && node.xml != null && node.xml.indexOf("<update") != -1){
1334 node.type="update";
1335 }
1336 //console.dir(node);
1337 });
1338 return nodes;
1339}