Search in sources :

Example 1 with ReportHandler

use of eu.esdihumboldt.hale.common.core.report.ReportHandler in project hale by halestudio.

the class GenerateDuplicates method loadProject.

private boolean loadProject() throws IOException {
    final AtomicBoolean success = new AtomicBoolean(true);
    LocatableInputSupplier<? extends InputStream> projectIn = new DefaultInputSupplier(context.getProject());
    ProjectTransformationEnvironment env = new ProjectTransformationEnvironment("sample", projectIn, new ReportHandler() {

        @Override
        public void publishReport(Report<?> report) {
            if (report.isSuccess() && report.getErrors().isEmpty()) {
                System.out.println(report.getSummary());
            } else {
                System.err.println("Error loading project: " + report.getSummary());
                success.set(false);
            }
        }
    });
    if (success.get()) {
        this.sourceSchema = env.getSourceSchema();
        this.targetSchema = env.getTargetSchema();
        this.examples = env.getAlignment();
        return true;
    }
    return false;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) ReportHandler(eu.esdihumboldt.hale.common.core.report.ReportHandler) ProjectTransformationEnvironment(eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment)

Example 2 with ReportHandler

use of eu.esdihumboldt.hale.common.core.report.ReportHandler in project hale by halestudio.

the class CityGMLPropagate method loadProject.

private boolean loadProject() throws IOException {
    final AtomicBoolean success = new AtomicBoolean(true);
    LocatableInputSupplier<? extends InputStream> projectIn = new DefaultInputSupplier(context.getProject());
    ProjectTransformationEnvironment env = new ProjectTransformationEnvironment("sample", projectIn, new ReportHandler() {

        @Override
        public void publishReport(Report<?> report) {
            if (report.isSuccess() && report.getErrors().isEmpty()) {
                System.out.println(report.getSummary());
            } else {
                System.err.println("Error loading project: " + report.getSummary());
                success.set(false);
            }
        }
    });
    if (success.get()) {
        this.sourceSchema = env.getSourceSchema();
        this.targetSchema = env.getTargetSchema();
        this.examples = env.getAlignment();
        return true;
    }
    return false;
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) ReportHandler(eu.esdihumboldt.hale.common.core.report.ReportHandler) ProjectTransformationEnvironment(eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment)

Example 3 with ReportHandler

use of eu.esdihumboldt.hale.common.core.report.ReportHandler in project hale by halestudio.

the class ExecTransformation method setupReportHandler.

private void setupReportHandler() {
    final ReportHandler delegateTo;
    if (context.getReportsOut() != null) {
        delegateTo = new ReportFile(context.getReportsOut());
    } else {
        delegateTo = null;
    }
    /*
		 * The report handler writes a summary to std out
		 */
    reportHandler = new ReportHandler() {

        @Override
        public void publishReport(Report<?> report) {
            ExecUtil.printSummary(report);
            if (delegateTo != null) {
                delegateTo.publishReport(report);
            }
        }
    };
}
Also used : ReportFile(eu.esdihumboldt.hale.common.headless.report.ReportFile) ReportHandler(eu.esdihumboldt.hale.common.core.report.ReportHandler)

Aggregations

ReportHandler (eu.esdihumboldt.hale.common.core.report.ReportHandler)3 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)2 ProjectTransformationEnvironment (eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ReportFile (eu.esdihumboldt.hale.common.headless.report.ReportFile)1