use of eu.esdihumboldt.hale.common.core.report.impl.DefaultReporter in project hale by halestudio.
the class ProjectHandler method onSuccess.
@Override
protected void onSuccess(EnvironmentManager context, String projectId, File projectFile, Project project, ReportFile reportFile) {
super.onSuccess(context, projectId, projectFile, project, reportFile);
if (isEnabled()) {
// load transformation environment if not yet done
if (transformationEnvironment == null) {
try {
transformationEnvironment = new ProjectTransformationEnvironment(projectId, new FileIOSupplier(projectFile), reportFile);
// check alignment
if (transformationEnvironment.getAlignment() == null) {
throw new IllegalStateException("Alignment missing or failed to load");
}
if (transformationEnvironment.getAlignment().getActiveTypeCells().isEmpty()) {
throw new IllegalStateException("Alignment contains no active type relations");
}
} catch (Exception e) {
log.error("Could not load transformation environment for project " + projectId, e);
status = Status.BROKEN;
transformationEnvironment = null;
context.removeEnvironment(projectId);
// log the exception as report
Reporter<Message> report = new DefaultReporter<Message>("Load project transformation environment", ProjectIO.ACTION_LOAD_PROJECT, Message.class, false);
report.error(new MessageImpl(e.getMessage(), e));
reportFile.publishReport(report);
}
} else {
// XXX somehow check if project was changed?
}
if (transformationEnvironment != null) {
context.addEnvironment(transformationEnvironment);
status = Status.ACTIVE;
}
} else {
// clear transformation environment
status = Status.INACTIVE;
transformationEnvironment = null;
context.removeEnvironment(projectId);
}
}
Aggregations