Search in sources :

Example 1 with ReportExecutor

use of eu.bcvsolutions.idm.rpt.api.executor.ReportExecutor in project CzechIdMng by bcvsolutions.

the class DefaultReportManager method generate.

@Override
public void generate(EntityEvent<RptReportDto> event) {
    Assert.notNull(event, "Report event is required!");
    RptReportDto report = event.getContent();
    Assert.notNull(report, "Report is required!");
    Assert.notNull(report.getId(), "Persisted report is required!");
    // 
    ReportExecutor executor = reportExecutorRegistry.getPluginFor(report.getExecutorName());
    if (executor == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("reportExecutor", report.getExecutorName()));
    }
    // create new executor instance
    executor = (ReportExecutor) AutowireHelper.createBean(executor.getClass());
    // set event - event will continue after executor is processed
    executor.setEvent(event);
    // check if lrt for report is already prepared by scheduler
    boolean newTask = true;
    if (report.getLongRunningTask() != null) {
        // preserve exists lrt - execute only
        executor.setLongRunningTaskId(report.getLongRunningTask());
        newTask = false;
    }
    // set lrt into report for getting state
    LongRunningFutureTask<RptReportDto> lrt = taskManager.execute(executor);
    // set new lrt for report
    if (newTask) {
        report.setLongRunningTask(lrt.getExecutor().getLongRunningTaskId());
        fillReportName(report, executor);
        reportService.save(report);
    }
}
Also used : ReportExecutor(eu.bcvsolutions.idm.rpt.api.executor.ReportExecutor) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) RptReportDto(eu.bcvsolutions.idm.rpt.api.dto.RptReportDto)

Aggregations

ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)1 RptReportDto (eu.bcvsolutions.idm.rpt.api.dto.RptReportDto)1 ReportExecutor (eu.bcvsolutions.idm.rpt.api.executor.ReportExecutor)1