use of org.apache.syncope.common.lib.to.ReportTO 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.common.lib.to.ReportTO in project syncope by apache.
the class ReportletWizardBuilder method onApplyInternal.
@Override
protected Serializable onApplyInternal(final ReportletWrapper modelObject) {
if (modelObject.getImplementationEngine() == ImplementationEngine.JAVA) {
ImplementationTO reportlet = implementationClient.read(ImplementationType.REPORTLET, modelObject.getImplementationKey());
try {
reportlet.setBody(MAPPER.writeValueAsString(modelObject.getConf()));
implementationClient.update(reportlet);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
ReportTO reportTO = restClient.read(report);
if (modelObject.isNew()) {
reportTO.getReportlets().add(modelObject.getImplementationKey());
}
restClient.update(reportTO);
return modelObject;
}
use of org.apache.syncope.common.lib.to.ReportTO in project syncope by apache.
the class ReportLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_DELETE + "')")
public ReportTO delete(final String key) {
Report report = reportDAO.find(key);
if (report == null) {
throw new NotFoundException("Report " + key);
}
ReportTO deletedReport = binder.getReportTO(report);
jobManager.unregister(report);
reportDAO.delete(report);
return deletedReport;
}
use of org.apache.syncope.common.lib.to.ReportTO in project syncope by apache.
the class ReportITCase method delete.
@Test
public void delete() {
ImplementationTO reportlet1 = new ImplementationTO();
reportlet1.setKey("UserReportletConf" + getUUIDString());
reportlet1.setEngine(ImplementationEngine.JAVA);
reportlet1.setType(ImplementationType.REPORTLET);
reportlet1.setBody(POJOHelper.serialize(new UserReportletConf("first")));
Response response = implementationService.create(reportlet1);
reportlet1.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
ImplementationTO reportlet2 = new ImplementationTO();
reportlet2.setKey("UserReportletConf" + getUUIDString());
reportlet2.setEngine(ImplementationEngine.JAVA);
reportlet2.setType(ImplementationType.REPORTLET);
reportlet2.setBody(POJOHelper.serialize(new UserReportletConf("second")));
response = implementationService.create(reportlet2);
reportlet2.setKey(response.getHeaderString(RESTHeaders.RESOURCE_KEY));
ReportTO report = new ReportTO();
report.setName("testReportForDelete" + getUUIDString());
report.getReportlets().add(reportlet1.getKey());
report.getReportlets().add(reportlet2.getKey());
report.setTemplate("sample");
report = createReport(report);
assertNotNull(report);
reportService.delete(report.getKey());
try {
reportService.read(report.getKey());
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
}
}
use of org.apache.syncope.common.lib.to.ReportTO in project syncope by apache.
the class ReportITCase method deleteExecutions.
@Test
public void deleteExecutions() {
Date start = new Date();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
ReportTO reportTO = reportService.read("0062ea9c-924d-4ecf-9961-4492a8cc6d1b");
reportTO.setKey(null);
reportTO.setName("deleteExecutions" + getUUIDString());
reportTO.getExecutions().clear();
reportTO = createReport(reportTO);
assertNotNull(reportTO);
String execKey = execReport(reportTO.getKey());
assertNotNull(execKey);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
Date end = new Date();
BulkActionResult result = reportService.deleteExecutions(new BulkExecDeleteQuery.Builder().key(reportTO.getKey()).startedAfter(start).endedBefore(end).build());
assertNotNull(result);
assertEquals(1, result.getResults().size());
assertEquals(execKey, result.getResults().keySet().iterator().next());
assertEquals(BulkActionResult.Status.SUCCESS, result.getResults().entrySet().iterator().next().getValue());
}
Aggregations