Package org.openbel.framework.common

Examples of org.openbel.framework.common.SimpleOutput


    protected void setReportable(Reportable reportable) {
        if (reportable != null) {
            this.reportable = reportable;
        } else {
            SimpleOutput so = new SimpleOutput();
            so.setErrorStream(err);
            so.setOutputStream(out);
            this.reportable = so;
        }
    }
View Full Code Here


     * @param configs
     */
    public PhaseApplication(String[] args) {
        super(args);

        final SimpleOutput reportable = new SimpleOutput();
        reportable.setErrorStream(System.err);
        reportable.setOutputStream(System.out);
        setReportable(reportable);

        setOptions(getPhaseConfiguration());

        // Initialize the system configuration either through the
View Full Code Here

     * @param args {@link String}[] the command-line arguments
     */
    public CacheManager(String[] args) {
        super(args);

        final SimpleOutput reportable = new SimpleOutput();
        reportable.setErrorStream(System.err);
        reportable.setOutputStream(System.out);
        setReportable(reportable);

        printApplicationInfo();

        initializeSystemConfiguration();

        config = getSystemConfiguration();
        cacheLookupService = new DefaultCacheLookupService();
        cacheService = new DefaultCacheableResourceService();
        final NamespaceIndexerService nsindexer =
                new NamespaceIndexerServiceImpl();
        final NamespaceService namespace = new DefaultNamespaceService(
                cacheService, cacheLookupService, nsindexer);
        cacheMgrService = new DefaultCacheManagerService(
                cacheLookupService, namespace, getReportable());

        Option[] options = getOptions();
        if (options.length == 0) {
            printUsage();
            bail(GENERAL_FAILURE);
        }

        reportable.output("Using cache directory: "
                + config.getCacheDirectory().getAbsolutePath());

        for (int i = 0; i < options.length; i++) {
            if (i != 0) {
                reportable.output("");
            }

            handleOption(options[i]);
        }
    }
View Full Code Here

     * @param args Command-line arguments
     */
    public Semantics(String[] args) {
        super(args);

        final SimpleOutput reportable = new SimpleOutput();
        reportable.setErrorStream(System.err);
        reportable.setOutputStream(System.out);
        setReportable(reportable);

        FunctionEnum[] values = FunctionEnum.values();

        // Print the number of functions.
View Full Code Here

    }

    public DocumentConverter(String[] args) {
        super(args, false);

        final SimpleOutput reportable = new SimpleOutput();
        reportable.setErrorStream(System.err);
        // Normal output is written to stderr because the output document
        // may be written to stdout.
        reportable.setOutputStream(System.err);
        setReportable(reportable);
        printApplicationInfo();

        if (hasOption('h')) {
            printHelp(true);
View Full Code Here

        if (extraArgs.size() == 0) {
            // print out the usage if no arguments are given
          printUsage();
          // Another SimpleOutput is used here, and it uses stdout because at this
          // point nothing else will need to be output.
          SimpleOutput so = new SimpleOutput();
          so.setErrorStream(System.out);
          so.error("\n");
            so.error("No documents specified.");
            end();
        } else if (extraArgs.size() > 1) {
            fatal("Only a single document can be specified.");
        }
        final String inputFileName = extraArgs.get(0);
View Full Code Here

    private final ValidationService validationService;

    public BelCheck(String[] args) {
        super(args);

        final SimpleOutput reportable = new SimpleOutput();
        reportable.setErrorStream(System.err);
        reportable.setOutputStream(System.out);
        setReportable(reportable);

        printApplicationInfo("BEL Check Utility");

        initializeSystemConfiguration();

        validator = createValidator();
        converter = createConverter();
        belValidator = new BELValidatorServiceImpl();
        belConverter = new BELConverterServiceImpl();
        final CacheableResourceService cache =
                new DefaultCacheableResourceService();
        final CacheLookupService cacheLookup = new DefaultCacheLookupService();
        annoDefService = new DefaultAnnotationDefinitionService(
                cache, cacheLookup);
        final NamespaceIndexerService nsindexer =
                new NamespaceIndexerServiceImpl();
        final NamespaceService nsService = new DefaultNamespaceService(
                cache, cacheLookup, nsindexer);
        final SemanticService semantics = new SemanticServiceImpl(nsService);
        final AnnotationService annotationService =
                new DefaultAnnotationService();
        validationService = new DefaultValidationService(
                nsService, semantics, annotationService);

        boolean pedantic = hasOption(PEDANTIC_OPTION);
        boolean permissive = hasOption(PERMISSIVE_OPTION);
        boolean verbose = hasOption(StandardOptions.LONG_OPT_VERBOSE);
        boolean quiet = hasOption(QUIET_OPTION);
        boolean summary = hasOption(SUMMARY_OPTION);

        if (pedantic && permissive) {
            fatal(CHECK_PEDANTIC_PERMISSIVE_ERROR);
        }

        List<String> fileArgs = getExtraneousArguments();
        if (!hasItems(fileArgs)) {
          // print out the usage if no arguments were given
          printUsage();
          reportable.error("\n");
            reportable.error(NO_DOCUMENT_FILES);
            end();
        }
        if (fileArgs.size() > 1) {
            fatal("Only a single document can be specified.");
        }

        String fileArg = fileArgs.get(0);

        if (!isBELDocument(fileArg)) {
            final String error = fileArg + " is not a BEL document.";
            reportable.error(error);
            bail(ExitCode.GENERAL_FAILURE);
            return;
        }

        File file = new File(fileArg);
        if (!readable(file)) {
            final String error = Strings.INPUT_FILE_UNREADABLE + file;
            reportable.error(error);
            bail(ExitCode.GENERAL_FAILURE);
            return;
        }

        try {
            final String abspath = file.getAbsolutePath();

            if (verbose) {
                reportable.output("Validating BEL Document: " + abspath);
            }

            int numWarnings = 0;
            int numErrors = 0;

            final Document document;
            if (isXBEL(file)) {
                List<ValidationError> validationErrors = validator
                        .validateWithErrors(file);

                // if validation errors exist then report and fail document
                if (hasItems(validationErrors)) {
                    numErrors += validationErrors.size();
                    if (!quiet) {
                        reportValidationError(validationErrors);
                    }
                    if (summary) {
                        printSummary(fileArg, numWarnings, numErrors);
                    }
                    bail(ExitCode.VALIDATION_FAILURE);
                    return;
                }

                document = converter.toCommon(file);
            } else if (isBELScript(file)) {
                List<ValidationError> validationErrors =
                        new ArrayList<ValidationError>();
                BELParseResults results = belValidator
                        .validateBELScript(file);

                // if validation errors exist then report and fail document
                if (hasItems(results.getSyntaxErrors())) {
                    for (BELParseErrorException syntaxError : results
                            .getSyntaxErrors()) {
                        validationErrors.add(new ValidationError(file
                                .getAbsolutePath(), syntaxError
                                .getMessage(),
                                syntaxError.getLine(), syntaxError
                                        .getCharacter()));
                    }
                    numErrors += validationErrors.size();

                    if (!quiet) {
                        reportValidationError(validationErrors);
                    }
                    if (summary) {
                        printSummary(fileArg, numWarnings, numErrors);
                    }
                    bail(ExitCode.VALIDATION_FAILURE);
                    return;
                }

                document = belConverter.toCommon(results.getDocument());
            } else {
                // unreachable; checked with isBelDocument
                fatal("Unsupported document type");
                return;
            }

            int numAnnoDefErrors =
                    validateAnnotationDefinitions(document, quiet, permissive,
                            verbose);
            if (permissive) {
                numWarnings += numAnnoDefErrors;
            } else {
                numErrors += numAnnoDefErrors;
            }

            ValidationResult vr = validationService.validate(document);
            for (String e : vr.getErrors()) {
                if (permissive) {
                    numWarnings++;
                    if (!quiet) {
                        reportable.warning("VALIDATION WARNING: " + e);
                    }
                } else {
                    numErrors++;
                    if (!quiet) {
                        reportable.error("VALIDATION ERROR: " + e);
                    }
                }
            }

            for (String w : vr.getWarnings()) {
                if (pedantic) {
                    numErrors++;
                    if (!quiet) {
                        reportable.error("VALIDATION ERROR: " + w);
                    }
                } else {
                    numWarnings++;
                    if (!quiet) {
                        reportable.warning("VALIDATION WARNING: " + w);
                    }
                }
            }

            if (summary) {
                printSummary(fileArg, numWarnings, numErrors);
            }
            if (numErrors == 0) {
                reportable.output(ALL_DOCUMENTS_PASSED_VALIDATION);
                bail(ExitCode.SUCCESS);
            } else {
                bail(ExitCode.VALIDATION_FAILURE);
            }
        } catch (Exception e) {
            reportable.error("Failed to import BEL Document.");
            reportable.error("Reason: " + e.getMessage());
            bail(ExitCode.GENERAL_FAILURE);
        }
    }
View Full Code Here

     */
    public PhaseZeroApplication(String[] args) {
        super(args);
        this.commandLineArgs = args;

        final SimpleOutput reportable = new SimpleOutput();
        reportable.setErrorStream(System.err);
        reportable.setOutputStream(System.out);
        setReportable(reportable);
    }
View Full Code Here

    /**
     * Sets the reportable implementation for {@link System#out} and
     * {@link System#err}.
     */
    private void reportable() {
        final SimpleOutput reportable = new SimpleOutput();
        reportable.setErrorStream(System.err);
        reportable.setOutputStream(System.out);
        setReportable(reportable);
    }
View Full Code Here

    private final SystemConfiguration sysconfig;

    public KamComparator(String[] args) {
        super(args);

        final SimpleOutput reportable = new SimpleOutput();
        reportable.setErrorStream(System.err);
        reportable.setOutputStream(System.out);
        setReportable(reportable);

        printApplicationInfo();

        initializeSystemConfiguration();
View Full Code Here

TOP

Related Classes of org.openbel.framework.common.SimpleOutput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.