Skip to content

Commit

Permalink
Update README.md and dist
Browse files Browse the repository at this point in the history
  • Loading branch information
erssebaggala committed May 1, 2019
1 parent 5110a7d commit 301c46b
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 90 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,24 @@
Coverts Huawei 2G,3G, and 4G CFGMML dumps to csv.

# Usage
java -jar huaweimmlparser.jar data.mml outputDirectory
```
usage: java -jar boda-huaweimmlparser.jar
Parses Huawei CFGMML files to csv
-c,--parameter-config <PARAMETER_CONFIG> parameter configuration file
-h,--help show help
-i,--input-file <INPUT_FILE> input file or directory name
-o,--output-directory <OUTPUT_DIRECTORY> output directory name
-p,--extract-parameters extract only the managed
objects and parameters
-v,--version display version
Examples:
java -jar boda-huaweimmlparser.jar -i cfgmml_dump.txt -o out_folder
java -jar boda-huaweimmlparser.jar -i input_folder -o out_folder
Copyright (c) 2019 Bodastage Solutions(http://www.bodastage.com)
```

# Download and installation
The lastest compiled jar file is availabled in the dist directory. Alternatively, download it directly from [here](https://github.com/bodastage/boda-huaweimmlparser/raw/master/dist/boda-huaweimmlparser.jar).
Expand Down
Binary file modified dist/boda-huaweimmlparser.jar
Binary file not shown.
17 changes: 14 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<groupId>com.bodastage.boda_huaweimmlparser</groupId>
<artifactId>boda-huaweimmlparser</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>boda-huaweimmlparser</name>
<version>1.3.0-SNAPSHOT</version>
<name>boda-huaweimmlparser-pr</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
Expand All @@ -14,11 +14,22 @@
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand All @@ -27,7 +38,7 @@
<configuration>
<archive>
<manifest>
<mainClass>com.bodastage.boda_huaweimmlparser.App</mainClass>
<mainClass>com.bodastage.boda_huaweimmlparser.HuaweiMMLParser</mainClass>
</manifest>
</archive>
<descriptorRefs>
Expand Down
86 changes: 0 additions & 86 deletions src/main/java/com/bodastage/boda_huaweimmlparser/App.java

This file was deleted.

185 changes: 185 additions & 0 deletions src/main/java/com/bodastage/boda_huaweimmlparser/HuaweiMMLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,28 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Stack;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;

/**
*
* @author [email protected]
*/
public class HuaweiMMLParser {

/**
* Current release version
*
* Since 1.3.0
*/
final static String VERSION = "1.3.0";


Logger logger = LoggerFactory.getLogger(HuaweiMMLParser.class);

public HuaweiMMLParser(){
Expand Down Expand Up @@ -236,6 +251,175 @@ public HuaweiMMLParser(){
*/
private String IP = null;

/**
* Extract managed objects and their parameters
*/
private Boolean extractParametersOnly = false;

/**
* Add meta fields to each MO. FILENAME, DATETIME
*/
private Boolean extractMetaFields = false;

public void setExtractParametersOnly(Boolean bool){
extractParametersOnly = bool;
}

public void setExtractMetaFields(Boolean bool){
extractMetaFields = bool;
}

public static void main( String[] args )
{

Options options = new Options();
CommandLine cmd = null;
String outputDirectory = null;
String inputFile = null;
String parameterConfigFile = null;
Boolean onlyExtractParameters = false;
Boolean showHelpMessage = false;
Boolean showVersion = false;
Boolean attachMetaFields = false; //Attach mattachMetaFields FILENAME,DATETIME,NE_TECHNOLOGY,NE_VENDOR,NE_VERSION,NE_TYPE

try{
options.addOption( "p", "extract-parameters", false, "extract only the managed objects and parameters" );
options.addOption( "v", "version", false, "display version" );
// options.addOption( "m", "meta-fields", false, "add meta fields to extracted parameters. FILENAME,DATETIME" );
options.addOption( Option.builder("i")
.longOpt( "input-file" )
.desc( "input file or directory name")
.hasArg()
.argName( "INPUT_FILE" ).build());
options.addOption(Option.builder("o")
.longOpt( "output-directory" )
.desc( "output directory name")
.hasArg()
.argName( "OUTPUT_DIRECTORY" ).build());
options.addOption(Option.builder("c")
.longOpt( "parameter-config" )
.desc( "parameter configuration file")
.hasArg()
.argName( "PARAMETER_CONFIG" ).build() );
options.addOption( "h", "help", false, "show help" );

//Parse command line arguments
CommandLineParser parser = new DefaultParser();
cmd = parser.parse( options, args);

if( cmd.hasOption("h")){
showHelpMessage = true;
}

if( cmd.hasOption("v")){
showVersion = true;
}

if(cmd.hasOption('o')){
outputDirectory = cmd.getOptionValue("o");
}

if(cmd.hasOption('i')){
inputFile = cmd.getOptionValue("i");
}

if(cmd.hasOption('c')){
parameterConfigFile = cmd.getOptionValue("c");
}

if(cmd.hasOption('p')){
onlyExtractParameters = true;
}

if(cmd.hasOption('m')){
attachMetaFields = true;
}

}catch(IllegalArgumentException e){

} catch (ParseException ex) {
// java.util.logging.Logger.getLogger(HuaweiCMObjectParser.class.getName()).log(Level.SEVERE, null, ex);
}


try{

if(showVersion == true ){
System.out.println(VERSION);
System.out.println("Copyright (c) 2019 Bodastage Solutions(http://www.bodastage.com)");
System.exit(0);
}

//show help
if( showHelpMessage == true ||
inputFile == null ||
( outputDirectory == null && onlyExtractParameters == false) ){
HelpFormatter formatter = new HelpFormatter();
String header = "Parses Huawei CFGMML files to csv\n\n";
String footer = "\n";
footer += "Examples: \n";
footer += "java -jar boda-huaweimmlparser.jar -i cfgmml_dump.txt -o out_folder\n";
footer += "java -jar boda-huaweimmlparser.jar -i input_folder -o out_folder\n";
footer += "\nCopyright (c) 2019 Bodastage Solutions(http://www.bodastage.com)";
formatter.printHelp( "java -jar boda-huaweimmlparser.jar", header, options, footer );
System.exit(0);
}

//Confirm that the output directory is a directory and has write
//privileges
if(outputDirectory != null ){
File fOutputDir = new File(outputDirectory);
if (!fOutputDir.isDirectory()) {
System.err.println("ERROR: The specified output directory is not a directory!.");
System.exit(1);
}

if (!fOutputDir.canWrite()) {
System.err.println("ERROR: Cannot write to output directory!");
System.exit(1);
}
}



//Get parser instance
HuaweiMMLParser cmParser = new HuaweiMMLParser();


if(onlyExtractParameters == true ){
cmParser.setExtractParametersOnly(true);
}

if( attachMetaFields == true ){
cmParser.setExtractMetaFields(true);
}

if( parameterConfigFile != null ){
File f = new File(parameterConfigFile);
if(f.isFile()){
cmParser.setParameterFile(parameterConfigFile);
cmParser.getParametersToExtract(parameterConfigFile);
cmParser.parserState = ParserStates.EXTRACTING_VALUES;
}
}


cmParser.setDataSource(inputFile);
if(outputDirectory != null ) cmParser.setOutputDirectory(outputDirectory);

cmParser.setOutputDirectory(outputDirectory);
cmParser.parse();
cmParser.printExecutionTime();

}catch(Exception e){
System.out.println(e.getMessage());
System.exit(1);
}


}


/**
* The file/directory to be parsed.
*
Expand Down Expand Up @@ -282,6 +466,7 @@ public void setParameterFile(String filename){
parameterFile = filename;
}


/**
* Extract parameter list from parameter file
*
Expand Down

0 comments on commit 301c46b

Please sign in to comment.