Search in sources :

Example 1 with Reporter

use of eu.esdihumboldt.hale.common.core.report.Reporter 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);
    }
}
Also used : Message(eu.esdihumboldt.hale.common.core.report.Message) Reporter(eu.esdihumboldt.hale.common.core.report.Reporter) DefaultReporter(eu.esdihumboldt.hale.common.core.report.impl.DefaultReporter) FileIOSupplier(eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier) ProjectTransformationEnvironment(eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment) MessageImpl(eu.esdihumboldt.hale.common.core.report.impl.MessageImpl) IOException(java.io.IOException)

Aggregations

FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)1 Message (eu.esdihumboldt.hale.common.core.report.Message)1 Reporter (eu.esdihumboldt.hale.common.core.report.Reporter)1 DefaultReporter (eu.esdihumboldt.hale.common.core.report.impl.DefaultReporter)1 MessageImpl (eu.esdihumboldt.hale.common.core.report.impl.MessageImpl)1 ProjectTransformationEnvironment (eu.esdihumboldt.hale.common.headless.impl.ProjectTransformationEnvironment)1 IOException (java.io.IOException)1