Search in sources :

Example 1 with Report

use of org.dkpro.lab.reporting.Report in project dkpro-lab by dkpro.

the class DefaultLifeCycleManager method complete.

@Override
public void complete(TaskContext aContext, Task aConfiguration) throws LifeCycleException {
    aContext.getMetadata().setEnd(System.currentTimeMillis());
    aContext.message("Completing task [" + aConfiguration.getType() + "]");
    aContext.message("Running reports for task [" + aConfiguration.getType() + "]");
    List<Report> reports = new ArrayList<Report>(aConfiguration.getReports());
    int i = 1;
    for (Report report : reports) {
        for (int g = 0; g < 3; g++) {
            System.gc();
        }
        try {
            aContext.message("Starting report [" + report.getClass().getName() + "] (" + i + "/" + reports.size() + ")");
            report.setContext(aContext);
            report.execute();
            aContext.message("Report complete [" + report.getClass().getName() + "] (" + i + "/" + reports.size() + ")");
        } catch (Exception e) {
            aContext.error("Report failed [" + report.getClass().getName() + "] (" + i + "/" + reports.size() + ")", e);
            throw new LifeCycleException(e);
        } finally {
            i++;
        }
    }
    // potentially incomplete version of this file has to be deleted.
    try {
        aContext.storeBinary(TaskContextMetadata.METADATA_KEY, aContext.getMetadata());
    } catch (Throwable e) {
        aContext.getStorageService().delete(aContext.getId(), TaskContextMetadata.METADATA_KEY);
        throw new LifeCycleException("Unable to write [" + TaskContextMetadata.METADATA_KEY + "] to mark context as complete.", e);
    }
    aContext.message("Completed task [" + aConfiguration.getType() + "]");
}
Also used : Report(org.dkpro.lab.reporting.Report) ArrayList(java.util.ArrayList) LifeCycleException(org.dkpro.lab.engine.LifeCycleException) IOException(java.io.IOException) DataAccessResourceFailureException(org.springframework.dao.DataAccessResourceFailureException) LifeCycleException(org.dkpro.lab.engine.LifeCycleException)

Aggregations

IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 LifeCycleException (org.dkpro.lab.engine.LifeCycleException)1 Report (org.dkpro.lab.reporting.Report)1 DataAccessResourceFailureException (org.springframework.dao.DataAccessResourceFailureException)1