Example usage for org.apache.commons.cli CommandLine getOptionValues

List of usage examples for org.apache.commons.cli CommandLine getOptionValues

Introduction

In this page you can find the example usage for org.apache.commons.cli CommandLine getOptionValues.

Prototype

public String[] getOptionValues(char opt) 

Source Link

Document

Retrieves the array of values, if any, of an option.

Usage

From source file:de.zib.scalaris.InterOpTest.java

/**
 * Queries the command line options for an action to perform.
 *
 * <pre>/*  w w  w .j a  v  a  2 s  . c o  m*/
 * <code>
 * > java -jar scalaris.jar -help
 * usage: scalaris [Options]
 *  -h,--help                        print this message
 *  -v,--verbose                     print verbose information, e.g. the
 *                                   properties read
 *  -lh,--localhost                  gets the local host's name as known to
 *                                   Java (for debugging purposes)
 *  -r,--read <basekey>              read all items with the given basekey
 *  -w,--write <basekey>             writes items of different types to the
 *                                   given basekey
 * </code>
 * </pre>
 *
 * In order to override node and cookie to use for a connection, specify
 * the <tt>scalaris.node</tt> or <tt>scalaris.cookie</tt> system properties.
 * Their values will be used instead of the values defined in the config
 * file!
 *
 * @param args
 *            command line arguments
 */
public static void main(final String[] args) {
    boolean verbose = false;
    final CommandLineParser parser = new GnuParser();
    CommandLine line = null;
    final Options options = getOptions();
    try {
        line = parser.parse(options, args);
    } catch (final ParseException e) {
        Main.printException("Parsing failed", e, false);
        return; // will not be reached since printException exits
    }

    if (line.hasOption("verbose")) {
        verbose = true;
        ConnectionFactory.getInstance().printProperties();
    }

    String basekey;
    Mode mode;
    if (line.hasOption("r")) { // read
        mode = Mode.READ;
        final String[] optionValues = line.getOptionValues("read");
        Main.checkArguments(optionValues, 2, options, "r");
        basekey = optionValues[0];
        final String language = optionValues[1];
        basekey += "_" + language;
        System.out.println("Java-API: reading from " + language);
    } else if (line.hasOption("w")) { // write
        mode = Mode.WRITE;
        basekey = line.getOptionValue("write");
        Main.checkArguments(basekey, options, "w");
        basekey += "_java";
        System.out.println("Java-API: writing values");
    } else if (line.hasOption("lh")) { // get local host name
        System.out.println(ConnectionFactory.getLocalhostName());
        return;
    } else {
        // print help if no other option was given
        //        if (line.hasOption("help")) {
        final HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("scalaris [Options]", getOptions());
        return;
    }
    try {
        final TransactionSingleOp sc = new TransactionSingleOp();
        int failed = 0;

        failed += read_write_boolean(basekey, sc, mode);
        failed += read_write_integer(basekey, sc, mode);
        failed += read_write_long(basekey, sc, mode);
        failed += read_write_biginteger(basekey, sc, mode);
        failed += read_write_double(basekey, sc, mode);
        failed += read_write_string(basekey, sc, mode);
        failed += read_write_binary(basekey, sc, mode);
        failed += read_write_list(basekey, sc, mode);
        failed += read_write_map(basekey, sc, mode);
        System.out.println();

        sc.closeConnection();
        if (failed > 0) {
            if (mode == Mode.WRITE) {
                System.out.println(failed + " number of writes failed.");
            } else {
                System.out.println(failed + " number of reads failed.");
            }
            System.out.println();
            System.exit(1);
        }
    } catch (final ConnectionException e) {
        Main.printException("failed with connection error", e, verbose);
    } catch (final UnknownException e) {
        Main.printException("failed with unknown", e, verbose);
    }
}

From source file:com.example.dlp.Inspect.java

/**
 * Command line application to inspect data using the Data Loss Prevention API.
 * Supported data formats: string, file, text file on GCS, BigQuery table, and Datastore entity
 *//*from  w  ww  .j  a  v  a  2  s  .  c o m*/
public static void main(String[] args) throws Exception {

    OptionGroup optionsGroup = new OptionGroup();
    optionsGroup.setRequired(true);
    Option stringOption = new Option("s", "string", true, "inspect string");
    optionsGroup.addOption(stringOption);

    Option fileOption = new Option("f", "file path", true, "inspect input file path");
    optionsGroup.addOption(fileOption);

    Option gcsOption = new Option("gcs", "Google Cloud Storage", false, "inspect GCS file");
    optionsGroup.addOption(gcsOption);

    Option datastoreOption = new Option("ds", "Google Datastore", false, "inspect Datastore kind");
    optionsGroup.addOption(datastoreOption);

    Option bigqueryOption = new Option("bq", "Google BigQuery", false, "inspect BigQuery table");
    optionsGroup.addOption(bigqueryOption);

    Options commandLineOptions = new Options();
    commandLineOptions.addOptionGroup(optionsGroup);

    Option minLikelihoodOption = Option.builder("minLikelihood").hasArg(true).required(false).build();

    commandLineOptions.addOption(minLikelihoodOption);

    Option maxFindingsOption = Option.builder("maxFindings").hasArg(true).required(false).build();

    commandLineOptions.addOption(maxFindingsOption);

    Option infoTypesOption = Option.builder("infoTypes").hasArg(true).required(false).build();
    infoTypesOption.setArgs(Option.UNLIMITED_VALUES);
    commandLineOptions.addOption(infoTypesOption);

    Option includeQuoteOption = Option.builder("includeQuote").hasArg(true).required(false).build();
    commandLineOptions.addOption(includeQuoteOption);

    Option bucketNameOption = Option.builder("bucketName").hasArg(true).required(false).build();
    commandLineOptions.addOption(bucketNameOption);

    Option gcsFileNameOption = Option.builder("fileName").hasArg(true).required(false).build();
    commandLineOptions.addOption(gcsFileNameOption);

    Option datasetIdOption = Option.builder("datasetId").hasArg(true).required(false).build();
    commandLineOptions.addOption(datasetIdOption);

    Option tableIdOption = Option.builder("tableId").hasArg(true).required(false).build();
    commandLineOptions.addOption(tableIdOption);

    Option projectIdOption = Option.builder("projectId").hasArg(true).required(false).build();
    commandLineOptions.addOption(projectIdOption);

    Option datastoreNamespaceOption = Option.builder("namespace").hasArg(true).required(false).build();
    commandLineOptions.addOption(datastoreNamespaceOption);

    Option datastoreKindOption = Option.builder("kind").hasArg(true).required(false).build();
    commandLineOptions.addOption(datastoreKindOption);

    CommandLineParser parser = new DefaultParser();
    HelpFormatter formatter = new HelpFormatter();
    CommandLine cmd;

    try {
        cmd = parser.parse(commandLineOptions, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        formatter.printHelp(Inspect.class.getName(), commandLineOptions);
        System.exit(1);
        return;
    }

    Likelihood minLikelihood = Likelihood.valueOf(
            cmd.getOptionValue(minLikelihoodOption.getOpt(), Likelihood.LIKELIHOOD_UNSPECIFIED.name()));
    int maxFindings = Integer.parseInt(cmd.getOptionValue(maxFindingsOption.getOpt(), "0"));
    boolean includeQuote = Boolean.parseBoolean(cmd.getOptionValue(includeQuoteOption.getOpt(), "true"));

    List<InfoType> infoTypesList = Collections.emptyList();
    if (cmd.hasOption(infoTypesOption.getOpt())) {
        infoTypesList = new ArrayList<>();
        String[] infoTypes = cmd.getOptionValues(infoTypesOption.getOpt());
        for (String infoType : infoTypes) {
            infoTypesList.add(InfoType.newBuilder().setName(infoType).build());
        }
    }
    // string inspection
    if (cmd.hasOption("s")) {
        String val = cmd.getOptionValue(stringOption.getOpt());
        inspectString(val, minLikelihood, maxFindings, infoTypesList, includeQuote);
    } else if (cmd.hasOption("f")) {
        String filePath = cmd.getOptionValue(fileOption.getOpt());
        inspectFile(filePath, minLikelihood, maxFindings, infoTypesList, includeQuote);
        // gcs file inspection
    } else if (cmd.hasOption("gcs")) {
        String bucketName = cmd.getOptionValue(bucketNameOption.getOpt());
        String fileName = cmd.getOptionValue(gcsFileNameOption.getOpt());
        inspectGcsFile(bucketName, fileName, minLikelihood, infoTypesList);
        // datastore kind inspection
    } else if (cmd.hasOption("ds")) {
        String namespaceId = cmd.getOptionValue(datastoreNamespaceOption.getOpt(), "");
        String kind = cmd.getOptionValue(datastoreKindOption.getOpt());
        // use default project id when project id is not specified
        String projectId = cmd.getOptionValue(projectIdOption.getOpt(), ServiceOptions.getDefaultProjectId());
        inspectDatastore(projectId, namespaceId, kind, minLikelihood, infoTypesList);
    } else if (cmd.hasOption("bq")) {
        String datasetId = cmd.getOptionValue(datasetIdOption.getOpt());
        String tableId = cmd.getOptionValue(tableIdOption.getOpt());
        // use default project id when project id is not specified
        String projectId = cmd.getOptionValue(projectIdOption.getOpt(), ServiceOptions.getDefaultProjectId());
        inspectBigquery(projectId, datasetId, tableId, minLikelihood, infoTypesList);
    }
}

From source file:at.ac.tuwien.inso.subcat.ui.ViewFactory.java

public static void main(String[] args) {
    Options options = new Options();
    options.addOption("h", "help", false, "Show this options");
    options.addOption("d", "db", true, "The database to process (required)");
    options.addOption("p", "project", true, "The project ID to process");
    options.addOption("P", "list-projects", false, "List all registered projects");
    options.addOption("C", "config", true, "A configuration file including reports");
    options.addOption("c", "commit-dictionary", true, "The commit dictionary ID to use");
    options.addOption("b", "bug-dictionary", true, "The bug dictionary ID to use");
    options.addOption("D", "list-dictionaries", false, "List all dictionaries");
    options.addOption("e", "db-extension", true, "Sqlite extension");
    options.addOption("v", "verbose", false, "Show details");

    Reporter reporter = new Reporter(false);
    String[] extensions = new String[0];
    ModelPool pool = null;//w w w . j  av  a 2 s  .c  om
    Model model = null;

    CommandLineParser parser = new PosixParser();
    boolean printDetails = false;

    try {
        CommandLine cmd = parser.parse(options, args);
        printDetails = cmd.hasOption("verbose");

        if (cmd.hasOption("help")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("postprocessor", options);
            return;
        }

        if (cmd.hasOption("db-extension")) {
            extensions = cmd.getOptionValues("db-extension");
        }

        if (cmd.hasOption("db") == false) {
            reporter.error("explorer", "Option --db is required");
            reporter.printSummary();
            return;
        }

        if (cmd.hasOption("config") == false) {
            reporter.error("explorer", "Option --config is required");
            reporter.printSummary();
            return;
        }

        Configuration config = new Configuration();
        Parser configParser = new Parser();
        try {
            configParser.parse(config, new File(cmd.getOptionValue("config")));
        } catch (IOException e) {
            reporter.error("explorer", "Could not read configuration file: " + e.getMessage());
            reporter.printSummary();
            return;
        } catch (ParserException e) {
            reporter.error("explorer", "Could not parse configuration file: " + e.getMessage());
            reporter.printSummary();
            return;
        }

        File dbf = new File(cmd.getOptionValue("db"));
        if (dbf.exists() == false || dbf.isFile() == false) {
            reporter.error("explorer", "Invalid database file path");
            reporter.printSummary();
            return;
        }

        pool = new ModelPool(cmd.getOptionValue("db"), 2, extensions);
        pool.setPrintTemplates(printDetails);
        model = pool.getModel();

        if (cmd.hasOption("list-projects")) {
            for (Project proj : model.getProjects()) {
                System.out.println("  " + proj.getId() + ": " + proj.getDate());
            }

            return;
        }

        Integer projId = null;
        if (cmd.hasOption("project") == false) {
            reporter.error("explorer", "Option --project is required");
            reporter.printSummary();
            return;
        } else {
            try {
                projId = Integer.parseInt(cmd.getOptionValue("project"));
            } catch (NumberFormatException e) {
                reporter.error("explorer", "Invalid project ID");
                reporter.printSummary();
                return;
            }
        }

        Project project = model.getProject(projId);
        if (project == null) {
            reporter.error("explorer", "Invalid project ID");
            reporter.printSummary();
            return;
        }

        if (cmd.hasOption("list-dictionaries")) {
            List<at.ac.tuwien.inso.subcat.model.Dictionary> dictionaries = model.getDictionaries(project);
            for (at.ac.tuwien.inso.subcat.model.Dictionary dict : dictionaries) {
                System.out.println("  (" + dict.getId() + ") " + dict.getContext() + " " + dict.getName());
            }
            return;
        }

        int bugDictId = -1;
        if (cmd.hasOption("bug-dictionary")) {
            try {
                bugDictId = Integer.parseInt(cmd.getOptionValue("bug-dictionary"));
                List<at.ac.tuwien.inso.subcat.model.Dictionary> dictionaries = model.getDictionaries(project);
                boolean valid = false;

                for (at.ac.tuwien.inso.subcat.model.Dictionary dict : dictionaries) {
                    if (dict.getId() == bugDictId) {
                        valid = true;
                        break;
                    }
                }

                if (valid == false) {
                    reporter.error("explorer", "Invalid bug dictionary ID");
                    reporter.printSummary();
                    return;
                }
            } catch (NumberFormatException e) {
                reporter.error("explorer", "Invalid bug dictionary ID");
                reporter.printSummary();
                return;
            }
        } else {
            List<at.ac.tuwien.inso.subcat.model.Dictionary> dictionaries = model.getDictionaries(project);
            for (at.ac.tuwien.inso.subcat.model.Dictionary dict : dictionaries) {
                if (dict.getContext().equals("bug")) {
                    bugDictId = dict.getId();
                    break;
                }
            }
        }

        int commitDictId = -1;
        if (cmd.hasOption("commit-dictionary")) {
            try {
                commitDictId = Integer.parseInt(cmd.getOptionValue("commit-dictionary"));
                List<at.ac.tuwien.inso.subcat.model.Dictionary> dictionaries = model.getDictionaries(project);
                boolean valid = false;

                for (at.ac.tuwien.inso.subcat.model.Dictionary dict : dictionaries) {
                    if (dict.getId() == commitDictId) {
                        valid = true;
                        break;
                    }
                }

                if (valid == false) {
                    reporter.error("explorer", "Invalid commit dictionary ID");
                    reporter.printSummary();
                    return;
                }
            } catch (NumberFormatException e) {
                reporter.error("explorer", "Invalid commit dictionary ID");
                reporter.printSummary();
                return;
            }
        } else {
            List<at.ac.tuwien.inso.subcat.model.Dictionary> dictionaries = model.getDictionaries(project);
            for (at.ac.tuwien.inso.subcat.model.Dictionary dict : dictionaries) {
                if (dict.getContext().equals("src")) {
                    commitDictId = dict.getId();
                    break;
                }
            }
        }

        // UI:
        Display display = new Display();
        final Shell shell = new Shell(display);
        final StackLayout stack = new StackLayout();
        shell.setLayout(stack);

        Composite _projectControl = null;
        Composite _teamControl = null;
        Composite _userControl = null;

        if (config.getProjectViewConfig() != null) {
            ViewFactory factory = new ViewFactory(model, config);
            _projectControl = factory.createProjectViewComposite(shell, SWT.NONE, project, commitDictId,
                    bugDictId, config.getProjectViewConfig());
        }

        if (config.getTeamViewConfig() != null) {
            ViewFactory factory = new ViewFactory(model, config);
            _teamControl = factory.createTeamViewComposite(shell, SWT.NONE, project, commitDictId, bugDictId,
                    config.getTeamViewConfig());
        }

        if (config.getUserViewConfig() != null) {
            ViewFactory factory = new ViewFactory(model, config);
            _userControl = factory.createUserViewComposite(shell, SWT.NONE, project, commitDictId, bugDictId,
                    config.getUserViewConfig());
        }

        final Composite projectControl = _projectControl;
        final Composite teamControl = _teamControl;
        final Composite userControl = _userControl;

        // Menu:
        Menu menu = new Menu(shell, SWT.BAR);
        shell.setMenuBar(menu);

        MenuItem mntmNewSubmenu = new MenuItem(menu, SWT.CASCADE);
        mntmNewSubmenu.setText("Views");

        Menu viewMenu = new Menu(shell, SWT.DROP_DOWN);
        mntmNewSubmenu.setMenu(viewMenu);

        Composite defaultView = null;

        if (projectControl != null) {
            MenuItem projectRadio = new MenuItem(viewMenu, SWT.RADIO);
            projectRadio.setText("Project View");
            projectRadio.addSelectionListener(new SelectionListener() {
                @Override
                public void widgetDefaultSelected(SelectionEvent arg0) {
                    stack.topControl = projectControl;
                    shell.layout();
                }

                @Override
                public void widgetSelected(SelectionEvent arg0) {
                    stack.topControl = projectControl;
                    shell.layout();
                }
            });

            defaultView = projectControl;
            projectRadio.setSelection(true);
        }

        if (teamControl != null) {
            MenuItem teamRadio = new MenuItem(viewMenu, SWT.RADIO);
            teamRadio.setText("Team View");
            teamRadio.addSelectionListener(new SelectionListener() {
                @Override
                public void widgetDefaultSelected(SelectionEvent arg0) {
                    stack.topControl = teamControl;
                    shell.layout();
                }

                @Override
                public void widgetSelected(SelectionEvent arg0) {
                    stack.topControl = teamControl;
                    shell.layout();
                }
            });

            if (defaultView == null) {
                defaultView = teamControl;
                teamRadio.setSelection(true);
            }
        }

        if (userControl != null) {
            MenuItem userRadio = new MenuItem(viewMenu, SWT.RADIO);
            userRadio.setText("User View");
            userRadio.addSelectionListener(new SelectionListener() {
                @Override
                public void widgetDefaultSelected(SelectionEvent arg0) {
                    stack.topControl = userControl;
                    shell.layout();
                }

                @Override
                public void widgetSelected(SelectionEvent arg0) {
                    stack.topControl = userControl;
                    shell.layout();
                }
            });

            if (defaultView == null) {
                defaultView = userControl;
                userRadio.setSelection(true);
            }
        }

        stack.topControl = defaultView;

        // Display:
        shell.pack();
        shell.open();

        while (!shell.isDisposed()) {
            if (!display.readAndDispatch()) {
                display.sleep();
            }
        }
        display.dispose();

        /*/ UI:
        Display display = new Display ();
                
        Shell teamShell = new Shell (display, SWT.CLOSE);
        teamShell.setLayout (new FillLayout ());
                
        Shell projectShell = new Shell (display, SWT.CLOSE);
        projectShell.setLayout (new FillLayout ());
                
        projectShell.setText ("Project View");
        teamShell.setText ("Team View");
                
        if (config.getTeamViewConfig () != null) {
           ViewFactory factory = new ViewFactory (model, config);
           factory.createTeamViewComposite (teamShell, SWT.NONE, project, commitDictId, bugDictId, config.getTeamViewConfig ());
                
           teamShell.pack();
           teamShell.open ();
        } else {
           teamShell.dispose ();
        }
                
        if (config.getProjectViewConfig () != null) {
           ViewFactory factory = new ViewFactory (model, config);
           factory.createProjectViewComposite (projectShell, SWT.NONE, project, commitDictId, bugDictId, config.getProjectViewConfig ());
                
           projectShell.pack();
           projectShell.open ();
        } else {
           projectShell.dispose ();
        }
                
        teamShell.addListener (SWT.CLOSE, new Listener () {
           @Override
           public void handleEvent (Event event) {
              teamShell.dispose ();
           }
        });
                
        projectShell.addListener (SWT.CLOSE, new Listener () {
           @Override
           public void handleEvent (Event event) {
              projectShell.dispose ();
           }
        });
                
          while (!display.isDisposed ()) {
             if (teamShell.isDisposed () && projectShell.isDisposed ()) {
         break;
             }
           if (!display.readAndDispatch ()) {
              display.sleep ();
           }
        }
                
        display.dispose();
        */
    } catch (ParseException e) {
        reporter.error("explorer", "Parsing failed: " + e.getMessage());
        if (printDetails == true) {
            e.printStackTrace();
        }
    } catch (ClassNotFoundException e) {
        reporter.error("explorer", "Failed to create a database connection: " + e.getMessage());
        if (printDetails == true) {
            e.printStackTrace();
        }
    } catch (SQLException e) {
        reporter.error("explorer", "Failed to create a database connection: " + e.getMessage());
        if (printDetails == true) {
            e.printStackTrace();
        }
    } catch (SemanticException e) {
        reporter.error("explorer", "Semantic Error: " + e.getMessage());
        if (printDetails == true) {
            e.printStackTrace();
        }
    } finally {
        if (model != null) {
            model.close();
        }
        if (pool != null) {
            pool.close();
        }
    }

    reporter.printSummary();
}

From source file:edu.wustl.mir.erl.ihe.xdsi.util.StoreSCU.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    long t1, t2;//from ww w  .  ja v a 2  s.c o m
    try {
        CommandLine cl = parseComandLine(args);
        Device device = new Device("storescu");
        Connection conn = new Connection();
        device.addConnection(conn);
        ApplicationEntity ae = new ApplicationEntity("STORESCU");
        device.addApplicationEntity(ae);
        ae.addConnection(conn);
        StoreSCU main = new StoreSCU(ae);
        configureTmpFile(main, cl);
        CLIUtils.configureConnect(main.remote, main.rq, cl);
        CLIUtils.configureBind(conn, ae, cl);
        CLIUtils.configure(conn, cl);
        main.remote.setTlsProtocols(conn.getTlsProtocols());
        main.remote.setTlsCipherSuites(conn.getTlsCipherSuites());
        configureRelatedSOPClass(main, cl);
        main.setAttributes(new Attributes());
        CLIUtils.addAttributes(main.attrs, cl.getOptionValues("s"));
        main.setUIDSuffix(cl.getOptionValue("uid-suffix"));
        main.setPriority(CLIUtils.priorityOf(cl));
        List<String> argList = cl.getArgList();
        boolean echo = argList.isEmpty();
        if (!echo) {
            System.out.println(rb.getString("scanning"));
            t1 = System.currentTimeMillis();
            main.scanFiles(argList);
            t2 = System.currentTimeMillis();
            int n = main.filesScanned;
            System.out.println();
            if (n == 0)
                return;
            System.out.println(
                    MessageFormat.format(rb.getString("scanned"), n, (t2 - t1) / 1000F, (t2 - t1) / n));
        }
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
        device.setExecutor(executorService);
        device.setScheduledExecutor(scheduledExecutorService);
        try {
            t1 = System.currentTimeMillis();
            main.open();
            t2 = System.currentTimeMillis();
            System.out
                    .println(MessageFormat.format(rb.getString("connected"), main.as.getRemoteAET(), t2 - t1));
            if (echo)
                main.echo();
            else {
                t1 = System.currentTimeMillis();
                main.sendFiles();
                t2 = System.currentTimeMillis();
            }
        } finally {
            main.close();
            executorService.shutdown();
            scheduledExecutorService.shutdown();
        }
        if (main.filesScanned > 0) {
            float s = (t2 - t1) / 1000F;
            float mb = main.totalSize / 1048576F;
            System.out.println(MessageFormat.format(rb.getString("sent"), main.filesSent, mb, s, mb / s));
        }
    } catch (ParseException e) {
        System.err.println("storescu: " + e.getMessage());
        System.err.println(rb.getString("try"));
        System.exit(2);
    } catch (Exception e) {
        System.err.println("storescu: " + e.getMessage());
        e.printStackTrace();
        System.exit(2);
    }
}

From source file:edu.usc.ir.geo.gazetteer.GeoNameResolver.java

public static void main(String[] args) throws Exception {
    Option buildOpt = OptionBuilder.withArgName("gazetteer file").hasArg().withLongOpt("build")
            .withDescription("The Path to the Geonames allCountries.txt").create('b');

    Option searchOpt = OptionBuilder.withArgName("set of location names").withLongOpt("search").hasArgs()
            .withDescription("Location names to search the Gazetteer for").create('s');

    Option indexOpt = OptionBuilder.withArgName("directoryPath").withLongOpt("index").hasArgs()
            .withDescription("The path to the Lucene index directory to either create or read").create('i');

    Option helpOpt = OptionBuilder.withLongOpt("help").withDescription("Print this message.").create('h');

    Option resultCountOpt = OptionBuilder.withArgName("number of results").withLongOpt("count").hasArgs()
            .withDescription("Number of best results to be returned for one location").withType(Integer.class)
            .create('c');

    Option serverOption = OptionBuilder.withArgName("Launch Server").withLongOpt("server")
            .withDescription("Launches Geo Gazetteer Service").create("server");

    Option jsonOption = OptionBuilder.withArgName("outputs json").withLongOpt(JSON_OPT)
            .withDescription("Formats output in well defined json structure").create(JSON_OPT);

    String indexPath = null;/* w  w w  .  j  a v  a 2  s  .c o m*/
    String gazetteerPath = null;
    Options options = new Options();
    options.addOption(buildOpt);
    options.addOption(searchOpt);
    options.addOption(indexOpt);
    options.addOption(helpOpt);
    options.addOption(resultCountOpt);
    options.addOption(serverOption);
    options.addOption(jsonOption);

    // create the parser
    CommandLineParser parser = new DefaultParser();
    GeoNameResolver resolver = new GeoNameResolver();

    try {
        // parse the command line arguments
        CommandLine line = parser.parse(options, args);

        if (line.hasOption("index")) {
            indexPath = line.getOptionValue("index");
        }

        if (line.hasOption("build")) {
            gazetteerPath = line.getOptionValue("build");
        }

        if (line.hasOption("help")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("lucene-geo-gazetteer", options);
            System.exit(1);
        }

        if (indexPath != null && gazetteerPath != null) {
            LOG.info("Building Lucene index at path: [" + indexPath + "] with geoNames.org file: ["
                    + gazetteerPath + "]");
            resolver.buildIndex(gazetteerPath, indexPath);
        }

        if (line.hasOption("search")) {
            List<String> geoTerms = new ArrayList<String>(Arrays.asList(line.getOptionValues("search")));
            String countStr = line.getOptionValue("count", "1");
            int count = 1;
            if (countStr.matches("\\d+"))
                count = Integer.parseInt(countStr);

            Map<String, List<Location>> resolved = resolver.searchGeoName(indexPath, geoTerms, count);
            if (line.hasOption(JSON_OPT)) {
                writeResultJson(resolved, System.out);
            } else {
                writeResult(resolved, System.out);
            }
        } else if (line.hasOption("server")) {
            if (indexPath == null) {
                System.err.println("Index path is required");
                System.exit(-2);
            }

            //TODO: get port from CLI args
            int port = 8765;
            Launcher.launchService(port, indexPath);
        } else {
            System.err.println("Sub command not recognised");
            System.exit(-1);
        }

    } catch (ParseException exp) {
        // oops, something went wrong
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
    }
}

From source file:com.divinesoft.boynas.Boynas.java

public static void main(String args[]) {
    //TODO: Move Options to a different method
    Options options = new Options();

    //Create options
    Option list = OptionBuilder.withDescription("List all config entries in database").create("list");

    Option clean = OptionBuilder.withDescription("Remove all config entries in database").create("clean");

    Option importCSV = OptionBuilder.withArgName("file").hasArg()
            .withDescription("Import config entries from a CSV file").create("importCSV");

    Option exportXML = OptionBuilder.withDescription("Export all config entries to XML CFG files")
            .create("exportXML");

    Option exportTemplate = OptionBuilder.withArgName("templates folder").hasArgs()
            .withDescription("Export all config entries from a set of template files").create("exportTemplate");

    Option version = OptionBuilder.withDescription("Print the version number").create("version");

    Option quickGen = OptionBuilder.withArgName("import file,templates folder")
            .withDescription("Use a one-shot template based config generator").hasArgs(2)
            .withValueSeparator(' ').create("quickExport");

    //Add options
    options.addOption(list);// www . j  av  a  2  s.  c  om
    options.addOption(clean);
    options.addOption(importCSV);
    options.addOption(exportXML);
    options.addOption(exportTemplate);
    options.addOption(quickGen);
    options.addOption(version);

    CommandLineParser parser = new GnuParser();

    //The main Boynas object
    Boynas boynas;

    //Start dealing with application context
    XmlBeanFactory appContext = new XmlBeanFactory(new ClassPathResource("applicationContext.xml"));

    try {
        CommandLine cmd = parser.parse(options, args);

        if (cmd.hasOption("list")) {
            boynas = (Boynas) appContext.getBean("boynasList");
            boynas.getAllConfigEntries();
        } else if (cmd.hasOption("clean")) {
            boynas = (Boynas) appContext.getBean("boynasList");
            boynas.clean();
        } else if (cmd.hasOption("importCSV")) {
            Boynas.filePath = cmd.getOptionValue("importCSV");
            boynas = (Boynas) appContext.getBean("bynImportCSV");
            boynas.importCSV();
        } else if (cmd.hasOption("exportXML")) {
            boynas = (Boynas) appContext.getBean("bynExportXML");
            boynas.exportXML();
        } else if (cmd.hasOption("version")) {
            boynas = (Boynas) appContext.getBean("boynasList");
            boynas.printVersion();
        } else if (cmd.hasOption("exportTemplate")) {
            Boynas.templatePath = cmd.getOptionValue("exportTemplate");
            boynas = (Boynas) appContext.getBean("bynExportTemplate");
            boynas.exportTemplate();
        } else if (cmd.hasOption("quickExport")) {
            String[] paths = cmd.getOptionValues("quickExport");

            if (paths.length < 2) {
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("boynas", options);
            }

            Boynas.filePath = paths[0];
            Boynas.templatePath = paths[1];
            boynas = (Boynas) appContext.getBean("bynQuickExport");
            boynas.quickExport();
        }

        else {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("boynas", options);
        }

    } catch (ParseException e) {
        System.err.println("Parsing failed. Reason: " + e.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("boynas", options);
    }
}

From source file:de.unileipzig.ub.scroller.Main.java

public static void main(String[] args) throws IOException {

    Options options = new Options();
    // add t option
    options.addOption("h", "help", false, "display this help");

    // elasticsearch options
    options.addOption("t", "host", true, "elasticsearch hostname (default: 0.0.0.0)");
    options.addOption("p", "port", true, "transport port (that's NOT the http port, default: 9300)");
    options.addOption("c", "cluster", true, "cluster name (default: elasticsearch_mdma)");

    options.addOption("i", "index", true, "index to use");

    options.addOption("f", "filter", true, "filter(s) - e.g. meta.kind=title");
    options.addOption("j", "junctor", true, "values: and, or (default: and)");
    options.addOption("n", "notice-every", true, "show speed after every N items");

    options.addOption("v", "verbose", false, "be verbose");
    // options.addOption("z", "end-of-message", true, "sentinel to print to stdout, once the regular input finished (default: EOM)");

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;

    try {//w ww  . java2  s  . c  o  m
        cmd = parser.parse(options, args);
    } catch (ParseException ex) {
        logger.error(ex);
        System.exit(1);
    }

    // process options
    if (cmd.hasOption("h")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("scroller", options, true);
        System.exit(0);
    }

    String endOfMessage = "EOM";

    boolean verbose = false;
    if (cmd.hasOption("verbose")) {
        verbose = true;
    }

    if (!cmd.hasOption("i")) {
        System.err.println("error: no index specified");
        System.exit(1);
    }

    long noticeEvery = 10000;
    if (cmd.hasOption("n")) {
        noticeEvery = Long.parseLong(cmd.getOptionValue("n"));
    }

    // ES options
    String[] hosts = new String[] { "0.0.0.0" };
    int port = 9300;
    String clusterName = "elasticsearch_mdma";
    int bulkSize = 3000;

    if (cmd.hasOption("host")) {
        hosts = cmd.getOptionValues("host");
    }
    if (cmd.hasOption("port")) {
        port = Integer.parseInt(cmd.getOptionValue("port"));
    }
    if (cmd.hasOption("cluster")) {
        clusterName = cmd.getOptionValue("cluster");
    }

    // Index
    String indexName = cmd.getOptionValue("index");

    Map<String, String> filterMap = new HashMap<String, String>();
    if (cmd.hasOption("filter")) {
        try {
            filterMap = getMapForKeys(cmd.getOptionValues("filter"));
        } catch (ParseException pe) {
            System.err.println(pe);
            System.exit(1);
        }
    }

    Collection<HashMap> filterList = new ArrayList<HashMap>();
    if (cmd.hasOption("filter")) {
        try {
            filterList = getFilterList(cmd.getOptionValues("filter"));
        } catch (ParseException pe) {
            System.err.println(pe);
            System.exit(1);
        }
    }

    // ES Client
    final Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch_mdma")
            .put("client.transport.ping_timeout", "60s").build();
    final TransportClient client = new TransportClient(settings);
    for (String host : hosts) {
        client.addTransportAddress(new InetSocketTransportAddress(host, port));
    }

    // build the query
    String junctor = "and";
    if (cmd.hasOption("j")) {
        junctor = cmd.getOptionValue("j");
    }

    //        ArrayList<TermFilterBuilder> filters = new ArrayList<TermFilterBuilder>();
    //        if (filterMap.size() > 0) {
    //            for (Map.Entry<String, String> entry : filterMap.entrySet()) {
    //                filters.add(new TermFilterBuilder(entry.getKey(), entry.getValue()));
    //            }
    //        }

    ArrayList<TermFilterBuilder> filters = new ArrayList<TermFilterBuilder>();
    if (filterList.size() > 0) {
        for (HashMap map : filterList) {
            for (Object obj : map.entrySet()) {
                Map.Entry entry = (Map.Entry) obj;
                filters.add(new TermFilterBuilder(entry.getKey().toString(), entry.getValue().toString()));
            }
        }
    }

    FilterBuilder fb = null;
    if (junctor.equals("and")) {
        AndFilterBuilder afb = new AndFilterBuilder();
        for (TermFilterBuilder tfb : filters) {
            afb.add(tfb);
        }
        fb = afb;
    }

    if (junctor.equals("or")) {
        OrFilterBuilder ofb = new OrFilterBuilder();
        for (TermFilterBuilder tfb : filters) {
            ofb.add(tfb);
        }
        fb = ofb;
    }

    //        TermFilterBuilder tfb0 = new TermFilterBuilder("meta.kind", "title");
    //        TermFilterBuilder tfb1 = new TermFilterBuilder("meta.timestamp", "201112081240");
    //
    //        AndFilterBuilder afb0 = new AndFilterBuilder(tfb0, tfb1);

    QueryBuilder qb0 = null;
    if (filterMap.isEmpty()) {
        qb0 = matchAllQuery();
    } else {
        qb0 = filteredQuery(matchAllQuery(), fb);
    }

    // sorting
    // FieldSortBuilder sortBuilder = new FieldSortBuilder("meta.timestamp");
    // sortBuilder.order(SortOrder.DESC);

    // FilteredQueryBuilder fqb0 = filteredQuery(matchAllQuery(), tfb0);

    final CountResponse countResponse = client.prepareCount(indexName).setQuery(qb0).execute().actionGet();
    final long total = countResponse.getCount();

    SearchResponse scrollResp = client.prepareSearch(indexName).setSearchType(SearchType.SCAN)
            .setScroll(new TimeValue(60000)).setQuery(qb0)
            // .addSort(sortBuilder) // sort has no effect on scroll type (see: https://github.com/CPAN-API/cpan-api/issues/172)
            .setSize(1000) //1000 hits per shard will be returned for each scroll
            .execute().actionGet();

    //Scroll until no hits are returned

    System.err.println("[Scroller] query: " + qb0.toString());
    System.err.println("[Scroller] took: " + scrollResp.getTookInMillis() + "ms");
    System.err.println("[Scroller] docs found: " + total);

    long counter = 0;
    long start = System.currentTimeMillis();

    while (true) {
        scrollResp = client.prepareSearchScroll(scrollResp.getScrollId()).setScroll(new TimeValue(600000))
                .execute().actionGet();

        if (scrollResp.getHits().hits().length == 0) {
            break;
        }

        for (SearchHit hit : scrollResp.getHits()) {

            System.out.println(hit.sourceAsString());
            counter += 1;
            if (counter % noticeEvery == 0) {
                final double elapsed = (System.currentTimeMillis() - start) / 1000;
                final double speed = counter / elapsed;
                final long eta = (long) ((elapsed / counter) * (total - counter) * 1000);
                System.err.println(
                        counter + "/" + total + " records recvd @ speed " + String.format("%1$,.1f", speed)
                                + " r/s eta: " + DurationFormatUtils.formatDurationWords(eta, false, false));
            }
        }
    }
    System.out.close();
    // System.out.println(endOfMessage);
}

From source file:com.zimbra.common.localconfig.LocalConfigUpgrade.java

public static void main(String[] args) throws ServiceException {
    CliUtil.toolSetup();/*w  w  w. ja  va  2  s  .  c  o  m*/

    CommandLine cl = null;
    try {
        CommandLineParser parser = new GnuParser();
        Options options = getAllOptions();
        cl = parser.parse(options, args);
        if (cl == null)
            throw new ParseException("");
    } catch (ParseException pe) {
        usage(pe.getMessage());
    }

    if (cl.hasOption(O_HELP)) {
        usage(null);
    }

    if (!cl.hasOption(O_BUG)) {
        usage("no bug specified");
    }

    if (!cl.hasOption(O_TAG)) {
        usage("no backup suffix tag specified");
    }

    LocalConfig lc = null;
    try {
        lc = new LocalConfig(cl.getOptionValue("c"));
        lc.backup(cl.getOptionValue("t"));
    } catch (DocumentException de) {
        ZimbraLog.misc.error("failed reading config file", de);
        System.exit(1);
    } catch (ConfigException ce) {
        ZimbraLog.misc.error("failed reading config file", ce);
        System.exit(2);
    } catch (IOException ioe) {
        ZimbraLog.misc.error("failed to backup config file", ioe);
        System.exit(3);
    }

    String[] bugs = cl.getOptionValues(O_BUG);
    for (String bug : bugs) {
        if (!sUpgrades.containsKey(bug)) {
            ZimbraLog.misc.warn("local config upgrade can't handle bug " + bug);
            continue;
        }

        LocalConfigUpgrade lcu = sUpgrades.get(bug);
        System.out.println("== Running local config upgrade for bug " + lcu.mBug + " (" + lcu.mShortName + ")");
        try {
            lcu.upgrade(lc);
            System.out
                    .println("== Done local config upgrade for bug " + lcu.mBug + " (" + lcu.mShortName + ")");
        } catch (ConfigException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    try {
        lc.save();
    } catch (IOException ioe) {
        ZimbraLog.misc.error("failed writing config file", ioe);
        System.exit(1);
    } catch (ConfigException ce) {
        ZimbraLog.misc.error("failed writing config file", ce);
        System.exit(1);
    }
}

From source file:ComputeNode.java

public static void main(String[] argv) {

    String fileservername = "localhost";
    String id = null;//from w  w w .  j  a  va2  s .c  o  m
    Double underLoad = null;
    Double overLoad = null;
    Double failProb = null;
    Double constantload = null;
    Pair<Double, Double> gaussian = null;
    String fileName = null;

    ArgumentHandler cli = new ArgumentHandler(
            "FileServer [-h] [collector address] [-u underload] "
                    + "[-o overload] [-c constant_load|-g mean variance] " + "[-p fail_prob] [-f configfile]",
            "Bala Subrahmanyam Kambala, Daniel William DaCosta - "
                    + "GPLv3 (http://www.gnu.org/copyleft/gpl.html)",
            "");
    cli.addOption("h", "help", false, "Print this usage information.");
    cli.addOption("u", "underLoad", true, "Under load threshold");
    cli.addOption("o", "overLoad", true, "Over load threshold");
    cli.addOption("c", "constant", true, "Generate constant load");
    cli.addOption("p", "probability", true, "Fail Probability(0-100)");
    cli.addOption("f", "configfile", true,
            "The configuration file to read parameters from. " + "The default is " + defaultconf + ". "
                    + "Command line arguments will override config file " + "arguments.");
    cli.addOption(OptionBuilder.withLongOpt("gaussian").hasArgs(2)
            .withDescription("Generate a gaussian probability model for load "
                    + "simulation. The first parameter is the mean "
                    + "and the second parameter is the variance.")
            .create('g'));

    // parse command line
    CommandLine commandLine = cli.parse(argv);
    if (commandLine.hasOption('h')) {
        cli.usage("");
        System.exit(0);
    }

    if (commandLine.hasOption('u')) {
        // TODO : Ensure the number is within range
        underLoad = Double.parseDouble(commandLine.getOptionValue('u'));
    }

    if (commandLine.hasOption('o')) {
        // TODO : Ensure the number is within range
        overLoad = Double.parseDouble(commandLine.getOptionValue('o'));
    }

    if (commandLine.hasOption('p')) {
        // TODO : Ensure the number is within range
        failProb = Double.parseDouble(commandLine.getOptionValue('p'));
    }

    if (commandLine.hasOption('c')) {
        // TODO : Ensure the number is within range
        constantload = Double.parseDouble(commandLine.getOptionValue('c'));
    }

    if (commandLine.hasOption('g')) {
        // TODO : Ensure the number is within range
        gaussian = new Pair<Double, Double>(Double.parseDouble(commandLine.getOptionValues('g')[0]),
                Double.parseDouble(commandLine.getOptionValues('g')[1]));
    }

    // TODO: If these flags are no longer mutually exclusive this
    // code should be adjusted to account for whatever constraint are
    // needed.
    if ((constantload != null) && (gaussian != null)) {
        cli.usage("-g -c switches are mutually exclusive!\n");
        System.exit(1);
    }

    if (commandLine.hasOption('f')) {
        fileName = commandLine.getOptionValue('f');
    }

    if (commandLine.getArgs().length != 0)
        fileservername = commandLine.getArgs()[0];
    System.out.println(argv);
    try {
        ComputeNode node = new ComputeNode(fileservername, underLoad, overLoad, failProb, constantload,
                gaussian, fileName);

        Naming.rebind("ComputeNode" + Integer.toString(node.getID()), node);

        // Scheduling heart beat message handler
        Timer t = new Timer();
        HeartBeatHandler h = node.new HeartBeatHandler();
        t.schedule(h, 0, 1 * 1000);

    } catch (ConnectException ce) {
        //lg.log(Level.SEVERE, "Server is not alive");
        ce.printStackTrace();
    } catch (Exception e) {
        //lg.log(Level.SEVERE, "Exception in file server");
        e.printStackTrace();
    }
}

From source file:fr.inria.edelweiss.kgimport.RdfSplitter.java

/**
 * The application entrypoint, configured through the command line input
 * arguments.//ww w  .  j  av a2s .c  om
 *
 * @param args the input command line arguments.
 */
public static void main(String args[]) {

    RdfSplitter rdfSplitter = new RdfSplitter();

    Options options = new Options();
    Option helpOpt = new Option("h", "help", false, "Print usage information.");
    Option inDirOpt = new Option("i", "input-dir", true, "The directory containing RDF files to be loaded.");
    Option outDirOpt = new Option("o", "output-dir", true,
            "The directory containing the generated RDF fragments");
    Option predFiltOpt = new Option("p", "predicate-filter", true,
            "Predicate filter used to segment the dataset. "
                    + "You can use multiple filters, typically one per fragment.");
    Option fragNbOpt = new Option("n", "number-of-fragments", true,
            "Number of fragments generated for the whole input dataset.");
    Option fragRepOpt = new Option("f", "fractionning-percentage", true,
            "Percentage of the whole input dataset for this fragment.");
    Option tdbOpt = new Option("tdb", "tdb-storage", false,
            "RDF fragments are persisted into a Jena TDB backend.");
    Option versionOpt = new Option("v", "version", false, "Print the version information and exit.");
    options.addOption(inDirOpt);
    options.addOption(outDirOpt);
    options.addOption(predFiltOpt);
    options.addOption(helpOpt);
    options.addOption(versionOpt);
    options.addOption(fragNbOpt);
    options.addOption(fragRepOpt);
    options.addOption(tdbOpt);

    String header = "RDF data fragmentation tool command line interface";
    String footer = "\nPlease report any issue to alban.gaignard@cnrs.fr";

    CommandLineParser parser = new BasicParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);

        if (cmd.hasOption("h")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("java -jar [].jar", header, options, footer, true);
            System.exit(0);
        }

        if (!cmd.hasOption("i")) {
            logger.warn("You must specify a valid input directory !");
            System.exit(-1);
        } else {
            rdfSplitter.setInputDirPath(cmd.getOptionValue("i"));
        }
        if (!cmd.hasOption("o")) {
            logger.warn("You must specify a valid output directory !");
            System.exit(-1);
        } else {
            rdfSplitter.setOutputDirPath(cmd.getOptionValue("o"));
        }
        if (cmd.hasOption("p")) {
            rdfSplitter.setInputPredicates(new ArrayList<String>(Arrays.asList(cmd.getOptionValues("p"))));
        }
        if (cmd.hasOption("f")) {
            ArrayList<String> opts = new ArrayList<String>(Arrays.asList(cmd.getOptionValues("f")));
            for (String opt : opts) {
                try {
                    rdfSplitter.getFragList().add(Integer.parseInt(opt));
                } catch (NumberFormatException e) {
                    logger.error(opt + " cannot be pased as an percentage value.");
                    System.exit(-1);
                }
            }
        }
        if (cmd.hasOption("n")) {
            try {
                rdfSplitter.setFragNb(Integer.parseInt(cmd.getOptionValue("n")));
            } catch (NumberFormatException e) {
                logger.error(cmd.getOptionValue("n") + " cannot be pased as an integer value.");
                System.exit(-1);
            }
        }

        File oDir = new File(rdfSplitter.getOutputDirPath());
        if (oDir.exists()) {
            logger.warn(rdfSplitter.getOutputDirPath() + " already exists !");
            oDir = Files.createTempDir();
            logger.warn(oDir.getAbsolutePath() + " created.");
            rdfSplitter.setOutputDirPath(oDir.getAbsolutePath());
        } else {
            if (oDir.mkdir()) {
                logger.info(rdfSplitter.getOutputDirPath() + " created.");
            }
        }

        if (!cmd.hasOption("n") && !cmd.hasOption("f") && !cmd.hasOption("p")) {
            logger.error("You must specify just one fragmentation type through '-n', '-f', or 'p' options");
            for (String arg : args) {
                logger.trace(arg);
            }
            System.exit(-1);
        }

        String fragName = rdfSplitter.getInputDirPath()
                .substring(rdfSplitter.getInputDirPath().lastIndexOf("/") + 1);

        //Input data loading
        Model model = ModelFactory.createDefaultModel();
        File inputDir = new File(rdfSplitter.getInputDirPath());
        if (inputDir.isDirectory()) {
            for (File f : inputDir.listFiles()) {
                logger.info("Loading " + f.getAbsolutePath());
                if (f.isDirectory()) {
                    String directory = f.getAbsolutePath();
                    Dataset dataset = TDBFactory.createDataset(directory);
                    dataset.begin(ReadWrite.READ);
                    // Get model inside the transaction
                    model.add(dataset.getDefaultModel());
                    dataset.end();
                } else {
                    InputStream iS;
                    try {
                        iS = new FileInputStream(f);
                        if (f.getAbsolutePath().endsWith(".n3")) {
                            model.read(iS, null, "N3");
                        } else if (f.getAbsolutePath().endsWith(".nt")) {
                            model.read(iS, null, "N-TRIPLES");
                        } else if (f.getAbsolutePath().endsWith(".rdf")) {
                            model.read(iS, null);
                        }
                    } catch (FileNotFoundException ex) {
                        LogManager.getLogger(RdfSplitter.class.getName()).log(Level.ERROR, "", ex);
                    }
                }
            }
            logger.info("Loaded " + model.size() + " triples");
        } else {
            System.exit(0);
        }

        StopWatch sw = new StopWatch();
        if (cmd.hasOption("n")) {
            sw.start();
            if (cmd.hasOption("tdb")) {
                rdfSplitter.saveFragmentsTDB(rdfSplitter.getFragHoriz(model, rdfSplitter.getFragNb()),
                        "Homog-" + fragName);
            } else {
                rdfSplitter.saveFragmentsRDF(rdfSplitter.getFragHoriz(model, rdfSplitter.getFragNb()),
                        "Homog-" + fragName);
            }
            logger.info("Homog horiz frag in " + sw.getTime() + "ms");
            sw.reset();
        } else if (cmd.hasOption("f")) {
            sw.start();
            if (cmd.hasOption("tdb")) {
                rdfSplitter.saveFragmentsTDB(rdfSplitter.getFragHoriz(model, rdfSplitter.getFragList()),
                        "Inhomog-" + fragName);
            } else {
                rdfSplitter.saveFragmentsRDF(rdfSplitter.getFragHoriz(model, rdfSplitter.getFragList()),
                        "Inhomog-" + fragName);
            }
            logger.info("Inhomog horiz frag in " + sw.getTime() + "ms");
            sw.reset();
        } else if (cmd.hasOption("p")) {
            sw.start();
            if (cmd.hasOption("tdb")) {
                rdfSplitter.saveFragmentsTDB(rdfSplitter.getFragVert(model, rdfSplitter.getInputPredicates()));
            } else {
                rdfSplitter.saveFragmentsRDF(rdfSplitter.getFragVert(model, rdfSplitter.getInputPredicates()));
            }
            logger.info("Vert frag in " + sw.getTime() + "ms");
            sw.reset();
        }

    } catch (ParseException ex) {
        logger.error("Impossible to parse the input command line " + cmd.toString());
    }
}