diff --git a/dist/boda-bulkcmparser.jar b/dist/boda-bulkcmparser.jar
index 4cf9d2b..50f9847 100644
Binary files a/dist/boda-bulkcmparser.jar and b/dist/boda-bulkcmparser.jar differ
diff --git a/nbactions.xml b/nbactions.xml
index 3770d2f..b717e23 100644
--- a/nbactions.xml
+++ b/nbactions.xml
@@ -9,4 +9,11 @@
assembly:single
+
+ CUSTOM-test
+ test
+
+ test
+
+
diff --git a/src/main/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParser.java b/src/main/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParser.java
index 978ab13..9befabb 100644
--- a/src/main/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParser.java
+++ b/src/main/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParser.java
@@ -29,6 +29,14 @@
public class BodaBulkCMParser {
+
+ /**
+ * Current release version
+ *
+ * Since 1.3.0
+ */
+ final String VERSION = "1.3.0";
+
/**
* Tracks XML elements.
*
@@ -248,6 +256,13 @@ public class BodaBulkCMParser {
*/
Map moColumnsParentIds = new LinkedHashMap();
+ /**
+ * A map of 3GPP attributes to the 3GPP MOs
+ *
+ * @since 1.3.0
+ */
+ Map moThreeGPPAttrMap = new LinkedHashMap();
+
/**
* The file/directory to be parsed.
*
@@ -719,6 +734,10 @@ public void endELementEvent(XMLEvent xmlEvent)
//3.2
if (qName.equals("attributes")) {
attrMarker = false;
+
+ if(parserState == ParserStates.EXTRACTING_PARAMETERS && vsDataType == null){
+ updateThreeGPPAttrMap();
+ }
return;
}
@@ -941,18 +960,33 @@ public void process3GPPAttributes()
paramValues = paramValues + "," + toCSVFormat(meMap.getValue());
}
}
+
+ //Some MOs dont have 3GPP attributes e.g. the fileHeader
+ //and the fileFooter
+ if( moThreeGPPAttrMap.get(mo) != null ){
+ //Get 3GPP attributes for MO at the current depth
+ Stack a3GPPAtrr = moThreeGPPAttrMap.get(mo);
+ Map current3GPPAttrs = null;
+
+ if (!threeGPPAttrStack.isEmpty() && threeGPPAttrStack.get(depth) != null) {
+ current3GPPAttrs = threeGPPAttrStack.get(depth);
+ }
+
+ for(int i =0; i < a3GPPAtrr.size();i++){
+ String aAttr = (String)a3GPPAtrr.get(i);
+ String aValue= "";
+
+ if( current3GPPAttrs != null && current3GPPAttrs.containsKey(aAttr)){
+ aValue = toCSVFormat(current3GPPAttrs.get(aAttr));
+ }
+
+ paramNames = paramNames + "," + aAttr;
+ paramValues = paramValues + "," + aValue;
+ }
+ }
+
- //Get 3GPP parameters for the MO at the current depth.
- if (!threeGPPAttrStack.isEmpty() && threeGPPAttrStack.get(depth) != null) {
- Iterator> iter
- = threeGPPAttrStack.get(depth).entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry meMap = iter.next();
- paramNames = paramNames + "," + meMap.getKey();
- paramValues = paramValues + "," + toCSVFormat(meMap.getValue());
- }
- }
-
+
//Write the 3GPP defined MOs to files.
PrintWriter pw = null;
if (!output3GPPMOPWMap.containsKey(mo)) {
@@ -1065,6 +1099,55 @@ public void processVendorAttributes() {
}
+
+ /**
+ * Update the map of 3GPP MOs to attributes.
+ *
+ * This is necessary to ensure the final output in the csv is aligned.
+ *
+ * @since 1.3.0
+ */
+ private void updateThreeGPPAttrMap(){
+ if( xmlTagStack == null || xmlTagStack.isEmpty() ) return;
+
+ String mo = xmlTagStack.peek().toString();
+
+ //Hold the current 3GPP attributes
+ HashMap tgppAttrs = null;
+
+ Stack attrs = new Stack();
+
+ //Initialize if the MO does not exist
+ if(!moThreeGPPAttrMap.containsKey(mo)){
+ moThreeGPPAttrMap.put(mo, new Stack());
+ }
+
+
+ //The attributes stack can be empty if the MO has no 3GPP attributes
+ if(threeGPPAttrStack.isEmpty() || threeGPPAttrStack.get(depth) == null){
+ return;
+ }
+ tgppAttrs = (LinkedHashMap) threeGPPAttrStack.get(depth);
+
+
+ attrs = moThreeGPPAttrMap.get(mo);
+
+ if(tgppAttrs != null){
+ //Get vendor specific attributes
+ Iterator> iter
+ = tgppAttrs.entrySet().iterator();
+ while (iter.hasNext()) {
+ Map.Entry me = iter.next();
+ String parameter = me.getKey();
+ if( !attrs.contains( parameter ) ){
+ attrs.push(parameter);
+ }
+ }
+ moThreeGPPAttrMap.replace(mo, attrs);
+
+ }
+ }
+
/**
* Collect parameters for vendor specific mo data
*/
@@ -1178,7 +1261,7 @@ public void closeMOPWMap() {
* @version 1.0.0
*/
public void showHelp() {
- System.out.println("boda-bulkcmparser 1.2.0 Copyright (c) 2017 Bodastage(http://www.bodastage.com)");
+ System.out.println("boda-bulkcmparser "+ VERSION +" Copyright (c) 2017 Bodastage(http://www.bodastage.com)");
System.out.println("Parses 3GPP Bulk CM XML to csv.");
System.out.println("Usage: java -jar boda-bulkcmparser.jar ");
}
diff --git a/src/test/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParserTest.java b/src/test/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParserTest.java
index 69da1ca..9994281 100644
--- a/src/test/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParserTest.java
+++ b/src/test/java/com/bodastage/boda_bulkcmparser/BodaBulkCMParserTest.java
@@ -79,7 +79,7 @@ public void tearDown(){
}catch(Exception e){
System.err.println(e.getMessage());
- //assertTrue(false);
+ assertTrue(false);
}
}