From 9b1ac6f4e578f2a70c938bc00adcc8cf7931e8fe Mon Sep 17 00:00:00 2001 From: Sahar Mehrpour Date: Tue, 14 Jan 2020 15:25:31 -0500 Subject: [PATCH] merged new changed by Gennie Mansi, logic for custom queries are added --- src/core/mineRulesCore/sci_class.js | 18 +++++++++++++----- src/core/miningRules.js | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core/mineRulesCore/sci_class.js b/src/core/mineRulesCore/sci_class.js index 0810414..f7fb3f9 100644 --- a/src/core/mineRulesCore/sci_class.js +++ b/src/core/mineRulesCore/sci_class.js @@ -116,7 +116,7 @@ export const findCustomRelations = (id_start, customQueries, attributeList, quer export const addCustomRelations = (allAttributes, customQueries, classGroupings, analysisFileName, classLocations, - parentInfo, fileAnalysisMap, dataMap) => { + parentInfo, fileAnalysisMap, dataMap, xmlFiles) => { var parentClass = classGroupings[classGroupings.length-1]; var classTree; @@ -133,10 +133,18 @@ export const addCustomRelations = (allAttributes, customQueries, classGroupings, if(f != undefined){ f = f.split("\\")[(f.split("\\")).length - 1] - f = f.split(".")[0] + ".xml"; + f = f.split(".")[0] + ".java"; + + // var data = fs.readFileSync(f).toString(); + // classTree = et.parse(data); - var data = fs.readFileSync(f).toString(); - classTree = et.parse(data); + let filtered = xmlFiles.filter(d => d["filePath"].endsWith(f)); + if (filtered.length > 0) + classTree = et.parse(filtered[0]["xml"]); + if (filtered.length === 0) { + console.log("file not found: ", f); + continue; + } } else{ @@ -176,7 +184,7 @@ export const addCustomRelations = (allAttributes, customQueries, classGroupings, classesVisited.push(childName); // Get the list of attributes for this class - let fileN = analysisFileName + "_subClassOf" + parentClass + ".txt"; + let fileN = analysisFileName + "_subClassOf_" + parentClass + ".txt"; var entry = (dataMap.get(fileN)); // Go through each of the customQueries. If the customQuery is present diff --git a/src/core/miningRules.js b/src/core/miningRules.js index 039e125..343002f 100644 --- a/src/core/miningRules.js +++ b/src/core/miningRules.js @@ -225,7 +225,7 @@ export const mineRulesFromXmlFiles = (xmlFiles, support, metaData, ws) => { for (const group of groupList.keys()){ var grouping = groupList.get(group); addCustomRelations(allAttributes, customQueries, grouping, analysisFileName, - classLocations, parentInfo, fileAnalysisMap, dataMap); + classLocations, parentInfo, fileAnalysisMap, dataMap, xmlFiles); } outputDataBases(dataMap, ws);