List of usage examples for org.apache.commons.cli OptionBuilder withDescription
public static OptionBuilder withDescription(String newDescription)
From source file:net.ladenthin.snowman.imager.run.CLI.java
@SuppressWarnings("static-access") public static void main(String[] args) throws Exception { try {/* ww w . j a v a 2 s. c o m*/ CommandLineParser parser = new PosixParser(); Options options = new Options(); options.addOption(cmdHelpS, cmdHelp, false, cmdHelpD); options.addOption(cmdVersionS, cmdVersion, false, cmdVersionD); options.addOption(OptionBuilder.withDescription(cmdConfigurationD).withLongOpt(cmdConfiguration) .hasArg().withArgName(cmdConfigurationA).create(cmdConfigurationS)); // parse the command line arguments CommandLine line = parser.parse(options, args); final String cmdLineSyntax = "java -jar " + Imager.jarFilename; // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); final String configurationPath; if (line.hasOption(cmdConfiguration)) { configurationPath = line.getOptionValue(cmdConfiguration); } else { System.out.println("Need configuration value."); formatter.printHelp(cmdLineSyntax, options); return; } // check parameter if (args.length == 0 || line.hasOption(cmdHelp)) { formatter.printHelp(cmdLineSyntax, options); return; } if (line.hasOption(cmdVersion)) { System.out.println(Imager.version); return; } Imager imager = new Imager(configurationPath); imager.waitForAllThreads(); imager.restartAndExit(); } catch (IllegalArgumentException | ParseException | IOException | InstantiationException | InterruptedException e) { LOGGER.error("Critical exception.", e); System.exit(-1); } }
From source file:apps.quantification.QuantifySVMPerf.java
public static void main(String[] args) throws IOException { String cmdLineSyntax = QuantifySVMPerf.class.getName() + " [OPTIONS] <path to svm_perf_classify> <testIndexDirectory> <quantificationModelDirectory>"; Options options = new Options(); OptionBuilder.withArgName("d"); OptionBuilder.withDescription("Dump confidences file"); OptionBuilder.withLongOpt("d"); OptionBuilder.isRequired(false);//from w ww. j a v a 2 s . co m OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("t"); OptionBuilder.withDescription("Path for temporary files"); OptionBuilder.withLongOpt("t"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("v"); OptionBuilder.withDescription("Verbose output"); OptionBuilder.withLongOpt("v"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("s"); OptionBuilder.withDescription("Don't delete temporary files in svm_perf format (default: delete)"); OptionBuilder.withLongOpt("s"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); SvmPerfClassifierCustomizer customizer = null; GnuParser parser = new GnuParser(); String[] remainingArgs = null; try { CommandLine line = parser.parse(options, args); remainingArgs = line.getArgs(); customizer = new SvmPerfClassifierCustomizer(remainingArgs[0]); if (line.hasOption("v")) customizer.printSvmPerfOutput(true); if (line.hasOption("s")) { System.out.println("Keeping temporary files."); customizer.setDeleteTestFiles(false); customizer.setDeletePredictionsFiles(false); } if (line.hasOption("t")) customizer.setTempPath(line.getOptionValue("t")); } catch (Exception exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(cmdLineSyntax, options); System.exit(-1); } if (remainingArgs.length != 3) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(cmdLineSyntax, options); System.exit(-1); } String indexFile = remainingArgs[1]; File file = new File(indexFile); String indexName = file.getName(); String indexPath = file.getParent(); String quantifierFilename = remainingArgs[2]; FileSystemStorageManager indexFssm = new FileSystemStorageManager(indexPath, false); indexFssm.open(); IIndex test = TroveReadWriteHelper.readIndex(indexFssm, indexName, TroveContentDBType.Full, TroveClassificationDBType.Full); indexFssm.close(); FileSystemStorageManager quantifierFssm = new FileSystemStorageManager(quantifierFilename, false); quantifierFssm.open(); SvmPerfDataManager classifierDataManager = new SvmPerfDataManager(customizer); FileSystemStorageManager fssm = new FileSystemStorageManager(quantifierFilename, false); fssm.open(); IQuantifier[] quantifiers = QuantificationLearner.read(fssm, classifierDataManager, ClassificationMode.PER_CATEGORY); fssm.close(); quantifierFssm.close(); Quantification ccQuantification = quantifiers[0].quantify(test); Quantification paQuantification = quantifiers[1].quantify(test); Quantification accQuantification = quantifiers[2].quantify(test); Quantification maxQuantification = quantifiers[3].quantify(test); Quantification sccQuantification = quantifiers[4].quantify(test); Quantification spaQuantification = quantifiers[5].quantify(test); Quantification trueQuantification = new Quantification("True", test.getClassificationDB()); File quantifierFile = new File(quantifierFilename); String quantificationName = quantifierFile.getParent() + Os.pathSeparator() + indexName + "_" + quantifierFile.getName() + ".txt"; BufferedWriter writer = new BufferedWriter(new FileWriter(quantificationName)); IShortIterator iterator = test.getCategoryDB().getCategories(); while (iterator.hasNext()) { short category = iterator.next(); String prefix = quantifierFile.getName() + "\t" + indexName + "\t" + test.getCategoryDB().getCategoryName(category) + "\t" + category + "\t" + trueQuantification.getQuantification(category) + "\t"; writer.write(prefix + ccQuantification.getName() + "\t" + ccQuantification.getQuantification(category) + "\n"); writer.write(prefix + paQuantification.getName() + "\t" + paQuantification.getQuantification(category) + "\n"); writer.write(prefix + accQuantification.getName() + "\t" + accQuantification.getQuantification(category) + "\n"); writer.write(prefix + maxQuantification.getName() + "\t" + maxQuantification.getQuantification(category) + "\n"); writer.write(prefix + sccQuantification.getName() + "\t" + sccQuantification.getQuantification(category) + "\n"); writer.write(prefix + spaQuantification.getName() + "\t" + spaQuantification.getQuantification(category) + "\n"); } writer.close(); BufferedWriter bfs = new BufferedWriter(new FileWriter(quantifierFile.getParent() + Os.pathSeparator() + indexName + "_" + quantifierFile.getName() + "_rates.txt")); TShortDoubleHashMap simpleTPRs = ((CCQuantifier) quantifiers[0]).getSimpleTPRs(); TShortDoubleHashMap simpleFPRs = ((CCQuantifier) quantifiers[0]).getSimpleFPRs(); TShortDoubleHashMap maxTPRs = ((CCQuantifier) ((ScaledQuantifier) quantifiers[3]).getInternalQuantifier()) .getSimpleTPRs(); TShortDoubleHashMap maxFPRs = ((CCQuantifier) ((ScaledQuantifier) quantifiers[3]).getInternalQuantifier()) .getSimpleFPRs(); TShortDoubleHashMap scaledTPRs = ((PAQuantifier) quantifiers[1]).getScaledTPRs(); TShortDoubleHashMap scaledFPRs = ((PAQuantifier) quantifiers[1]).getScaledFPRs(); ContingencyTableSet simpleContingencyTableSet = ((CCQuantifier) quantifiers[0]).getContingencyTableSet(); ContingencyTableSet maxContingencyTableSet = ((CCQuantifier) ((ScaledQuantifier) quantifiers[3]) .getInternalQuantifier()).getContingencyTableSet(); short[] cats = simpleTPRs.keys(); for (int i = 0; i < cats.length; ++i) { short cat = cats[i]; String catName = test.getCategoryDB().getCategoryName(cat); ContingencyTable simpleContingencyTable = simpleContingencyTableSet.getCategoryContingencyTable(cat); ContingencyTable maxContingencyTable = maxContingencyTableSet.getCategoryContingencyTable(cat); double simpleTPR = simpleTPRs.get(cat); double simpleFPR = simpleFPRs.get(cat); double maxTPR = maxTPRs.get(cat); double maxFPR = maxFPRs.get(cat); double scaledTPR = scaledTPRs.get(cat); double scaledFPR = scaledFPRs.get(cat); String line = indexName + "_" + quantifierFile.getName() + "\ttest\tsimple\t" + catName + "\t" + cat + "\t" + simpleContingencyTable.tp() + "\t" + simpleContingencyTable.fp() + "\t" + simpleContingencyTable.fn() + "\t" + simpleContingencyTable.tn() + "\t" + simpleTPR + "\t" + simpleFPR + "\n"; bfs.write(line); line = indexName + "_" + quantifierFile.getName() + "\ttest\tmax\t" + catName + "\t" + cat + "\t" + maxContingencyTable.tp() + "\t" + maxContingencyTable.fp() + "\t" + maxContingencyTable.fn() + "\t" + maxContingencyTable.tn() + "\t" + maxTPR + "\t" + maxFPR + "\n"; bfs.write(line); line = indexName + "_" + quantifierFile.getName() + "\ttest\tscaled\t" + catName + "\t" + cat + "\t" + simpleContingencyTable.tp() + "\t" + simpleContingencyTable.fp() + "\t" + simpleContingencyTable.fn() + "\t" + simpleContingencyTable.tn() + "\t" + scaledTPR + "\t" + scaledFPR + "\n"; bfs.write(line); } bfs.close(); }
From source file:apps.quantification.QuantifySVMLight.java
public static void main(String[] args) throws IOException { String cmdLineSyntax = QuantifySVMLight.class.getName() + " [OPTIONS] <path to svm_light_classify> <testIndexDirectory> <quantificationModelDirectory>"; Options options = new Options(); OptionBuilder.withArgName("d"); OptionBuilder.withDescription("Dump confidences file"); OptionBuilder.withLongOpt("d"); OptionBuilder.isRequired(false);/*from w ww.j av a 2 s. c om*/ OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("t"); OptionBuilder.withDescription("Path for temporary files"); OptionBuilder.withLongOpt("t"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("v"); OptionBuilder.withDescription("Verbose output"); OptionBuilder.withLongOpt("v"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("s"); OptionBuilder.withDescription("Don't delete temporary files in svm_light format (default: delete)"); OptionBuilder.withLongOpt("s"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); SvmLightClassifierCustomizer customizer = null; GnuParser parser = new GnuParser(); String[] remainingArgs = null; try { CommandLine line = parser.parse(options, args); remainingArgs = line.getArgs(); customizer = new SvmLightClassifierCustomizer(remainingArgs[0]); if (line.hasOption("v")) customizer.printSvmLightOutput(true); if (line.hasOption("s")) { System.out.println("Keeping temporary files."); customizer.setDeleteTestFiles(false); customizer.setDeletePredictionsFiles(false); } if (line.hasOption("t")) customizer.setTempPath(line.getOptionValue("t")); } catch (Exception exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(cmdLineSyntax, options); System.exit(-1); } if (remainingArgs.length != 3) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(cmdLineSyntax, options); System.exit(-1); } String indexFile = remainingArgs[1]; File file = new File(indexFile); String indexName = file.getName(); String indexPath = file.getParent(); String quantifierFilename = remainingArgs[2]; FileSystemStorageManager indexFssm = new FileSystemStorageManager(indexPath, false); indexFssm.open(); IIndex test = TroveReadWriteHelper.readIndex(indexFssm, indexName, TroveContentDBType.Full, TroveClassificationDBType.Full); indexFssm.close(); FileSystemStorageManager quantifierFssm = new FileSystemStorageManager(quantifierFilename, false); quantifierFssm.open(); SvmLightDataManager classifierDataManager = new SvmLightDataManager(customizer); FileSystemStorageManager fssm = new FileSystemStorageManager(quantifierFilename, false); fssm.open(); IQuantifier[] quantifiers = QuantificationLearner.read(fssm, classifierDataManager, ClassificationMode.PER_CATEGORY); fssm.close(); quantifierFssm.close(); Quantification ccQuantification = quantifiers[0].quantify(test); Quantification paQuantification = quantifiers[1].quantify(test); Quantification accQuantification = quantifiers[2].quantify(test); Quantification maxQuantification = quantifiers[3].quantify(test); Quantification sccQuantification = quantifiers[4].quantify(test); Quantification spaQuantification = quantifiers[5].quantify(test); Quantification trueQuantification = new Quantification("True", test.getClassificationDB()); File quantifierFile = new File(quantifierFilename); String quantificationName = quantifierFile.getParent() + Os.pathSeparator() + indexName + "_" + quantifierFile.getName() + ".txt"; BufferedWriter writer = new BufferedWriter(new FileWriter(quantificationName)); IShortIterator iterator = test.getCategoryDB().getCategories(); while (iterator.hasNext()) { short category = iterator.next(); String prefix = quantifierFile.getName() + "\t" + indexName + "\t" + test.getCategoryDB().getCategoryName(category) + "\t" + category + "\t" + trueQuantification.getQuantification(category) + "\t"; writer.write(prefix + ccQuantification.getName() + "\t" + ccQuantification.getQuantification(category) + "\n"); writer.write(prefix + paQuantification.getName() + "\t" + paQuantification.getQuantification(category) + "\n"); writer.write(prefix + accQuantification.getName() + "\t" + accQuantification.getQuantification(category) + "\n"); writer.write(prefix + maxQuantification.getName() + "\t" + maxQuantification.getQuantification(category) + "\n"); writer.write(prefix + sccQuantification.getName() + "\t" + sccQuantification.getQuantification(category) + "\n"); writer.write(prefix + spaQuantification.getName() + "\t" + spaQuantification.getQuantification(category) + "\n"); } writer.close(); BufferedWriter bfs = new BufferedWriter(new FileWriter(quantifierFile.getParent() + Os.pathSeparator() + indexName + "_" + quantifierFile.getName() + "_rates.txt")); TShortDoubleHashMap simpleTPRs = ((CCQuantifier) quantifiers[0]).getSimpleTPRs(); TShortDoubleHashMap simpleFPRs = ((CCQuantifier) quantifiers[0]).getSimpleFPRs(); TShortDoubleHashMap maxTPRs = ((CCQuantifier) ((ScaledQuantifier) quantifiers[3]).getInternalQuantifier()) .getSimpleTPRs(); TShortDoubleHashMap maxFPRs = ((CCQuantifier) ((ScaledQuantifier) quantifiers[3]).getInternalQuantifier()) .getSimpleFPRs(); TShortDoubleHashMap scaledTPRs = ((PAQuantifier) quantifiers[1]).getScaledTPRs(); TShortDoubleHashMap scaledFPRs = ((PAQuantifier) quantifiers[1]).getScaledFPRs(); ContingencyTableSet simpleContingencyTableSet = ((CCQuantifier) quantifiers[0]).getContingencyTableSet(); ContingencyTableSet maxContingencyTableSet = ((CCQuantifier) ((ScaledQuantifier) quantifiers[3]) .getInternalQuantifier()).getContingencyTableSet(); short[] cats = simpleTPRs.keys(); for (int i = 0; i < cats.length; ++i) { short cat = cats[i]; String catName = test.getCategoryDB().getCategoryName(cat); ContingencyTable simpleContingencyTable = simpleContingencyTableSet.getCategoryContingencyTable(cat); ContingencyTable maxContingencyTable = maxContingencyTableSet.getCategoryContingencyTable(cat); double simpleTPR = simpleTPRs.get(cat); double simpleFPR = simpleFPRs.get(cat); double maxTPR = maxTPRs.get(cat); double maxFPR = maxFPRs.get(cat); double scaledTPR = scaledTPRs.get(cat); double scaledFPR = scaledFPRs.get(cat); String line = indexName + "_" + quantifierFile.getName() + "\ttest\tsimple\t" + catName + "\t" + cat + "\t" + simpleContingencyTable.tp() + "\t" + simpleContingencyTable.fp() + "\t" + simpleContingencyTable.fn() + "\t" + simpleContingencyTable.tn() + "\t" + simpleTPR + "\t" + simpleFPR + "\n"; bfs.write(line); line = indexName + "_" + quantifierFile.getName() + "\ttest\tmax\t" + catName + "\t" + cat + "\t" + maxContingencyTable.tp() + "\t" + maxContingencyTable.fp() + "\t" + maxContingencyTable.fn() + "\t" + maxContingencyTable.tn() + "\t" + maxTPR + "\t" + maxFPR + "\n"; bfs.write(line); line = indexName + "_" + quantifierFile.getName() + "\ttest\tscaled\t" + catName + "\t" + cat + "\t" + simpleContingencyTable.tp() + "\t" + simpleContingencyTable.fp() + "\t" + simpleContingencyTable.fn() + "\t" + simpleContingencyTable.tn() + "\t" + scaledTPR + "\t" + scaledFPR + "\n"; bfs.write(line); } bfs.close(); }
From source file:com.enioka.jqm.tools.Main.java
/** * Startup method for the packaged JAR/* ww w . j a va 2s .com*/ * * @param args * 0 is node name */ @SuppressWarnings("static-access") public static void main(String[] args) { Helpers.setLogFileName("cli"); Option o00 = OptionBuilder.withArgName("nodeName").hasArg().withDescription("name of the JQM node to start") .isRequired().create("startnode"); Option o01 = OptionBuilder.withDescription("display help").withLongOpt("help").create("h"); Option o11 = OptionBuilder.withArgName("applicationname").hasArg() .withDescription("name of the application to launch").isRequired().create("enqueue"); Option o21 = OptionBuilder.withArgName("xmlpath").hasArg() .withDescription("path of the XML configuration file to import").isRequired() .create("importjobdef"); Option o31 = OptionBuilder.withArgName("xmlpath").hasArg() .withDescription("export all queue definitions into an XML file").isRequired() .create("exportallqueues"); OptionBuilder.withArgName("xmlpath").hasArg() .withDescription("export some queue definitions into an XML file").isRequired() .create("exportqueuefile"); OptionBuilder.withArgName("queues").hasArg().withDescription("queues to export").withValueSeparator(',') .isRequired().create("queue"); Option o51 = OptionBuilder.withArgName("xmlpath").hasArg() .withDescription("import all queue definitions from an XML file").isRequired() .create("importqueuefile"); Option o61 = OptionBuilder.withArgName("nodeName").hasArg() .withDescription("creates a JQM node of this name, or updates it if it exists. Implies -u.") .isRequired().create("createnode"); Option o71 = OptionBuilder.withDescription("display JQM engine version").withLongOpt("version").create("v"); Option o81 = OptionBuilder.withDescription("upgrade JQM database").withLongOpt("upgrade").create("u"); Option o91 = OptionBuilder.withArgName("jobInstanceId").hasArg() .withDescription("get job instance status by ID").isRequired().withLongOpt("getstatus").create("g"); Option o101 = OptionBuilder.withArgName("password").hasArg() .withDescription("creates or resets root admin account password").isRequired().withLongOpt("root") .create("r"); Option o111 = OptionBuilder.withArgName("option").hasArg() .withDescription( "ws handling. Possible values are: enable, disable, ssl, nossl, internalpki, externalapi") .isRequired().withLongOpt("gui").create("w"); Option o121 = OptionBuilder.withArgName("id[,logfilepath]").hasArg().withDescription("single launch mode") .isRequired().withLongOpt("gui").create("s"); Option o131 = OptionBuilder.withArgName("resourcefile").hasArg() .withDescription("resource parameter file to use. Default is resources.xml") .withLongOpt("resources").create("p"); Option o141 = OptionBuilder.withArgName("login,password,role1,role2,...").hasArgs(Option.UNLIMITED_VALUES) .withValueSeparator(',') .withDescription("Create or update a JQM account. Roles must exist beforehand.").create("U"); Options options = new Options(); OptionGroup og1 = new OptionGroup(); og1.setRequired(true); og1.addOption(o00); og1.addOption(o01); og1.addOption(o11); og1.addOption(o21); og1.addOption(o31); og1.addOption(o51); og1.addOption(o61); og1.addOption(o71); og1.addOption(o81); og1.addOption(o91); og1.addOption(o101); og1.addOption(o111); og1.addOption(o121); og1.addOption(o141); options.addOptionGroup(og1); OptionGroup og2 = new OptionGroup(); og2.addOption(o131); options.addOptionGroup(og2); HelpFormatter formatter = new HelpFormatter(); formatter.setWidth(160); try { // Parse arguments CommandLineParser parser = new BasicParser(); CommandLine line = parser.parse(options, args); // Other db connection? if (line.getOptionValue(o131.getOpt()) != null) { jqmlogger.info("Using resource XML file " + line.getOptionValue(o131.getOpt())); Helpers.resourceFile = line.getOptionValue(o131.getOpt()); } // Set db connection Helpers.registerJndiIfNeeded(); // Enqueue if (line.getOptionValue(o11.getOpt()) != null) { enqueue(line.getOptionValue(o11.getOpt())); } // Get status if (line.getOptionValue(o91.getOpt()) != null) { getStatus(Integer.parseInt(line.getOptionValue(o91.getOpt()))); } // Import XML else if (line.getOptionValue(o21.getOpt()) != null) { importJobDef(line.getOptionValue(o21.getOpt())); } // Start engine else if (line.getOptionValue(o00.getOpt()) != null) { startEngine(line.getOptionValue(o00.getOpt())); } // Export all Queues else if (line.getOptionValue(o31.getOpt()) != null) { exportAllQueues(line.getOptionValue(o31.getOpt())); } // Import queues else if (line.getOptionValue(o51.getOpt()) != null) { importQueues(line.getOptionValue(o51.getOpt())); } // Create node else if (line.getOptionValue(o61.getOpt()) != null) { createEngine(line.getOptionValue(o61.getOpt())); } // Upgrade else if (line.hasOption(o81.getOpt())) { upgrade(); } // Help else if (line.hasOption(o01.getOpt())) { formatter.printHelp("java -jar jqm-engine.jar", options, true); } // Version else if (line.hasOption(o71.getOpt())) { jqmlogger.info("Engine version: " + Helpers.getMavenVersion()); } // Root password else if (line.hasOption(o101.getOpt())) { root(line.getOptionValue(o101.getOpt())); } // Web options else if (line.hasOption(o111.getOpt())) { ws(line.getOptionValue(o111.getOpt())); } // Web options else if (line.hasOption(o121.getOpt())) { single(line.getOptionValue(o121.getOpt())); } // User handling else if (line.hasOption(o141.getOpt())) { user(line.getOptionValues(o141.getOpt())); } } catch (ParseException exp) { jqmlogger.fatal("Could not read command line: " + exp.getMessage()); formatter.printHelp("java -jar jqm-engine.jar", options, true); return; } }
From source file:jp.primecloud.auto.tool.management.main.Main.java
public static void main(String args[]) { Options options = new Options(); options.addOption("Z", false, "Zabbix mode"); options.addOption("U", false, "UPDATE mode"); options.addOption("S", false, "SELECT mode"); options.addOption("C", false, "Create Mode"); options.addOption("P", false, "Show Platform"); options.addOption("L", false, "Show Users"); options.addOption("E", false, "Ecrypt UserPassword"); options.addOption("I", false, "IaasGateway Mode"); options.addOption("A", false, "PCC-API Genarate ID or Key Mode"); options.addOption("W", false, "Decrypt UserPassword"); options.addOption("username", true, "Create the username"); options.addOption("password", true, "Create the password"); options.addOption("firstname", true, "Create the firstname"); options.addOption("familyname", true, "Create the familyname"); options.addOption("userno", true, "Create the userno"); options.addOption("dburl", "connectionurl", true, "PrimeCloud Controller database url"); options.addOption("dbuser", "username", true, "PrimeCloud Controller database username"); options.addOption("dbpass", "password", true, "PrimeCloud Controller database password"); options.addOption("sql", true, "SQL"); options.addOption("columnname", true, "columnName"); options.addOption("columntype", true, "columnType"); options.addOption("salt", true, "Salt"); OptionBuilder.withLongOpt("prepared"); OptionBuilder.hasArgs();//ww w. j a v a 2 s.c o m OptionBuilder.withDescription("execute as PreparedStatement"); OptionBuilder.withArgName("params"); Option optionPrepared = OptionBuilder.create(); options.addOption(optionPrepared); // for Zabbix options.addOption("enable", false, "enable"); options.addOption("disable", false, "disable"); options.addOption("get", false, "getUser from zabbix"); options.addOption("check", false, "API setting check for zabbix"); options.addOption("config", true, "Property can obtain from management-config.properties"); options.addOption("platformkind", true, "Platform kind. e.g. ec2 and ec2_vpc or vmware"); options.addOption("platformname", true, "Platform can obtain from auto-config.xml"); options.addOption("platformno", true, "Platform can obtain from auto-config.xml"); // for IaasGateway(AWS, Cloudstack) options.addOption("keyname", true, "import your key pair as keyName"); options.addOption("publickey", true, "import your public key"); // for PCC options.addOption("accessid", true, "accessid for PCC-API"); options.addOption("secretkey", true, "secretkey for PCC-API"); options.addOption("generatetype", true, "genarateType for PCC-API"); options.addOption("h", "help", false, "help"); CommandLineParser parser = new BasicParser(); CommandLine commandLine; try { commandLine = parser.parse(options, args); } catch (ParseException e) { System.out.println( "???????? -h?????????"); return; } if (commandLine.hasOption("h")) { HelpFormatter f = new HelpFormatter(); f.printHelp("PCC script ", options); } ManagementConfigLoader.init(); //? //Zabbix? if (commandLine.hasOption("Z")) { if (commandLine.hasOption("C")) { //Zabbix? ZabbixMain.createExecute(commandLine); } else if (commandLine.hasOption("U")) { //Zabbix ZabbixMain.updateExecute(commandLine); } else if (commandLine.hasOption("disable")) { //Zabbix ZabbixMain.disableExecute(commandLine); } else if (commandLine.hasOption("enable")) { //Zabbix ZabbixMain.enableExecute(commandLine); } else if (commandLine.hasOption("get")) { //Zabbix? ZabbixMain.getUser(commandLine); } else if (commandLine.hasOption("check")) { //Zabbix?? ZabbixMain.checkApiVersion(); } //PCC? } else if (commandLine.hasOption("U")) { if (commandLine.hasOption("prepared")) { SQLMain.updateExecutePrepared(commandLine); } else { //Update? SQLMain.updateExecute(commandLine); } } else if (commandLine.hasOption("S")) { //Select? SQLMain.selectExecute(commandLine); } else if (commandLine.hasOption("P")) { //? ConfigMain.showPlatforms(); } else if (commandLine.hasOption("L")) { //PCC? UserService.showUserPlatform(); } else if (commandLine.hasOption("config")) { //??? ConfigMain.getProperty(commandLine.getOptionValue("config")); } else if (commandLine.hasOption("platformname") && commandLine.hasOption("platformkind")) { //?????? ConfigMain.getPlatformNo(commandLine.getOptionValue("platformname"), commandLine.getOptionValue("platformkind")); } else if (commandLine.hasOption("E")) { //PCC?? UserService.encryptUserPassword(commandLine.getOptionValue("password")); } else if (commandLine.hasOption("I")) { //IaasGatewayCall??AWS or Cloudstack??? IaasGatewayMain.importExecute(commandLine); } else if (commandLine.hasOption("A")) { PccApiGenerateService.genarate(commandLine); } else if (commandLine.hasOption("W")) { //PCC?? UserService.decryptUserPassword(commandLine.getOptionValue("password"), commandLine.getOptionValue("salt")); } }
From source file:apps.quantification.LearnQuantificationSVMLight.java
public static void main(String[] args) throws IOException { String cmdLineSyntax = LearnQuantificationSVMLight.class.getName() + " [OPTIONS] <path to svm_light_learn> <path to svm_light_classify> <trainingIndexDirectory> <outputDirectory>"; Options options = new Options(); OptionBuilder.withArgName("f"); OptionBuilder.withDescription("Number of folds"); OptionBuilder.withLongOpt("f"); OptionBuilder.isRequired(true);// ww w.j a v a 2 s . c o m OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("c"); OptionBuilder.withDescription("The c value for svm_light (default 1)"); OptionBuilder.withLongOpt("c"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("k"); OptionBuilder.withDescription("Kernel type (default 0: linear, 1: polynomial, 2: RBF, 3: sigmoid)"); OptionBuilder.withLongOpt("k"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("t"); OptionBuilder.withDescription("Path for temporary files"); OptionBuilder.withLongOpt("t"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("v"); OptionBuilder.withDescription("Verbose output"); OptionBuilder.withLongOpt("v"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("s"); OptionBuilder.withDescription("Don't delete temporary training file in svm_light format (default: delete)"); OptionBuilder.withLongOpt("s"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); SvmLightLearnerCustomizer classificationLearnerCustomizer = null; SvmLightClassifierCustomizer classificationCustomizer = null; int folds = -1; GnuParser parser = new GnuParser(); String[] remainingArgs = null; try { CommandLine line = parser.parse(options, args); remainingArgs = line.getArgs(); classificationLearnerCustomizer = new SvmLightLearnerCustomizer(remainingArgs[0]); classificationCustomizer = new SvmLightClassifierCustomizer(remainingArgs[1]); folds = Integer.parseInt(line.getOptionValue("f")); if (line.hasOption("c")) classificationLearnerCustomizer.setC(Float.parseFloat(line.getOptionValue("c"))); if (line.hasOption("k")) { System.out.println("Kernel type: " + line.getOptionValue("k")); classificationLearnerCustomizer.setKernelType(Integer.parseInt(line.getOptionValue("k"))); } if (line.hasOption("v")) classificationLearnerCustomizer.printSvmLightOutput(true); if (line.hasOption("s")) classificationLearnerCustomizer.setDeleteTrainingFiles(false); if (line.hasOption("t")) { classificationLearnerCustomizer.setTempPath(line.getOptionValue("t")); classificationCustomizer.setTempPath(line.getOptionValue("t")); } } catch (Exception exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(cmdLineSyntax, options); System.exit(-1); } assert (classificationLearnerCustomizer != null); if (remainingArgs.length != 4) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(cmdLineSyntax, options); System.exit(-1); } String indexFile = remainingArgs[2]; File file = new File(indexFile); String indexName = file.getName(); String indexPath = file.getParent(); String outputPath = remainingArgs[3]; SvmLightLearner classificationLearner = new SvmLightLearner(); classificationLearner.setRuntimeCustomizer(classificationLearnerCustomizer); FileSystemStorageManager fssm = new FileSystemStorageManager(indexPath, false); fssm.open(); IIndex training = TroveReadWriteHelper.readIndex(fssm, indexName, TroveContentDBType.Full, TroveClassificationDBType.Full); final TextualProgressBar progressBar = new TextualProgressBar("Learning the quantifiers"); IOperationStatusListener status = new IOperationStatusListener() { @Override public void operationStatus(double percentage) { progressBar.signal((int) percentage); } }; QuantificationLearner quantificationLearner = new QuantificationLearner(folds, classificationLearner, classificationLearnerCustomizer, classificationCustomizer, ClassificationMode.PER_CATEGORY, new LogisticFunction(), status); IQuantifier[] quantifiers = quantificationLearner.learn(training); File executableFile = new File(classificationLearnerCustomizer.getSvmLightLearnPath()); IDataManager classifierDataManager = new SvmLightDataManager(new SvmLightClassifierCustomizer( executableFile.getParentFile().getAbsolutePath() + Os.pathSeparator() + "svm_light_classify")); String description = "_SVMLight_C-" + classificationLearnerCustomizer.getC() + "_K-" + classificationLearnerCustomizer.getKernelType(); if (classificationLearnerCustomizer.getAdditionalParameters().length() > 0) description += "_" + classificationLearnerCustomizer.getAdditionalParameters(); String quantifierPrefix = indexName + "_Quantifier-" + folds + description; FileSystemStorageManager fssmo = new FileSystemStorageManager( outputPath + File.separatorChar + quantifierPrefix, true); fssmo.open(); QuantificationLearner.write(quantifiers, fssmo, classifierDataManager); fssmo.close(); BufferedWriter bfs = new BufferedWriter( new FileWriter(outputPath + File.separatorChar + quantifierPrefix + "_rates.txt")); TShortDoubleHashMap simpleTPRs = quantificationLearner.getSimpleTPRs(); TShortDoubleHashMap simpleFPRs = quantificationLearner.getSimpleFPRs(); TShortDoubleHashMap scaledTPRs = quantificationLearner.getScaledTPRs(); TShortDoubleHashMap scaledFPRs = quantificationLearner.getScaledFPRs(); ContingencyTableSet contingencyTableSet = quantificationLearner.getContingencyTableSet(); short[] cats = simpleTPRs.keys(); for (int i = 0; i < cats.length; ++i) { short cat = cats[i]; String catName = training.getCategoryDB().getCategoryName(cat); ContingencyTable contingencyTable = contingencyTableSet.getCategoryContingencyTable(cat); double simpleTPR = simpleTPRs.get(cat); double simpleFPR = simpleFPRs.get(cat); double scaledTPR = scaledTPRs.get(cat); double scaledFPR = scaledFPRs.get(cat); String line = quantifierPrefix + "\ttrain\tsimple\t" + catName + "\t" + cat + "\t" + contingencyTable.tp() + "\t" + contingencyTable.fp() + "\t" + contingencyTable.fn() + "\t" + contingencyTable.tn() + "\t" + simpleTPR + "\t" + simpleFPR + "\n"; bfs.write(line); line = quantifierPrefix + "\ttrain\tscaled\t" + catName + "\t" + cat + "\t" + contingencyTable.tp() + "\t" + contingencyTable.fp() + "\t" + contingencyTable.fn() + "\t" + contingencyTable.tn() + "\t" + scaledTPR + "\t" + scaledFPR + "\n"; bfs.write(line); } bfs.close(); }
From source file:apps.quantification.LearnQuantificationSVMPerf.java
public static void main(String[] args) throws IOException { String cmdLineSyntax = LearnQuantificationSVMPerf.class.getName() + " [OPTIONS] <path to svm_perf_learn> <path to svm_perf_classify> <trainingIndexDirectory> <outputDirectory>"; Options options = new Options(); OptionBuilder.withArgName("f"); OptionBuilder.withDescription("Number of folds"); OptionBuilder.withLongOpt("f"); OptionBuilder.isRequired(true);//from www . ja va2 s . com OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("c"); OptionBuilder.withDescription("The c value for svm_perf (default 0.01)"); OptionBuilder.withLongOpt("c"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("t"); OptionBuilder.withDescription("Path for temporary files"); OptionBuilder.withLongOpt("t"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("l"); OptionBuilder.withDescription("The loss function to optimize (default 2):\n" + " 0 Zero/one loss: 1 if vector of predictions contains error, 0 otherwise.\n" + " 1 F1: 100 minus the F1-score in percent.\n" + " 2 Errorrate: Percentage of errors in prediction vector.\n" + " 3 Prec/Rec Breakeven: 100 minus PRBEP in percent.\n" + " 4 Prec@p: 100 minus precision at p in percent.\n" + " 5 Rec@p: 100 minus recall at p in percent.\n" + " 10 ROCArea: Percentage of swapped pos/neg pairs (i.e. 100 - ROCArea)."); OptionBuilder.withLongOpt("l"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("w"); OptionBuilder.withDescription("Choice of structural learning algorithm (default 9):\n" + " 0: n-slack algorithm described in [2]\n" + " 1: n-slack algorithm with shrinking heuristic\n" + " 2: 1-slack algorithm (primal) described in [5]\n" + " 3: 1-slack algorithm (dual) described in [5]\n" + " 4: 1-slack algorithm (dual) with constraint cache [5]\n" + " 9: custom algorithm in svm_struct_learn_custom.c"); OptionBuilder.withLongOpt("w"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("p"); OptionBuilder.withDescription("The value of p used by the prec@p and rec@p loss functions (default 0)"); OptionBuilder.withLongOpt("p"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("v"); OptionBuilder.withDescription("Verbose output"); OptionBuilder.withLongOpt("v"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); OptionBuilder.withArgName("s"); OptionBuilder.withDescription("Don't delete temporary training file in svm_perf format (default: delete)"); OptionBuilder.withLongOpt("s"); OptionBuilder.isRequired(false); OptionBuilder.hasArg(false); options.addOption(OptionBuilder.create()); SvmPerfLearnerCustomizer classificationLearnerCustomizer = null; SvmPerfClassifierCustomizer classificationCustomizer = null; int folds = -1; GnuParser parser = new GnuParser(); String[] remainingArgs = null; try { CommandLine line = parser.parse(options, args); remainingArgs = line.getArgs(); classificationLearnerCustomizer = new SvmPerfLearnerCustomizer(remainingArgs[0]); classificationCustomizer = new SvmPerfClassifierCustomizer(remainingArgs[1]); folds = Integer.parseInt(line.getOptionValue("f")); if (line.hasOption("c")) classificationLearnerCustomizer.setC(Float.parseFloat(line.getOptionValue("c"))); if (line.hasOption("w")) classificationLearnerCustomizer.setW(Integer.parseInt(line.getOptionValue("w"))); if (line.hasOption("p")) classificationLearnerCustomizer.setP(Integer.parseInt(line.getOptionValue("p"))); if (line.hasOption("l")) classificationLearnerCustomizer.setL(Integer.parseInt(line.getOptionValue("l"))); if (line.hasOption("v")) classificationLearnerCustomizer.printSvmPerfOutput(true); if (line.hasOption("s")) classificationLearnerCustomizer.setDeleteTrainingFiles(false); if (line.hasOption("t")) { classificationLearnerCustomizer.setTempPath(line.getOptionValue("t")); classificationCustomizer.setTempPath(line.getOptionValue("t")); } } catch (Exception exp) { System.err.println("Parsing failed. Reason: " + exp.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(cmdLineSyntax, options); System.exit(-1); } assert (classificationLearnerCustomizer != null); if (remainingArgs.length != 4) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(cmdLineSyntax, options); System.exit(-1); } String indexFile = remainingArgs[2]; File file = new File(indexFile); String indexName = file.getName(); String indexPath = file.getParent(); String outputPath = remainingArgs[3]; SvmPerfLearner classificationLearner = new SvmPerfLearner(); classificationLearner.setRuntimeCustomizer(classificationLearnerCustomizer); FileSystemStorageManager fssm = new FileSystemStorageManager(indexPath, false); fssm.open(); IIndex training = TroveReadWriteHelper.readIndex(fssm, indexName, TroveContentDBType.Full, TroveClassificationDBType.Full); final TextualProgressBar progressBar = new TextualProgressBar("Learning the quantifiers"); IOperationStatusListener status = new IOperationStatusListener() { @Override public void operationStatus(double percentage) { progressBar.signal((int) percentage); } }; QuantificationLearner quantificationLearner = new QuantificationLearner(folds, classificationLearner, classificationLearnerCustomizer, classificationCustomizer, ClassificationMode.PER_CATEGORY, new LogisticFunction(), status); IQuantifier[] quantifiers = quantificationLearner.learn(training); File executableFile = new File(classificationLearnerCustomizer.getSvmPerfLearnPath()); IDataManager classifierDataManager = new SvmPerfDataManager(new SvmPerfClassifierCustomizer( executableFile.getParentFile().getAbsolutePath() + Os.pathSeparator() + "svm_perf_classify")); String description = "_SVMPerf_C-" + classificationLearnerCustomizer.getC() + "_W-" + classificationLearnerCustomizer.getW() + "_L-" + classificationLearnerCustomizer.getL(); if (classificationLearnerCustomizer.getL() == 4 || classificationLearnerCustomizer.getL() == 5) description += "_P-" + classificationLearnerCustomizer.getP(); if (classificationLearnerCustomizer.getAdditionalParameters().length() > 0) description += "_" + classificationLearnerCustomizer.getAdditionalParameters(); String quantifierPrefix = indexName + "_Quantifier-" + folds + description; FileSystemStorageManager fssmo = new FileSystemStorageManager( outputPath + File.separatorChar + quantifierPrefix, true); fssmo.open(); QuantificationLearner.write(quantifiers, fssmo, classifierDataManager); fssmo.close(); BufferedWriter bfs = new BufferedWriter( new FileWriter(outputPath + File.separatorChar + quantifierPrefix + "_rates.txt")); TShortDoubleHashMap simpleTPRs = quantificationLearner.getSimpleTPRs(); TShortDoubleHashMap simpleFPRs = quantificationLearner.getSimpleFPRs(); TShortDoubleHashMap scaledTPRs = quantificationLearner.getScaledTPRs(); TShortDoubleHashMap scaledFPRs = quantificationLearner.getScaledFPRs(); ContingencyTableSet contingencyTableSet = quantificationLearner.getContingencyTableSet(); short[] cats = simpleTPRs.keys(); for (int i = 0; i < cats.length; ++i) { short cat = cats[i]; String catName = training.getCategoryDB().getCategoryName(cat); ContingencyTable contingencyTable = contingencyTableSet.getCategoryContingencyTable(cat); double simpleTPR = simpleTPRs.get(cat); double simpleFPR = simpleFPRs.get(cat); double scaledTPR = scaledTPRs.get(cat); double scaledFPR = scaledFPRs.get(cat); String line = quantifierPrefix + "\ttrain\tsimple\t" + catName + "\t" + cat + "\t" + contingencyTable.tp() + "\t" + contingencyTable.fp() + "\t" + contingencyTable.fn() + "\t" + contingencyTable.tn() + "\t" + simpleTPR + "\t" + simpleFPR + "\n"; bfs.write(line); line = quantifierPrefix + "\ttrain\tscaled\t" + catName + "\t" + cat + "\t" + contingencyTable.tp() + "\t" + contingencyTable.fp() + "\t" + contingencyTable.fn() + "\t" + contingencyTable.tn() + "\t" + scaledTPR + "\t" + scaledFPR + "\n"; bfs.write(line); } bfs.close(); }
From source file:net.extemporal.test.Main.java
public static void main(String[] args) throws IOException { Options opts = new Options(); opts.addOption(OptionBuilder.withDescription("email id for 1st account").hasArg(true).create("e1")); opts.addOption(//from ww w .ja v a 2s . c om OptionBuilder.withDescription("either gmail password or full URNs for Store and Transport servers") .hasOptionalArgs(3).create("c1")); opts.addOption(OptionBuilder.withDescription("email id for 2nd account").hasArg(true).create("e2")); opts.addOption( OptionBuilder.withDescription("either gmail password or full URNs for Store and Transport servers") .hasOptionalArgs(3).create("c2")); // this parses the command line but doesn't throw an exception on unknown options try { CommandLine cmd = new GnuParser().parse(opts, args, true); if (cmd.hasOption("e1") && cmd.hasOption("c1")) { String e = cmd.getOptionValue("e1"); String[] accounts = cmd.getOptionValues("c1"); if (accounts.length == 1) email1 = EmailTestPlatform.getGMailCredentials(e, accounts[0]); else if (email1.length == 2) { email1 = new String[] { e, accounts[0], accounts[1] }; } } if (cmd.hasOption("e2") && cmd.hasOption("c2")) { String e = cmd.getOptionValue("e2"); String[] accounts = cmd.getOptionValues("c2"); if (accounts.length == 1) email2 = EmailTestPlatform.getGMailCredentials(e, accounts[0]); else if (email2.length == 2) { email2 = new String[] { e, accounts[0], accounts[1] }; } } } catch (ParseException pex) { System.err.println("error parsing commandline: " + pex); } ShellFactory.createConsoleShell("test-harness", "Type '?list' to see valid commands", new Main()) .commandLoop(); }
From source file:de.dominicscheurer.passwords.Main.java
/** * @param args//from w w w.j a v a2 s. co m * Command line arguments (see code or output of program when * started with no arguments). */ @SuppressWarnings("static-access") public static void main(String[] args) { Options options = new Options(); Option seedPwdOpt = OptionBuilder.withArgName("Seed Password").isRequired().hasArg() .withDescription("Password used as a seed").withLongOpt("seed-password").create("s"); Option serviceIdOpt = OptionBuilder.withArgName("Service Identifier").isRequired().hasArg() .withDescription("The service that the password is created for, e.g. facebook.com") .withLongOpt("service-identifier").create("i"); Option pwdLengthOpt = OptionBuilder.withArgName("Password Length").withType(Integer.class).hasArg() .withDescription("Length of the password in characters").withLongOpt("pwd-length").create("l"); Option specialChars = OptionBuilder.withArgName("With special chars (TRUE|false)").withType(Boolean.class) .hasArg().withDescription("Set to true if special chars !-_?=@/+* are desired, else false") .withLongOpt("special-chars").create("c"); Option suppressPwdOutpOpt = OptionBuilder .withDescription("Suppress password output (copy to clipboard only)").withLongOpt("hide-password") .hasArg(false).create("x"); Option helpOpt = OptionBuilder.withDescription("Prints this help message").withLongOpt("help").create("h"); options.addOption(seedPwdOpt); options.addOption(serviceIdOpt); options.addOption(pwdLengthOpt); options.addOption(specialChars); options.addOption(suppressPwdOutpOpt); options.addOption(helpOpt); CommandLineParser parser = new GnuParser(); try { CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("h")) { SafePwdGen.printHelp(options); System.exit(0); } int pwdLength = STD_PWD_LENGTH; if (cmd.hasOption("l")) { pwdLength = new Integer(cmd.getOptionValue("l")); } boolean useSpecialChars = true; if (cmd.hasOption("c")) { useSpecialChars = new Boolean(cmd.getOptionValue("c")); } if (pwdLength > MAX_PWD_LENGTH_64 && !useSpecialChars) { System.out.println(PASSWORD_SIZE_TOO_BIG + MAX_PWD_LENGTH_64); } if (pwdLength > MAX_PWD_LENGTH_71 && useSpecialChars) { System.out.println(PASSWORD_SIZE_TOO_BIG + MAX_PWD_LENGTH_71); } boolean suppressPwdOutput = cmd.hasOption('x'); String pwd = SafePwdGen.createPwd(cmd.getOptionValue("s"), cmd.getOptionValue("i"), pwdLength, useSpecialChars); if (!suppressPwdOutput) { System.out.print(GENERATED_PASSWORD); System.out.println(pwd); } System.out.println(CLIPBOARD_COPIED_MSG); SystemClipboardInterface.copy(pwd); System.in.read(); } catch (ParseException e) { System.out.println(e.getLocalizedMessage()); SafePwdGen.printHelp(options); } catch (UnsupportedEncodingException e) { System.out.println(e.getLocalizedMessage()); } catch (NoSuchAlgorithmException e) { System.out.println(e.getLocalizedMessage()); } catch (IOException e) { System.out.println(e.getLocalizedMessage()); } }
From source file:edu.harvard.med.screensaver.io.screenresults.ScreenResultImporter.java
@SuppressWarnings("static-access") public static void main(String[] args) { ScreenResultImporter app = new ScreenResultImporter(args); app.addCommandLineOption(OptionBuilder.hasArg().withArgName("screen facility ID").isRequired() .withDescription(//from w w w .jav a 2s. c o m "the facility-assigned ID of the screen for which the screen result is being parsed") .withLongOpt(SCREEN_OPTION[LONG_OPTION]).create(SCREEN_OPTION[SHORT_OPTION])); app.addCommandLineOption(OptionBuilder.hasArg().withArgName("file").isRequired() .withDescription("the file location of the Excel workbook file holding the Screen Result metadata") .withLongOpt(INPUT_FILE_OPTION[LONG_OPTION]).create(INPUT_FILE_OPTION[SHORT_OPTION])); app.addCommandLineOption(OptionBuilder.hasArg().withArgName("comments").isRequired(false) .withDescription("comments to associate with the data loading activity") .withLongOpt(COMMENTS[LONG_OPTION]).create(COMMENTS[SHORT_OPTION])); app.addCommandLineOption(OptionBuilder.withDescription("The first plate number to parse/import").hasArg() .withArgName("#").withLongOpt(PLATE_NUMBER_START_OPTION[LONG_OPTION]) .create(PLATE_NUMBER_START_OPTION[SHORT_OPTION])); app.addCommandLineOption(OptionBuilder.withDescription("The last plate number to parse/import").hasArg() .withArgName("#").withLongOpt(PLATE_NUMBER_END_OPTION[LONG_OPTION]) .create(PLATE_NUMBER_END_OPTION[SHORT_OPTION])); app.addCommandLineOption(OptionBuilder .withDescription("Import screen result into database if parsing is successful. " + "(By default, the parser only validates the input and then exits.)") .withLongOpt(IMPORT_OPTION[LONG_OPTION]).create(IMPORT_OPTION[SHORT_OPTION])); app.addCommandLineOption(OptionBuilder.withDescription("Ignore any subsequent duplicates of a well") .isRequired(false).withLongOpt(IGNORE_DUPLICATE_ERRORS_OPTION[LONG_OPTION]) .create(IGNORE_DUPLICATE_ERRORS_OPTION[SHORT_OPTION])); app.addCommandLineOption(OptionBuilder.withDescription( "Set the incremental flushing option; this is necessary for conserving memory in large imports (default=\"true\")") .isRequired(false).withArgName("value").withLongOpt(INCREMENTAL_FLUSH_OPTION[LONG_OPTION]) .create(INCREMENTAL_FLUSH_OPTION[SHORT_OPTION])); app.addCommandLineOption(OptionBuilder.withDescription(DELETE_EXISTING[2]).hasArg(false) .withLongOpt(DELETE_EXISTING[LONG_OPTION]).create(DELETE_EXISTING[SHORT_OPTION])); app.processOptions(/* acceptDatabaseOptions= */true, /* acceptAdminUserOptions= */true); try { execute(app); } catch (ParseErrorsException e) { if (!e.getErrors().isEmpty()) { for (ParseError pe : e.getErrors()) { log.error("" + pe); } log.error("" + e.getErrors().size() + " errors found."); } System.exit(1); } catch (Exception e) { log.error("Failed to create the screen result", e); System.exit(1); } }