diff --git a/dist/boda-bulkcmparser.jar b/dist/boda-bulkcmparser.jar index 7b8adef..951f5b5 100644 Binary files a/dist/boda-bulkcmparser.jar and b/dist/boda-bulkcmparser.jar differ diff --git a/pom.xml b/pom.xml index ff3a348..945de0f 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.bodastate.boda_bulkcmparser boda-bulkcmparser jar - 2.0.4 + 2.0.5 boda-bulkcmparser http://maven.apache.org diff --git a/src/main/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParser.java b/src/main/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParser.java index 788a57a..a9d4a46 100644 --- a/src/main/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParser.java +++ b/src/main/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParser.java @@ -47,7 +47,7 @@ public class BodaBulkCMParser { * * Since 1.3.0 */ - final static String VERSION = "2.0.4"; + final static String VERSION = "2.0.5"; private static final Logger LOGGER = LoggerFactory.getLogger(BodaBulkCMParser.class); @@ -520,7 +520,7 @@ public static void main(String[] args) { if(showVersion == true ){ System.out.println(VERSION); - System.out.println("Copyright (c) 2018 Bodastage Solutions(http://www.bodastage.com)"); + System.out.println("Copyright (c) 2019 Bodastage Solutions(http://www.bodastage.com)"); System.exit(0); } @@ -536,7 +536,7 @@ public static void main(String[] args) { footer += "java -jar boda-bulkcmparser.jar -i input_folder -o out_folder\n"; footer += "java -jar boda-bulkcmparser.jar -i input_folder -p\n"; footer += "java -jar boda-bulkcmparser.jar -i input_folder -p -m\n"; - footer += "\nCopyright (c) 2018 Bodastage Solutions(http://www.bodastage.com)"; + footer += "\nCopyright (c) 2019 Bodastage Solutions(http://www.bodastage.com)"; formatter.printHelp( "java -jar boda-bulkcmparser.jar", header, options, footer ); System.exit(0); } @@ -605,15 +605,7 @@ public void parse() throws XMLStreamException, FileNotFoundException, Unsupporte } //Reset variables - vsDataType = null; - vsDataTypeStack.clear(); - vsDataTypeRlStack.clear(); - xmlAttrStack.clear(); - xmlTagStack.clear(); - startElementTag = null; - startElementTagPrefix = ""; - attrMarker = false; - depth = 0; + resetVariables(); //Extracting values if (parserState == ParserStates.EXTRACTING_VALUES) { @@ -626,6 +618,22 @@ public void parse() throws XMLStreamException, FileNotFoundException, Unsupporte printExecutionTime(); } + /** + * Reset parser variables before next file + */ + public void resetVariables(){ + //Reset variables + vsDataType = null; + vsDataTypeStack.clear(); + vsDataTypeRlStack.clear(); + xmlAttrStack.clear(); + xmlTagStack.clear(); + startElementTag = null; + startElementTagPrefix = ""; + attrMarker = false; + depth = 0; + } + /** * Determines if the source data file is a regular file or a directory and * parses it accordingly @@ -706,6 +714,9 @@ public void processFileOrDirectory() } catch (Exception e) { System.out.println(e.getMessage()); System.out.println("Skipping file: " + this.baseFileName + "\n"); + + //Reset variables if a file is skipped + resetVariables(); } } } @@ -1506,7 +1517,7 @@ private void collectVendorMOColumns(){ //String pName = meMap.getKey(); String pName = parentMO + "_" + meMap.getKey(); - if( parentIDStack.search(pName ) < 0 ){ + if( parentIDStack.search(pName) < 0 ){ parentIDStack.push(pName); } @@ -1536,38 +1547,38 @@ private void collectVendorMOColumns(){ // //Parent IDs - for (int i = 0; i < xmlTagStack.size(); i++) { - String parentMO = xmlTagStack.get(i).toString(); - - //If the parent tag is VsDataContainer, look for the - //vendor specific MO in the vsDataContainer-to-vsDataType map. - if (parentMO.startsWith("VsDataContainer")) { - parentMO = vsDataContainerTypeMap.get(parentMO); - } - - //The depth at each xml tag index is index+1 - int depthKey = i + 1; - - //Iterate through the XML attribute tags for the element. - if (xmlAttrStack.get(depthKey) == null) { - continue; //Skip null values - } - - Iterator> mIter - = xmlAttrStack.get(depthKey).entrySet().iterator(); - - while (mIter.hasNext()) { - Map.Entry meMap = mIter.next(); - //String pName = meMap.getKey(); - String pName = parentMO + "_" + meMap.getKey(); - - if( parentIDStack.search(pName ) < 0 ){ - parentIDStack.push(pName); - } - } - } - - moColumnsParentIds.replace(vsDataType, parentIDStack); +// for (int i = 0; i < xmlTagStack.size(); i++) { +// String parentMO = xmlTagStack.get(i).toString(); +// +// //If the parent tag is VsDataContainer, look for the +// //vendor specific MO in the vsDataContainer-to-vsDataType map. +// if (parentMO.startsWith("VsDataContainer")) { +// parentMO = vsDataContainerTypeMap.get(parentMO); +// } +// +// //The depth at each xml tag index is index+1 +// int depthKey = i + 1; +// +// //Iterate through the XML attribute tags for the element. +// if (xmlAttrStack.get(depthKey) == null) { +// continue; //Skip null values +// } +// +// Iterator> mIter +// = xmlAttrStack.get(depthKey).entrySet().iterator(); +// +// while (mIter.hasNext()) { +// Map.Entry meMap = mIter.next(); +// //String pName = meMap.getKey(); +// String pName = parentMO + "_" + meMap.getKey(); +// +// if( parentIDStack.search(pName ) < 0 ){ +// parentIDStack.push(pName); +// } +// } +// } +// +// moColumnsParentIds.replace(vsDataType, parentIDStack); }