Skip to content

Commit

Permalink
Fix missing DATETIME value bug when using parameter cfg file
Browse files Browse the repository at this point in the history
  • Loading branch information
erssebaggala committed Dec 31, 2018
1 parent 740a6c8 commit a2c45e0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
Binary file modified dist/boda-bulkcmparser.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.bodastate.boda_bulkcmparser</groupId>
<artifactId>boda-bulkcmparser</artifactId>
<packaging>jar</packaging>
<version>2.0.3</version>
<version>2.0.4</version>
<name>boda-bulkcmparser</name>
<url>http://maven.apache.org</url>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class BodaBulkCMParser {
*
* Since 1.3.0
*/
final static String VERSION = "2.0.3";
final static String VERSION = "2.0.4";


private static final Logger LOGGER = LoggerFactory.getLogger(BodaBulkCMParser.class);
Expand Down Expand Up @@ -335,6 +335,44 @@ public void setExtractMetaFields(Boolean bool){
extractMetaFields = bool;
}

/**
* Get the date
* @param inputFilename
*/
public void getDateTime(String inputFilename){
try{
XMLInputFactory factory = XMLInputFactory.newInstance();

XMLEventReader eventReader = factory.createXMLEventReader(
new FileReader(inputFilename));
baseFileName = bulkCMXMLFileBasename = getFileBasename(inputFilename);

while (eventReader.hasNext()) {
XMLEvent event = eventReader.nextEvent();
switch (event.getEventType()) {
case XMLStreamConstants.START_ELEMENT:
StartElement startElement = event.asStartElement();
String qName = startElement.getName().getLocalPart();
Iterator<Attribute> attributes = startElement.getAttributes();
if(qName.equals("fileFooter")){
while (attributes.hasNext()) {
Attribute attribute = attributes.next();
if (attribute.getName().toString().equals("dateTime")) {
dateTime = attribute.getValue();
}
}
}

break;
}


}
}catch(Exception e){

}
}

/**
* Extract parameter list from parameter file
*
Expand Down Expand Up @@ -616,7 +654,15 @@ public void processFileOrDirectory()
}else{
System.out.print("Parsing " + this.baseFileName + "...");
}

//Get date time
if(parameterFile != null){
getDateTime(this.dataSource);
}

//Parse file
this.parseFile(this.dataSource);

if( parserState == ParserStates.EXTRACTING_PARAMETERS){
System.out.println("Done.");
}else{
Expand All @@ -642,8 +688,14 @@ public void processFileOrDirectory()
System.out.print("Parsing " + this.baseFileName + "...");
}

//Parse
//Get date time
if(parameterFile != null){
getDateTime(f.getAbsolutePath());
}

//Parse dump file
this.parseFile(f.getAbsolutePath());

if( parserState == ParserStates.EXTRACTING_PARAMETERS){
System.out.println("Done.");
}else{
Expand Down

0 comments on commit a2c45e0

Please sign in to comment.