use of org.apache.syncope.core.persistence.api.entity.Report 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.Report in project syncope by apache.
the class ReportLogic method getJob.
@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_READ + "')")
@Override
public JobTO getJob(final String key) {
Report report = reportDAO.find(key);
if (report == null) {
throw new NotFoundException("Report " + key);
}
JobTO jobTO = null;
try {
jobTO = getJobTO(JobNamer.getJobKey(report));
} catch (SchedulerException e) {
LOG.error("Problems while retrieving scheduled job {}", JobNamer.getJobKey(report), e);
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
sce.getElements().add(e.getMessage());
throw sce;
}
if (jobTO == null) {
throw new NotFoundException("Job for report " + key);
}
return jobTO;
}
use of org.apache.syncope.core.persistence.api.entity.Report 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());
}
use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.
the class ReportTest method find.
@Test
public void find() {
Report report = reportDAO.find("0062ea9c-924d-4ecf-9961-4492a8cc6d1b");
assertNotNull(report);
assertNotNull(report.getExecs());
assertFalse(report.getExecs().isEmpty());
assertEquals(1, report.getExecs().size());
}
use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.
the class ReportTest method deleteReportExecution.
@Test
public void deleteReportExecution() {
ReportExec execution = reportExecDAO.find("c13f39c5-0d35-4bff-ba79-3cd5de940369");
int executionNumber = execution.getReport().getExecs().size();
reportExecDAO.delete("c13f39c5-0d35-4bff-ba79-3cd5de940369");
reportExecDAO.flush();
assertNull(reportExecDAO.find("0062ea9c-924d-4ecf-9961-4492a8cc6d1b"));
Report report = reportDAO.find("0062ea9c-924d-4ecf-9961-4492a8cc6d1b");
assertEquals(report.getExecs().size(), executionNumber - 1);
}
Aggregations