From a2c2bd67323a35936d5f4ef9b3230e6c25e6a0c8 Mon Sep 17 00:00:00 2001 From: Sheshi Chinthakayala Date: Wed, 25 Oct 2017 17:53:03 -0500 Subject: script to import multiple dgs into the dgbuilder. The script appends the dgs to flows.json which is used by the dgbuilder. Issue-ID:CCSDK-130 Change-Id: Ide3842299832cf125b8129d268e6d8527ca4c5c6 Signed-off-by: Sheshi Chinthakayala --- dgbuilder/tools/multiple_dg_load.js | 115 ++++++++++++++++++++++++++++++++++++ dgbuilder/tools/multiple_dg_load.sh | 6 ++ 2 files changed, 121 insertions(+) create mode 100644 dgbuilder/tools/multiple_dg_load.js create mode 100755 dgbuilder/tools/multiple_dg_load.sh (limited to 'dgbuilder') diff --git a/dgbuilder/tools/multiple_dg_load.js b/dgbuilder/tools/multiple_dg_load.js new file mode 100644 index 00000000..8640667e --- /dev/null +++ b/dgbuilder/tools/multiple_dg_load.js @@ -0,0 +1,115 @@ + +var fs = require('fs'); +var obj =[]; +try{ + obj = JSON.parse(fs.readFileSync(process.argv[2], 'utf8')); +}catch(err){ +} +var dirPath=process.argv[3]; +console.log(dirPath); +function getID() { + return (1+Math.random()*4294967295).toString(16); +} + +var filteredArray = obj.filter(function(itm){ + return itm.type == 'tab' ; +}); + +var tabsArr=filteredArray; + var files = fs.readdirSync(dirPath); + for (var i in files) { + var currentFile = dirPath + '/' + files[i]; + //console.log(currentFile); + var stats = fs.statSync(currentFile); +try{ + if (stats.isFile()) { + var moduleName=""; + var methodName=""; + console.log("processing... " + currentFile); + var o = JSON.parse(fs.readFileSync(currentFile, 'utf8')); + for(var idx in o){ + if(o[idx].type == "service-logic"){ + moduleName=o[idx].name; + } + if(o[idx].type == "method"){ + methodName=o[idx].name; + methodName = methodName.replace("method ",""); + } + if(moduleName != "" && methodName != ""){ + break; + } + } + var id = o[0].z; + //console.log("tab id:" + id); + var newId = id; + var number_of_tabs = 0; + if(filteredArray != null ){ + number_of_tabs = filteredArray.length; + } + //console.log("number_of_tabs:" + number_of_tabs); + //console.log("id:" + id); + if(filteredArray != null && filteredArray.length > 0){ + for(var i in filteredArray){ + if(filteredArray[i].id == id){ + newId = getID(); + console.log("Using new id:" + newId); + } + } + for(var idx in o){ + o[idx].z= newId; + var oldNodeId = o[idx].id; + var newNodeId = getID(); + o[idx].id= newNodeId; + for(var k=0;k