Search in sources :

Example 36 with IOReport

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

the class AppSchemaIsolatedWorkspacesMappingTest method loadSchema.

private static Schema loadSchema(SchemaReader schemaReader, String resource) throws Exception {
    DefaultInputSupplier input = new DefaultInputSupplier(AppSchemaIsolatedWorkspacesMappingTest.class.getResource(resource).toURI());
    schemaReader.setSharedTypes(new DefaultTypeIndex());
    schemaReader.setSource(input);
    schemaReader.validate();
    IOReport report = schemaReader.execute(null);
    assertTrue(report.isSuccess());
    assertTrue("Errors are contained in the report", report.getErrors().isEmpty());
    return schemaReader.getSchema();
}
Also used : DefaultTypeIndex(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeIndex) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Example 37 with IOReport

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

the class AppSchemaMappingTest method loadSchema.

private static Schema loadSchema(SchemaReader schemaReader, String resource) throws Exception {
    DefaultInputSupplier input = new DefaultInputSupplier(AppSchemaMappingTest.class.getResource(resource).toURI());
    schemaReader.setSharedTypes(new DefaultTypeIndex());
    schemaReader.setSource(input);
    schemaReader.validate();
    IOReport report = schemaReader.execute(null);
    assertTrue(report.isSuccess());
    assertTrue("Errors are contained in the report", report.getErrors().isEmpty());
    return schemaReader.getSchema();
}
Also used : DefaultTypeIndex(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeIndex) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Example 38 with IOReport

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

the class ExportJob method run.

/**
 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
 */
@Override
protected IStatus run(IProgressMonitor monitor) {
    IOReporter defaultReporter = writer.createReporter();
    defaultReporter.setSuccess(false);
    IOReport report = defaultReporter;
    try {
        ATransaction trans = log.begin(defaultReporter.getTaskName());
        try {
            IOReport result = writer.execute(new ProgressMonitorIndicator(monitor));
            if (result != null) {
                report = result;
            } else {
                defaultReporter.setSuccess(true);
            }
        } catch (Throwable e) {
            defaultReporter.error(new IOMessageImpl(e.getLocalizedMessage(), e));
        } finally {
            trans.end();
        }
    } catch (Throwable e) {
        defaultReporter.error(new IOMessageImpl(e.getLocalizedMessage(), e));
    }
    if (monitor.isCanceled()) {
        reset();
        return Status.CANCEL_STATUS;
    }
    // add report to report service
    reportHandler.publishReport(report);
    // show message to user
    if (report.isSuccess()) {
        // no message, we rely on the report being
        // shown/processed
        // let advisor handle results
        advisor.handleResults(writer);
        reset();
        return Status.OK_STATUS;
    } else {
        reset();
        log.error(report.getSummary());
        return new Status(Status.ERROR, "eu.esdihumboldt.hale.common.headless", report.getSummary(), null);
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IOReporter(eu.esdihumboldt.hale.common.core.io.report.IOReporter) ProgressMonitorIndicator(eu.esdihumboldt.hale.common.core.io.ProgressMonitorIndicator) ATransaction(de.fhg.igd.slf4jplus.ATransaction) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport)

Example 39 with IOReport

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

the class ValidationJob method run.

/**
 * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
 */
@Override
protected IStatus run(IProgressMonitor monitor) {
    boolean successful = true;
    for (InstanceValidator validator : this.validators) {
        IOReporter defaultReporter = validator.createReporter();
        defaultReporter.setSuccess(false);
        IOReport report = defaultReporter;
        try {
            ATransaction trans = log.begin(defaultReporter.getTaskName());
            try {
                if (writer != null) {
                    // set validation schemas (may have been determined only
                    // during writer execution)
                    // set schemas
                    List<? extends Locatable> schemas = writer.getValidationSchemas();
                    validator.setSchemas(schemas.toArray(new Locatable[schemas.size()]));
                }
                validator.setServiceProvider(serviceProvider);
                IOReport result = validator.execute(new ProgressMonitorIndicator(monitor));
                if (result != null) {
                    report = result;
                } else {
                    defaultReporter.setSuccess(true);
                }
            } catch (Throwable e) {
                defaultReporter.error(new IOMessageImpl(e.getLocalizedMessage(), e));
            } finally {
                trans.end();
            }
        } catch (Throwable e) {
            defaultReporter.error(new IOMessageImpl(e.getLocalizedMessage(), e));
        }
        if (monitor.isCanceled()) {
            reset();
            return Status.CANCEL_STATUS;
        }
        // add report to report service
        reportHandler.publishReport(report);
        // show message to user
        if (report.isSuccess()) {
            // info message
            log.info(report.getSummary());
        } else {
            // error message
            log.error(report.getSummary());
            successful = false;
        }
    }
    reset();
    if (successful) {
        log.userInfo("All validations completed successfully.");
        return Status.OK_STATUS;
    } else {
        log.userError("There were validation failures. Please check the reports for details.");
        return ERROR_STATUS;
    }
}
Also used : InstanceValidator(eu.esdihumboldt.hale.common.instance.io.InstanceValidator) IOReporter(eu.esdihumboldt.hale.common.core.io.report.IOReporter) ProgressMonitorIndicator(eu.esdihumboldt.hale.common.core.io.ProgressMonitorIndicator) ATransaction(de.fhg.igd.slf4jplus.ATransaction) IOMessageImpl(eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) Locatable(eu.esdihumboldt.hale.common.core.io.supplier.Locatable)

Example 40 with IOReport

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

the class SkosCodeListTest method readCodeList.

private CodeList readCodeList(URI source) throws Exception {
    CodeListReader reader = new SkosCodeListReader();
    reader.setSource(new DefaultInputSupplier(source));
    IOReport report = reader.execute(new LogProgressIndicator());
    assertTrue(report.isSuccess());
    return reader.getCodeList();
}
Also used : SkosCodeListReader(eu.esdihumboldt.hale.io.codelist.skos.reader.SkosCodeListReader) CodeListReader(eu.esdihumboldt.hale.common.codelist.io.CodeListReader) SkosCodeListReader(eu.esdihumboldt.hale.io.codelist.skos.reader.SkosCodeListReader) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) IOReport(eu.esdihumboldt.hale.common.core.io.report.IOReport) LogProgressIndicator(eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)

Aggregations

IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)102 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)34 Test (org.junit.Test)33 LogProgressIndicator (eu.esdihumboldt.hale.common.core.io.impl.LogProgressIndicator)25 List (java.util.List)23 QName (javax.xml.namespace.QName)23 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)22 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)22 HashMap (java.util.HashMap)22 File (java.io.File)14 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)11 XmlSchemaReader (eu.esdihumboldt.hale.io.xsd.reader.XmlSchemaReader)11 SchemaReader (eu.esdihumboldt.hale.common.schema.io.SchemaReader)10 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)8 IOProviderDescriptor (eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor)8 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)8 IOException (java.io.IOException)8 Ignore (org.junit.Ignore)8 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)7 IOReporter (eu.esdihumboldt.hale.common.core.io.report.IOReporter)7