X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=dgbuilder%2Fpublic%2Futil%2Fjs%2FmigrateFlow.js;fp=dgbuilder%2Fpublic%2Futil%2Fjs%2FmigrateFlow.js;h=399db6060cd2d87212958c4ba49c234679c8833c;hb=d1569975bb18f4359fac18aa98f55b69c248a3ad;hp=0000000000000000000000000000000000000000;hpb=a016ea661ff5767a3539734c4c07ef974a6e4614;p=ccsdk%2Fdistribution.git diff --git a/dgbuilder/public/util/js/migrateFlow.js b/dgbuilder/public/util/js/migrateFlow.js new file mode 100644 index 00000000..399db606 --- /dev/null +++ b/dgbuilder/public/util/js/migrateFlow.js @@ -0,0 +1,184 @@ +fs=require('fs'); +_=require('lodash'); +//extras=require("/home/users/schinthakayala/nodered/sheshi/dgxml/extras"); +//puts=extras.puts; +var path = require('path'); +var appDir = path.dirname(require.main.filename); + +var dgjson = []; +var level = 0; + +function getJSON() { +var filename = process.argv[2]; + console.log("reading json from flows file" + filename); + //flowsJson=fs.readFileSync(appDir + "/flows_ss4nj01dev01.localdomain.json").toString(); + flowsJson=fs.readFileSync(filename).toString(); + // Let's make a backup while we're here... + ts=Date.now().toString(); + flows=JSON.parse(flowsJson); + //console.log("returning flows"); + return(flows); +} + +function getStartTag(xmlStr){ + var startTag= null ; + if(xmlStr != null){ + xmlStr = xmlStr.trim(); + } + try{ + var regex = new RegExp("(<)([^ >]+)"); + var match = regex.exec(xmlStr); + if(match != null){ + if(match[1] != undefined && match[2] != undefined){ + startTag = match[2]; + } + } + }catch(e){ + console.log(e); + } + return startTag; + +} + +function getAttributeValue(xmlStr,attribute){ + var attrVal=null; + try{ + var myRe = new RegExp(attribute + "=['\"](.*)['\"] ","m"); + var myArray = myRe.exec(xmlStr); + if(myArray != null && myArray[1] != null){ + attrVal=myArray[1]; + } + }catch(err){ + console.log(err); + } + return attrVal; +} + +function processNodes(){ + var nodes = getJSON(); + //console.dir(nodes); + + nodes.forEach( function(node) { + if( node.xml != null && node.xml.indexOf("", "m"); + myArray = myRe.exec(node.xml); + if(myArray != null && myArray[1] != null){ + version=myArray[1]; + //console.dir(myArray); + } + */ + version=getAttributeValue(node.xml,"version"); + node.type="service-logic"; + //node.category="DGEmain"; + node.module=module; + node.version=version; + if(module != null && version != null){ + node.name=module+ "_" + version; + } + console.log("module=" + module); + console.log("version=" + version); + }else if( node.xml != null && node.xml.indexOf("