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();
}
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();
}
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);
}
}
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;
}
}
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();
}
Aggregations