Example usage for org.apache.commons.cli OptionBuilder withLongOpt

List of usage examples for org.apache.commons.cli OptionBuilder withLongOpt

Introduction

In this page you can find the example usage for org.apache.commons.cli OptionBuilder withLongOpt.

Prototype

public static OptionBuilder withLongOpt(String newLongopt) 

Source Link

Document

The next Option created will have the following long option value.

Usage

From source file:norbert.mynemo.ui.RecommendCommandParser.java

private static Options getOptions() {
    // algorithm option
    OptionBuilder.isRequired();/*from   ww  w.  j  ava 2s.c om*/
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(ALGORITHM_ARG_NAME);
    OptionBuilder.withLongOpt(ALGORITHM_LONG_OPTION);
    OptionBuilder.withDescription(ALGORITHM_DESCRIPTION);
    Option algorithm = OptionBuilder.create(ALGORITHM_CHAR_OPTION);

    // data model option
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(DATAMODEL_ARG_NAME);
    OptionBuilder.withLongOpt(DATAMODEL_LONG_OPTION);
    OptionBuilder.withDescription(DATAMODEL_DESCRIPTION);
    Option dataModel = OptionBuilder.create(DATAMODEL_CHAR_OPTION);

    // user option
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(USER_ARG_NAME);
    OptionBuilder.withLongOpt(USER_LONG_OPTION);
    OptionBuilder.withDescription(USER_DESCRIPTION);
    Option user = OptionBuilder.create(USER_CHAR_OPTION);

    // recommendations option
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(RECOMMENDATIONS_ARG_NAME);
    OptionBuilder.withLongOpt(RECOMMENDATIONS_LONG_OPTION);
    OptionBuilder.withDescription(RECOMMENDATIONS_DESCRIPTION);
    Option recommendation = OptionBuilder.create(RECOMMENDATIONS_CHAR_OPTION);

    // features option
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(FEATURES_ARG_NAME);
    OptionBuilder.withLongOpt(FEATURES_LONG_OPTION);
    OptionBuilder.withDescription(FEATURES_DESCRIPTION);
    Option features = OptionBuilder.create(FEATURES_CHAR_OPTION);

    // iterations option
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(ITERATIONS_ARG_NAME);
    OptionBuilder.withLongOpt(ITERATIONS_LONG_OPTION);
    OptionBuilder.withDescription(ITERATIONS_DESCRIPTION);
    Option iterations = OptionBuilder.create(ITERATIONS_CHAR_OPTION);

    // neighbors option
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(NEIGHBORS_ARG_NAME);
    OptionBuilder.withLongOpt(NEIGHBORS_LONG_OPTION);
    OptionBuilder.withDescription(NEIGHBORS_DESCRIPTION);
    Option neighbors = OptionBuilder.create(NEIGHBORS_CHAR_OPTION);

    return new Options().addOption(algorithm).addOption(dataModel).addOption(user).addOption(neighbors)
            .addOption(recommendation).addOption(features).addOption(iterations);
}

From source file:norbert.mynemo.ui.ScrapeCommandParser.java

private static Options getOptions() {
    // out movies
    OptionBuilder.isRequired();/*from w w w  . j a  v  a  2 s .  com*/
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(OUT_MOVIES_ARG_NAME);
    OptionBuilder.withLongOpt(OUT_MOVIES_LONG_OPTION);
    OptionBuilder.withDescription(OUT_MOVIES_DESCRIPTION);
    Option outMovies = OptionBuilder.create(OUT_MOVIES_CHAR_OPTION);

    // out ratings
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(OUT_RATINGS_ARG_NAME);
    OptionBuilder.withLongOpt(OUT_RATINGS_LONG_OPTION);
    OptionBuilder.withDescription(OUT_RATINGS_DESCRIPTION);
    Option outRatings = OptionBuilder.create(OUT_RATINGS_CHAR_OPTION);

    // input files
    OptionBuilder.isRequired();
    OptionBuilder.hasArgs();
    OptionBuilder.withArgName(IN_ARG_NAME);
    OptionBuilder.withLongOpt(IN_LONG_OPTION);
    OptionBuilder.withDescription(IN_DESCRIPTION);
    Option in = OptionBuilder.create(IN_CHAR_OPTION);

    // user agent file
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(USERAGENTS_ARG_NAME);
    OptionBuilder.withLongOpt(USERAGENTS_LONG_OPTION);
    OptionBuilder.withDescription(USERAGENTS_DESCRIPTION);
    Option userAgents = OptionBuilder.create(USERAGENTS_CHAR_OPTION);

    // movie blacklist file
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(MOVIE_BLACKLIST_ARG_NAME);
    OptionBuilder.withLongOpt(MOVIE_BLACKLIST_LONG_OPTION);
    OptionBuilder.withDescription(MOVIE_BLACKLIST_DESCRIPTION);
    Option movieBlacklist = OptionBuilder.create();

    // user blacklist file
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(USER_BLACKLIST_ARG_NAME);
    OptionBuilder.withLongOpt(USER_BLACKLIST_LONG_OPTION);
    OptionBuilder.withDescription(USER_BLACKLIST_DESCRIPTION);
    Option userBlacklist = OptionBuilder.create();

    return new Options().addOption(outMovies).addOption(outRatings).addOption(in).addOption(userAgents)
            .addOption(movieBlacklist).addOption(userBlacklist);
}

From source file:norbert.mynemo.ui.SelectCommandParser.java

private static Options getOptions() {
    OptionBuilder.isRequired();//from  www  .j  a  v a  2s  .co m
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(DATAMODEL_ARG_NAME);
    OptionBuilder.withDescription(DATAMODEL_DESCRIPTION);
    OptionBuilder.withLongOpt(DATAMODEL_LONG_OPTION);
    Option dataModel = OptionBuilder.create(DATAMODEL_CHAR_OPTION);

    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(USER_ARG_NAME);
    OptionBuilder.withLongOpt(USER_LONG_OPTION);
    OptionBuilder.withDescription(USER_DESCRIPTION);
    Option user = OptionBuilder.create(USER_CHAR_OPTION);

    OptionBuilder.hasArgs();
    OptionBuilder.withArgName(ALGORITHMS_ARG_NAME);
    OptionBuilder.withLongOpt(ALGORITHMS_LONG_OPTION);
    OptionBuilder.withDescription(ALGORITHMS_DESCRIPTION);
    Option algorithms = OptionBuilder.create(ALGORITHMS_CHAR_OPTION);

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(METRIC_ARG_NAME);
    OptionBuilder.withLongOpt(METRIC_LONG_OPTION);
    OptionBuilder.withDescription(METRIC_DESCRIPTION);
    Option metric = OptionBuilder.create(METRIC_CHAR_OPTION);

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(SPEED_ARG_NAME);
    OptionBuilder.withLongOpt(SPEED_LONG_OPTION);
    OptionBuilder.withDescription(SPEED_DESCRIPTION);
    Option speed = OptionBuilder.create(SPEED_CHAR_OPTION);

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(COVERAGE_ARG_NAME);
    OptionBuilder.withLongOpt(COVERAGE_LONG_OPTION);
    OptionBuilder.withDescription(COVERAGE_DESCRIPTION);
    Option coverage = OptionBuilder.create(COVERAGE_CHAR_OPTION);

    return new Options().addOption(dataModel).addOption(user).addOption(algorithms).addOption(metric)
            .addOption(speed).addOption(coverage);
}

From source file:op.OPDE.java

/**
 * Hier ist die main Methode von OPDE. In dieser Methode wird auch festgestellt, wie OPDE gestartet wurde.
 * <ul>//  ww  w. j  a v  a2 s. co  m
 * <li>Im Standard Modus, das heisst mit graphischer Oberflche. Das drfte der hufigste Fall sein.</li>
 * <li>Im DFNImport Modus. Der wird meist auf dem Datenbankserver gebraucht um Nachts die Durchfhrungsnachweise anhand der
 * DFNImport Tabelle zu generieren. Das alles gehrt zu der Pflegeplanung.</li>
 * <li>Im BHPImport Modus. Auch dieser Modus wird auf dem DB-Server gebraucht um die Behandlungspflege Massnahmen
 * anhand der rztlichen Verordnungen zu generieren.</li>
 * </ul>
 *
 * @param args Hier stehen die Kommandozeilen Parameter. Diese werden mit
 */
public static void main(String[] args) throws Exception {
    /***
     *
     *              ____
     *            ,'  , `.
     *         ,-+-,.' _ |              ,--,
     *      ,-+-. ;   , ||            ,--.'|         ,---,
     *     ,--.'|'   |  ;|            |  |,      ,-+-. /  |
     *    |   |  ,', |  ':  ,--.--.   `--'_     ,--.'|'   |
     *    |   | /  | |  || /       \  ,' ,'|   |   |  ,"' |
     *    '   | :  | :  |,.--.  .-. | '  | |   |   | /  | |
     *    ;   . |  ; |--'  \__\/: . . |  | :   |   | |  | |
     *    |   : |  | ,     ," .--.; | '  : |__ |   | |  |/
     *    |   : '  |/     /  /  ,.  | |  | '.'||   | |--'
     *    ;   | |`-'     ;  :   .'   \;  :    ;|   |/
     *    |   ;/         |  ,     .-./|  ,   / '---'
     *    '---'           `--`---'     ---`-'
     *
     */
    uptime = SYSCalendar.now();

    //        arial14 = new Font("Arial", Font.PLAIN, 14);
    //        arial28 = new Font("Arial", Font.PLAIN, 28);

    /***
     *      _                                               ____                  _ _
     *     | |    __ _ _ __   __ _ _   _  __ _  __ _  ___  | __ ) _   _ _ __   __| | | ___
     *     | |   / _` | '_ \ / _` | | | |/ _` |/ _` |/ _ \ |  _ \| | | | '_ \ / _` | |/ _ \
     *     | |__| (_| | | | | (_| | |_| | (_| | (_| |  __/ | |_) | |_| | | | | (_| | |  __/
     *     |_____\__,_|_| |_|\__, |\__,_|\__,_|\__, |\___| |____/ \__,_|_| |_|\__,_|_|\___|
     *                       |___/             |___/
     */
    lang = ResourceBundle.getBundle("languageBundle", Locale.getDefault());

    validatorFactory = Validation.buildDefaultValidatorFactory();

    /***
     *       ____      _       _             _ _                                                        _   _
     *      / ___|__ _| |_ ___| |__     __ _| | |  _ __ ___   __ _ _   _  ___    _____  _____ ___ _ __ | |_(_) ___  _ __  ___
     *     | |   / _` | __/ __| '_ \   / _` | | | | '__/ _ \ / _` | | | |/ _ \  / _ \ \/ / __/ _ \ '_ \| __| |/ _ \| '_ \/ __|
     *     | |__| (_| | || (__| | | | | (_| | | | | | | (_) | (_| | |_| |  __/ |  __/>  < (_|  __/ |_) | |_| | (_) | | | \__ \
     *      \____\__,_|\__\___|_| |_|  \__,_|_|_| |_|  \___/ \__, |\__,_|\___|  \___/_/\_\___\___| .__/ \__|_|\___/|_| |_|___/
     *                                                       |___/                               |_|
     */
    Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
        @Override
        public void uncaughtException(Thread t, Throwable e) {
            OPDE.fatal(e);
        }
    });

    localProps = new SortedProperties();
    props = new Properties();

    /***
     *                         _      _               ___        __
     *      _ __ ___  __ _  __| |    / \   _ __  _ __|_ _|_ __  / _| ___
     *     | '__/ _ \/ _` |/ _` |   / _ \ | '_ \| '_ \| || '_ \| |_ / _ \
     *     | | |  __/ (_| | (_| |  / ___ \| |_) | |_) | || | | |  _| (_) |
     *     |_|  \___|\__,_|\__,_| /_/   \_\ .__/| .__/___|_| |_|_|  \___/
     *                                    |_|   |_|
     */
    appInfo = new AppInfo();

    /***
     *       ____                                          _   _     _               ___        _   _
     *      / ___|___  _ __ ___  _ __ ___   __ _ _ __   __| | | |   (_)_ __   ___   / _ \ _ __ | |_(_) ___  _ __  ___
     *     | |   / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` | | |   | | '_ \ / _ \ | | | | '_ \| __| |/ _ \| '_ \/ __|
     *     | |__| (_) | | | | | | | | | | | (_| | | | | (_| | | |___| | | | |  __/ | |_| | |_) | |_| | (_) | | | \__ \
     *      \____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_| |_____|_|_| |_|\___|  \___/| .__/ \__|_|\___/|_| |_|___/
     *                                                                                   |_|
     */
    Options opts = new Options();
    opts.addOption("h", "hilfe", false, "Gibt die Hilfeseite fr OPDE aus.");
    opts.addOption("v", "version", false, "Zeigt die Versionsinformationen an.");
    opts.addOption("x", "experimental", false,
            "Schaltet experimentelle Programm-Module fr User frei, die Admin Rechte haben. VORSICHT !!!!");
    opts.addOption("a", "anonym", false,
            "Blendet die Bewohnernamen in allen Ansichten aus. Spezieller Modus fr Schulungsmaterial zu erstellen.");
    opts.addOption("w", "workingdir", true,
            "Damit kannst Du ein anderes Arbeitsverzeichnis setzen. Wenn Du diese Option weglsst, dann ist das Dein Benutzerverzeichnis: "
                    + System.getProperty("user.home"));
    opts.addOption("l", "debug", false,
            "Schaltet alle Ausgaben ein auf der Konsole ein, auch die, die eigentlich nur whrend der Softwareentwicklung angezeigt werden.");
    opts.addOption("t", "training", false,
            "Wird fr Einarbeitungsversionen bentigt. Frbt die Oberflche anders ein und zeigt eine Warnmeldung nach jeder Anmeldung.");
    Option optFTPserver = OptionBuilder.withLongOpt("ftpserver").withArgName("ip or hostname").hasArgs(1)
            .withDescription(lang.getString("cmdline.ftpserver")).create("f");
    opts.addOption(optFTPserver);
    //        opts.addOption("p", "pidfile", false, "Path to the pidfile which needs to be deleted when this application ends properly.");

    Option notification = OptionBuilder.withLongOpt("notification").hasOptionalArg()
            .withDescription("Schickt allen festgelegten Empfngern die jeweilige Benachrichtungs-Mail.")
            .create("n");
    notification.setArgName(
            "Liste der Empfnger (durch Komma getrennt, ohne Leerzeichen. UID verwenden). Damit kannst Du die Benachrichtigungen einschrnken. Fehlt diese Liste, erhalten ALLE Empfnger eine Mail.");
    opts.addOption(notification);

    opts.addOption(OptionBuilder.withLongOpt("jdbc").hasArg().withDescription(lang.getString("cmdline.jdbc"))
            .create("j"));

    Option dfnimport = OptionBuilder //.withArgName("datum")
            .withLongOpt("dfnimport").hasOptionalArg()
            .withDescription("Startet OPDE im DFNImport Modus fr den aktuellen Tag.").create("d");
    dfnimport.setArgName(
            "Anzahl der Tage (+ oder -) abweichend vom aktuellen Tag fr den der Import durchgefhrt werden soll. Nur in Ausnahmefllen anzuwenden.");
    opts.addOption(dfnimport);

    Option bhpimport = OptionBuilder.withLongOpt("bhpimport").hasOptionalArg()
            .withDescription("Startet OPDE im BHPImport Modus fr den aktuellen Tag.").create("b");
    //        bhpimport.setOptionalArg(true);
    bhpimport.setArgName(
            "Anzahl der Tage (+ oder -) abweichend vom aktuellen Tag fr den der Import durchgefhrt werden soll. Nur in Ausnahmefllen anzuwenden.");
    opts.addOption(bhpimport);

    BasicParser parser = new BasicParser();
    CommandLine cl = null;
    String footer = "http://www.Offene-Pflege.de";

    /***
     *      _          _
     *     | |__   ___| |_ __    ___  ___ _ __ ___  ___ _ __
     *     | '_ \ / _ \ | '_ \  / __|/ __| '__/ _ \/ _ \ '_ \
     *     | | | |  __/ | |_) | \__ \ (__| | |  __/  __/ | | |
     *     |_| |_|\___|_| .__/  |___/\___|_|  \___|\___|_| |_|
     *                  |_|
     */
    try {
        cl = parser.parse(opts, args);
    } catch (ParseException ex) {
        HelpFormatter f = new HelpFormatter();
        f.printHelp("OffenePflege.jar [OPTION]",
                "Offene-Pflege.de, Version " + appInfo.getVersion() + " Build:" + appInfo.getBuildnum(), opts,
                footer);
        System.exit(0);
    }

    // Alternative FTP-Server
    if (cl.hasOption("f")) {
        UPDATE_FTPSERVER = cl.getOptionValue("f");
    }

    if (cl.hasOption("h")) {
        HelpFormatter f = new HelpFormatter();
        f.printHelp("OffenePflege.jar [OPTION]",
                "Offene-Pflege.de, Version " + appInfo.getVersion() + " Build:" + appInfo.getBuildnum(), opts,
                footer);
        System.exit(0);
    }

    String homedir = System.getProperty("user.home");
    // alternatice working dir
    if (cl.hasOption("w")) {
        File dir = new File(cl.getOptionValue("w"));
        if (dir.exists() && dir.isDirectory()) {
            homedir = dir.getAbsolutePath();
        }
    }
    opwd = homedir + sep + AppInfo.dirBase;

    /***
     *                                                                ___
     *       __ _ _ __   ___  _ __  _   _ _ __ ___   ___  _   _ ___  |__ \
     *      / _` | '_ \ / _ \| '_ \| | | | '_ ` _ \ / _ \| | | / __|   / /
     *     | (_| | | | | (_) | | | | |_| | | | | | | (_) | |_| \__ \  |_|
     *      \__,_|_| |_|\___/|_| |_|\__, |_| |_| |_|\___/ \__,_|___/  (_)
     *                              |___/
     */
    if (cl.hasOption("a")) { // anonym Modus
        //localProps.put("anonym", "true");
        anonym = true;
        anonymize = new HashMap[] { SYSConst.getNachnamenAnonym(), SYSConst.getVornamenFrauAnonym(),
                SYSConst.getVornamenMannAnonym() };
    } else {
        anonym = false;
    }

    /***
     *      _       _ _                _       _
     *     (_)_ __ (_) |_   _ __  _ __(_)_ __ | |_ ___ _ __ ___
     *     | | '_ \| | __| | '_ \| '__| | '_ \| __/ _ \ '__/ __|
     *     | | | | | | |_  | |_) | |  | | | | | ||  __/ |  \__ \
     *     |_|_| |_|_|\__| | .__/|_|  |_|_| |_|\__\___|_|  |___/
     *                     |_|
     */
    printers = new LogicalPrinters();

    /***
     *      _                 _   _                 _                                   _   _
     *     | | ___   __ _  __| | | | ___   ___ __ _| |  _ __  _ __ ___  _ __   ___ _ __| |_(_) ___  ___
     *     | |/ _ \ / _` |/ _` | | |/ _ \ / __/ _` | | | '_ \| '__/ _ \| '_ \ / _ \ '__| __| |/ _ \/ __|
     *     | | (_) | (_| | (_| | | | (_) | (_| (_| | | | |_) | | | (_) | |_) |  __/ |  | |_| |  __/\__ \
     *     |_|\___/ \__,_|\__,_| |_|\___/ \___\__,_|_| | .__/|_|  \___/| .__/ \___|_|   \__|_|\___||___/
     *                                                 |_|             |_|
     */
    if (loadLocalProperties()) {

        //            try {
        //                FileAppender fileAppender = new FileAppender(layout, , true);
        //                logger.addAppender(fileAppender);
        //            } catch (IOException ex) {
        //                fatal(ex);
        //            }

        animation = localProps.containsKey("animation") && localProps.getProperty("animation").equals("true");

        logger.info("######### START ###########  " + OPDE.getAppInfo().getProgname() + ", v"
                + OPDE.getAppInfo().getVersion() + "/" + OPDE.getAppInfo().getBuildnum());
        logger.info(System.getProperty("os.name").toLowerCase());

        /***
         *      _     ____       _                   ___ ___
         *     (_)___|  _ \  ___| |__  _   _  __ _  |__ \__ \
         *     | / __| | | |/ _ \ '_ \| | | |/ _` |   / / / /
         *     | \__ \ |_| |  __/ |_) | |_| | (_| |  |_| |_|
         *     |_|___/____/ \___|_.__/ \__,_|\__, |  (_) (_)
         *                                   |___/
         */
        if (cl.hasOption("l") || SYSTools.catchNull(localProps.getProperty("debug")).equalsIgnoreCase("true")) {
            debug = true;
            logger.setLevel(Level.DEBUG);
        } else {
            debug = false;
            logger.setLevel(Level.INFO);
        }

        Logger.getLogger("org.hibernate").setLevel(Level.OFF);

        if (cl.hasOption("x")
                || SYSTools.catchNull(localProps.getProperty("experimental")).equalsIgnoreCase("true")) {
            experimental = true;

        } else {
            experimental = false;
        }

        if (cl.hasOption("t")
                || SYSTools.catchNull(localProps.getProperty("training")).equalsIgnoreCase("true")) {
            training = true;
        } else {
            training = false;
        }

        /***
         *          _ _                       _                                               _   _ _     _        ___ 
         *       __| | |____   _____ _ __ ___(_) ___  _ __     ___ ___  _ __ ___  _ __   __ _| |_(_) |__ | | ___  |__ \
         *      / _` | '_ \ \ / / _ \ '__/ __| |/ _ \| '_ \   / __/ _ \| '_ ` _ \| '_ \ / _` | __| | '_ \| |/ _ \   / /
         *     | (_| | |_) \ V /  __/ |  \__ \ | (_) | | | | | (_| (_) | | | | | | |_) | (_| | |_| | |_) | |  __/  |_| 
         *      \__,_|_.__/ \_/ \___|_|  |___/_|\___/|_| |_|  \___\___/|_| |_| |_| .__/ \__,_|\__|_|_.__/|_|\___|  (_) 
         *                                                                       |_|                                   
         */
        url = cl.hasOption("j") ? cl.getOptionValue("j") : localProps.getProperty("javax.persistence.jdbc.url");
        String hostkey = OPDE.getLocalProps().getProperty("hostkey");
        String cryptpassword = localProps.getProperty("javax.persistence.jdbc.password");
        DesEncrypter desEncrypter = new DesEncrypter(hostkey);
        Connection jdbcConnection = DriverManager.getConnection(url,
                localProps.getProperty("javax.persistence.jdbc.user"), desEncrypter.decrypt(cryptpassword));
        if (appInfo.getDbversion() != getDBVersion(jdbcConnection)) {
            SYSFilesTools.print(lang.getString("cant.start.with.version.mismatch"), false);
            System.exit(1);
        }
        jdbcConnection.close();

        /***
         *          _ ____   _      ____        _        _
         *         | |  _ \ / \    |  _ \  __ _| |_ __ _| |__   __ _ ___  ___
         *      _  | | |_) / _ \   | | | |/ _` | __/ _` | '_ \ / _` / __|/ _ \
         *     | |_| |  __/ ___ \  | |_| | (_| | || (_| | |_) | (_| \__ \  __/
         *      \___/|_| /_/   \_\ |____/ \__,_|\__\__,_|_.__/ \__,_|___/\___|
         *
         */
        Properties jpaProps = new Properties();
        jpaProps.put("javax.persistence.jdbc.user", localProps.getProperty("javax.persistence.jdbc.user"));

        try {
            jpaProps.put("javax.persistence.jdbc.password", desEncrypter.decrypt(cryptpassword));
        } catch (Exception e) {
            if (Desktop.isDesktopSupported()) {
                JOptionPane.showMessageDialog(null, SYSTools.xx("misc.msg.decryption.failure"),
                        appInfo.getProgname(), JOptionPane.ERROR_MESSAGE);
            } else {
                OPDE.fatal(e);
            }
            System.exit(1);
        }

        jpaProps.put("javax.persistence.jdbc.driver", localProps.getProperty("javax.persistence.jdbc.driver"));
        jpaProps.put("javax.persistence.jdbc.url", url);

        //            if (cl.hasOption("d") || cl.hasOption("d")) {  // not for BHP or DFN
        //                jpaProps.put("eclipselink.cache.shared.default", "false");
        //            } else {
        //                jpaProps.put("eclipselink.cache.shared.default", "true");
        //            }

        jpaProps.put("eclipselink.cache.shared.default", "false");
        jpaProps.put("eclipselink.session.customizer", "entity.JPAEclipseLinkSessionCustomizer");
        emf = Persistence.createEntityManagerFactory("OPDEPU", jpaProps);

        /***
         *     __     __            _
         *     \ \   / /__ _ __ ___(_) ___  _ __
         *      \ \ / / _ \ '__/ __| |/ _ \| '_ \
         *       \ V /  __/ |  \__ \ | (_) | | | |
         *        \_/ \___|_|  |___/_|\___/|_| |_|
         *
         */
        String header = SYSTools.getWindowTitle("");
        if (cl.hasOption("v")) {
            System.out.println(header);
            System.out.println(footer);
            System.exit(0);
        }

        /***
         *       ____                           _         ____  _____ _   _
         *      / ___| ___ _ __   ___ _ __ __ _| |_ ___  |  _ \|  ___| \ | |___
         *     | |  _ / _ \ '_ \ / _ \ '__/ _` | __/ _ \ | | | | |_  |  \| / __|
         *     | |_| |  __/ | | |  __/ | | (_| | ||  __/ | |_| |  _| | |\  \__ \
         *      \____|\___|_| |_|\___|_|  \__,_|\__\___| |____/|_|   |_| \_|___/
         *
         */
        if (cl.hasOption("d")) {
            EntityManager em = OPDE.createEM();

            try {
                em.getTransaction().begin();
                Users rootUser = em.find(Users.class, "admin");

                SYSLogin rootLogin = em.merge(new SYSLogin(rootUser));
                OPDE.setLogin(rootLogin);
                initProps();

                // create the new DFNs
                DFNTools.generate(em);
                // move over the floating ones that have not yet been clicked to the current day
                DFNTools.moveFloating(em);

                em.getTransaction().commit();
            } catch (Exception ex) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                fatal(ex);
            } finally {
                em.close();
            }
            System.exit(0);
        }

        /***
         *       ____                           _         ____  _   _ ____
         *      / ___| ___ _ __   ___ _ __ __ _| |_ ___  | __ )| | | |  _ \ ___
         *     | |  _ / _ \ '_ \ / _ \ '__/ _` | __/ _ \ |  _ \| |_| | |_) / __|
         *     | |_| |  __/ | | |  __/ | | (_| | ||  __/ | |_) |  _  |  __/\__ \
         *      \____|\___|_| |_|\___|_|  \__,_|\__\___| |____/|_| |_|_|   |___/
         *
         */
        if (cl.hasOption("b")) {

            EntityManager em = OPDE.createEM();

            try {
                em.getTransaction().begin();
                Users rootUser = em.find(Users.class, "admin");

                SYSLogin rootLogin = em.merge(new SYSLogin(rootUser));
                OPDE.setLogin(rootLogin);
                initProps();

                BHPTools.generate(em);

                em.getTransaction().commit();
            } catch (Exception ex) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                fatal(ex);
            } finally {
                em.close();
            }
            System.exit(0);
        }

        /***
         *      _   _       _   _  __ _           _   _
         *     | \ | | ___ | |_(_)/ _(_) ___ __ _| |_(_) ___  _ __
         *     |  \| |/ _ \| __| | |_| |/ __/ _` | __| |/ _ \| '_ \
         *     | |\  | (_) | |_| |  _| | (_| (_| | |_| | (_) | | | |
         *     |_| \_|\___/ \__|_|_| |_|\___\__,_|\__|_|\___/|_| |_|
         *
         */
        if (cl.hasOption("n")) {

            EntityManager em = OPDE.createEM();

            try {
                em.getTransaction().begin();
                Users rootUser = em.find(Users.class, "admin");

                SYSLogin rootLogin = em.merge(new SYSLogin(rootUser));
                OPDE.setLogin(rootLogin);
                initProps();

                EMailSystem.notify(cl.getOptionValue("n"));

                em.getTransaction().commit();
            } catch (Exception ex) {
                if (em.getTransaction().isActive()) {
                    em.getTransaction().rollback();
                }
                fatal(ex);
            } finally {
                em.close();
            }
            System.exit(0);
        }

        // to speed things later. The first connection loads the while JPA system.
        EntityManager em1 = createEM();
        em1.close();

        UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        setStandardFont();

        try {
            css = SYSTools.readFileAsString(opwd + sep + AppInfo.dirTemplates + sep + AppInfo.fileStandardCSS);
        } catch (IOException ie) {
            css = "";
        }

        // JideSoft
        Lm.verifyLicense("Torsten Loehr", "Open-Pflege.de", "G9F4JW:Bm44t62pqLzp5woAD4OCSUAr2");
        WizardStyle.setStyle(WizardStyle.JAVA_STYLE);
        // JideSoft

        /***
         *      _____               __  __       _        ____
         *     |  ___| __ _ __ ___ |  \/  | __ _(_)_ __  / /\ \
         *     | |_ | '__| '_ ` _ \| |\/| |/ _` | | '_ \| |  | |
         *     |  _|| |  | | | | | | |  | | (_| | | | | | |  | |
         *     |_|  |_|  |_| |_| |_|_|  |_|\__,_|_|_| |_| |  | |
         *                                               \_\/_/
         */

        //        JFrame frm = new JFrame();
        //            frm.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        //            frm.setLayout(new FlowLayout());
        //
        //                    frm.getContentPane().add(new PnlBodyScheme(new Properties()));
        //
        //                    frm.setVisible(true);

        SYSTools.checkForSoftwareupdates();

        mainframe = new FrmMain();

        mainframe.setVisible(true);

    }
}

From source file:opendap.metacat.old_code.ThreddsCrawler.java

/**
 * @param args/*from  w w  w  . ja va 2s  .c om*/
 */
@SuppressWarnings("static-access")
public static void main(String[] args) {

    ThreddsCrawler crawler = new ThreddsCrawler();

    // create the command line parser
    CommandLineParser parser = new PosixParser();

    // create the Options
    Options options = new Options();

    options.addOption("r", "read-cache", false, "Read catalogs from the cache");
    options.addOption("n", "no-cache", false, "Do not cache catalogs");
    options.addOption("p", "print-catalogs", false, "Print the THREDDS catalogs");
    options.addOption("v", "verbose", false, "Verbose output");

    options.addOption(OptionBuilder.withLongOpt("cache-name")
            .withDescription("Use this to set a prefix for the cache name.").hasArg().withArgName("cacheName")
            .create());

    options.addOption(OptionBuilder.withLongOpt("catalog-root").withDescription("use this as the root catalog")
            .hasArg().withArgName("catalogRoot").create());

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

        String catalogURL = line.getOptionValue("catalog-root");
        System.out.println("Catalog Root: " + catalogURL);

        crawler.cacheNamePrefix = line.getOptionValue("cache-name");
        System.out.println("Cache name: " + crawler.cacheNamePrefix);

        if (line.hasOption("v"))
            crawler.verbose = true;

        if (line.hasOption("n")) {
            if (crawler.verbose)
                System.out.println("Caching is off");
            crawler.crawlCatalog(catalogURL, false, System.out);
            if (crawler.verbose)
                System.out.println("Found " + new Integer(crawler.catalogsVisited).toString() + " catalogs.");
        } else if (line.hasOption("r")) {
            if (crawler.verbose)
                System.out.println("Reading from cache, no network accesses");
            crawler.crawlCatalogCache(System.out, line.hasOption("p"));
            if (crawler.verbose)
                System.out.println("Read " + new Integer(crawler.catalogsVisited).toString() + " catalogs.");
        } else if (line.hasOption("p")) {
            throw new Exception(
                    "The Print Catalog option (-p) can only be used when reading from the cache (-r).");
        } else {
            if (crawler.verbose)
                System.out.println("Caching is on");
            crawler.crawlCatalog(catalogURL, true, System.out);
            crawler.tcc.saveCatalogCache();
            if (crawler.verbose)
                System.out.println("Found " + new Integer(crawler.catalogsVisited).toString() + " catalogs.");
        }

    } catch (ParseException exp) {
        System.err.println("Unexpected exception:" + exp.getMessage());
    }

    catch (Exception e) {
        System.err.println("Error : " + e.getMessage());
        e.printStackTrace();
    }
}

From source file:org.acmsl.queryj.tools.cli.QueryJCLIHelper.java

/**
 * Creates the command-line option for the <i>custom SQL</i>.
 * @return such <code>Option</code> instance.
 *///from w  w  w  .j av  a2  s.  c o  m
public Option createCustomSqlOption() {
    OptionBuilder.withArgName("file");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription(CUSTOM_SQL_OPTION_DESCRIPTION);
    OptionBuilder.withLongOpt(CUSTOM_SQL_LONG_OPTION);
    OptionBuilder.isRequired(false);
    return OptionBuilder.create(CUSTOM_SQL_OPTION);
}

From source file:org.acmsl.queryj.tools.cli.QueryJCLIHelper.java

/**
 * Creates the command-line long option for the <i>help</i>.
 * @return such <code>Option</code> instance.
 *//*  w ww  .  j a  va  2  s.c o  m*/
@NotNull
public Option createHelpLongOption() {
    OptionBuilder.withDescription(HELP_OPTION_DESCRIPTION);
    OptionBuilder.withLongOpt(HELP_LONG_OPTION);
    OptionBuilder.isRequired(false);
    return OptionBuilder.create(HELP_LONG_OPTION);
}

From source file:org.agiso.tempel.starter.Bootstrap.java

private static Options configureTempelOptions() {
    Options options = new Options();

    Option help = new Option("h", "help", false, "print this help message");
    options.addOption(help);//  ww w. j a v a2s .com

    Option version = new Option("v", "version", false, "print the version information and exit");
    options.addOption(version);

    @SuppressWarnings("static-access")
    Option directory = OptionBuilder.withLongOpt("directory")
            .withDescription("create resources in defined directory").hasArg().withArgName("DIRECTORY")
            .create("d");
    options.addOption(directory);

    @SuppressWarnings("static-access")
    Option property = OptionBuilder.withLongOpt("define").withArgName("property=value").hasArgs(2)
            .withValueSeparator().withDescription("use value for given property").create("D");
    options.addOption(property);

    @SuppressWarnings("static-access")
    Option debug = OptionBuilder.withLongOpt("debug").withDescription("run Tempel in debug mode").create();
    options.addOption(debug);

    return options;
}

From source file:org.alder.fotobuchconvert.ifolor.IfolorToScribusMain.java

@SuppressWarnings("static-access")
public static void main(String[] args) {
    // create Options object
    Options options = new Options();
    options.addOption(OptionBuilder.withLongOpt(OPT_IN).hasArg().withDescription("Input file (type ifolor)")
            .isRequired().create('i'));
    options.addOption(OptionBuilder.withLongOpt(OPT_OUT).hasArg().withDescription("Output file (type scibus)")
            .isRequired().create('o'));
    options.addOption(OptionBuilder.withLongOpt(OPT_ABSOLUTE_PATHS)
            .withDescription("Convert resource paths (eg. images) to absolute paths").create());
    options.addOption(/*from   w  ww .ja v  a 2 s .c o  m*/
            OptionBuilder.withLongOpt(OPT_TEST).withDescription("Test mode (only first 4 pages)").create('t'));
    CommandLineParser parser = new PosixParser();

    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println("Unexpected exception:" + e.getMessage());

        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(IfolorToScribusMain.class.getSimpleName() + " --in <file.dpp> --out <file.sla>",
                options);
        return;
    }

    log.trace("infile: " + cmd.getOptionValue(OPT_IN));
    log.trace("outfile: " + cmd.getOptionValue(OPT_OUT));
    log.trace("absolutePaths: " + cmd.hasOption(OPT_ABSOLUTE_PATHS));
    log.trace("test: " + cmd.hasOption(OPT_TEST));

    try {
        File infile = new File(cmd.getOptionValue(OPT_IN));
        if (!infile.exists()) {
            System.err.println("input file " + infile + " does not exist");
            System.exit(1);
        }
        ProjectPath path = new ProjectPath(infile);
        File outFile = new File(cmd.getOptionValue(OPT_OUT));

        // conversion
        IfolorLoader loader = new IfolorLoader();
        Book book = loader.load(path);

        if (cmd.hasOption(OPT_TEST))
            book.reducePagesForTesting();

        ScribusExporter f = new ScribusExporter();

        f.export(outFile, book);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.apache.ctakes.assertion.medfacts.cleartk.TrainAssertionModel.java

public static void main(String args[]) {

    Options options = new Options();

    Option modelDirectoryOption = OptionBuilder.withLongOpt(TrainAssertionModel.PARAM_NAME_MODEL_DIRECTORY)
            .withArgName("DIR").hasArg().isRequired()
            .withDescription(/*from w  w  w. jav a  2 s  . c o  m*/
                    "the directory where the model is written to for training, or read from for decoding")
            .create();
    options.addOption(modelDirectoryOption);

    Option trainingInputDirectoryOption = OptionBuilder
            .withLongOpt(TrainAssertionModel.PARAM_NAME_TRAINING_INPUT_DIRECTORY).withArgName("DIR").hasArg()
            .isRequired().withDescription("directory where input training xmi files are located").create();
    options.addOption(trainingInputDirectoryOption);

    Option decodingInputDirectoryOption = OptionBuilder
            .withLongOpt(TrainAssertionModel.PARAM_NAME_DECODING_INPUT_DIRECTORY).withArgName("DIR").hasArg()
            .isRequired().withDescription("directory where input xmi files are located for decoding").create();
    options.addOption(decodingInputDirectoryOption);

    Option decodingOutputDirectoryOption = OptionBuilder
            .withLongOpt(TrainAssertionModel.PARAM_NAME_DECODING_OUTPUT_DIRECTORY).withArgName("DIR").hasArg()
            .isRequired()
            .withDescription("directory where output xmi files that are generated in decoding are placed")
            .create();
    options.addOption(decodingOutputDirectoryOption);

    CommandLineParser parser = new GnuParser();

    boolean invalidInput = false;

    CommandLine commandLine = null;
    String modelDirectory = null;
    String trainingInputDirectory = null;
    String decodingInputDirectory = null;
    String decodingOutputDirectory = null;
    try {
        commandLine = parser.parse(options, args);

        modelDirectory = commandLine.getOptionValue(TrainAssertionModel.PARAM_NAME_MODEL_DIRECTORY);
        trainingInputDirectory = commandLine
                .getOptionValue(TrainAssertionModel.PARAM_NAME_TRAINING_INPUT_DIRECTORY);
        decodingInputDirectory = commandLine
                .getOptionValue(TrainAssertionModel.PARAM_NAME_DECODING_INPUT_DIRECTORY);
        decodingOutputDirectory = commandLine
                .getOptionValue(TrainAssertionModel.PARAM_NAME_DECODING_OUTPUT_DIRECTORY);
    } catch (ParseException e) {
        invalidInput = true;
        logger.error("unable to parse command-line arguments", e);
    }

    if (modelDirectory == null || modelDirectory.isEmpty() || trainingInputDirectory == null
            || trainingInputDirectory.isEmpty() || decodingInputDirectory == null
            || decodingInputDirectory.isEmpty() || decodingOutputDirectory == null
            || decodingOutputDirectory.isEmpty()) {
        logger.error("required parameters not supplied");
        invalidInput = true;
    }

    if (invalidInput) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(TrainAssertionModel.class.getName(), options, true);
        return;
    }

    logger.info(String.format(
            "%n" + "model dir:           \"%s\"%n" + "training input dir:  \"%s\"%n"
                    + "decoding input dir:  \"%s\"%n" + "decoding output dir: \"%s\"%n",
            modelDirectory, trainingInputDirectory, decodingInputDirectory, decodingOutputDirectory));

    String maxentModelOutputDirectory = modelDirectory + "/maxent";
    try {
        AnalysisEngineDescription dataWriter = AnalysisEngineFactory.createEngineDescription(
                AssertionCleartkAnalysisEngine.class, AssertionComponents.CTAKES_CTS_TYPE_SYSTEM_DESCRIPTION,
                DefaultDataWriterFactory.PARAM_DATA_WRITER_CLASS_NAME,
                MaxentStringOutcomeDataWriter.class.getName(),
                DirectoryDataWriterFactory.PARAM_OUTPUT_DIRECTORY, maxentModelOutputDirectory);
        testClassifier(dataWriter, maxentModelOutputDirectory, trainingInputDirectory, decodingInputDirectory,
                decodingOutputDirectory);
    } catch (Exception e) {
        logger.error("Some exception happened while training or decoding...", e);
        return;
    }

}