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