use of org.apache.syncope.core.persistence.api.entity.ReportExec in project syncope by apache.
the class JPAReportExecDAO method delete.
@Override
public void delete(final String key) {
ReportExec execution = find(key);
if (execution == null) {
return;
}
delete(execution);
}
use of org.apache.syncope.core.persistence.api.entity.ReportExec in project syncope by apache.
the class ReportDataBinderImpl method getReportTO.
@Override
public ReportTO getReportTO(final Report report) {
ReportTO reportTO = new ReportTO();
reportTO.setKey(report.getKey());
reportTO.setTemplate(report.getTemplate().getKey());
BeanUtils.copyProperties(report, reportTO, IGNORE_REPORT_PROPERTIES);
reportTO.getReportlets().addAll(report.getReportlets().stream().map(Entity::getKey).collect(Collectors.toList()));
ReportExec latestExec = reportExecDAO.findLatestStarted(report);
if (latestExec == null) {
reportTO.setLatestExecStatus(StringUtils.EMPTY);
} else {
reportTO.setLatestExecStatus(latestExec.getStatus());
reportTO.setStart(latestExec.getStart());
reportTO.setEnd(latestExec.getEnd());
reportTO.setLastExec(reportTO.getStart());
}
reportTO.getExecutions().addAll(report.getExecs().stream().map(reportExec -> getExecTO(reportExec)).collect(Collectors.toList()));
String triggerName = JobNamer.getTriggerName(JobNamer.getJobKey(report).getName());
try {
Trigger trigger = scheduler.getScheduler().getTrigger(new TriggerKey(triggerName, Scheduler.DEFAULT_GROUP));
if (trigger != null) {
reportTO.setLastExec(trigger.getPreviousFireTime());
reportTO.setNextExec(trigger.getNextFireTime());
}
} catch (SchedulerException e) {
LOG.warn("While trying to get to " + triggerName, e);
}
return reportTO;
}
use of org.apache.syncope.core.persistence.api.entity.ReportExec in project syncope by apache.
the class ReportLogic method listExecutions.
@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_READ + "')")
@Override
public Pair<Integer, List<ExecTO>> listExecutions(final String key, final int page, final int size, final List<OrderByClause> orderByClauses) {
Report report = reportDAO.find(key);
if (report == null) {
throw new NotFoundException("Report " + key);
}
Integer count = reportExecDAO.count(key);
List<ExecTO> result = reportExecDAO.findAll(report, page, size, orderByClauses).stream().map(reportExec -> binder.getExecTO(reportExec)).collect(Collectors.toList());
return Pair.of(count, result);
}
use of org.apache.syncope.core.persistence.api.entity.ReportExec in project syncope by apache.
the class ReportLogic method deleteExecution.
@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_DELETE + "')")
@Override
public ExecTO deleteExecution(final String executionKey) {
ReportExec reportExec = reportExecDAO.find(executionKey);
if (reportExec == null) {
throw new NotFoundException("Report execution " + executionKey);
}
ExecTO reportExecToDelete = binder.getExecTO(reportExec);
reportExecDAO.delete(reportExec);
return reportExecToDelete;
}
use of org.apache.syncope.core.persistence.api.entity.ReportExec in project syncope by apache.
the class ReportTest method save.
@Test
public void save() {
Report report = reportDAO.find("0062ea9c-924d-4ecf-9961-4492a8cc6d1b");
assertNotNull(report);
assertEquals(1, report.getExecs().size());
ReportExec reportExec = entityFactory.newEntity(ReportExec.class);
reportExec.setReport(report);
reportExec.setStart(new Date());
reportExec.setEnd(new Date());
reportExec.setStatus(ReportExecStatus.SUCCESS);
report.add(reportExec);
reportExec = reportExecDAO.save(reportExec);
assertNotNull(reportExec);
assertNotNull(reportExec.getKey());
reportExecDAO.flush();
report = reportDAO.find("0062ea9c-924d-4ecf-9961-4492a8cc6d1b");
assertNotNull(report);
assertEquals(2, report.getExecs().size());
}
Aggregations