Search in sources :

Example 6 with ReportTO

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;
}
Also used : TriggerKey(org.quartz.TriggerKey) Entity(org.apache.syncope.core.persistence.api.entity.Entity) Trigger(org.quartz.Trigger) SchedulerException(org.quartz.SchedulerException) ReportTO(org.apache.syncope.common.lib.to.ReportTO) ReportExec(org.apache.syncope.core.persistence.api.entity.ReportExec)

Example 7 with 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;
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) ReportTO(org.apache.syncope.common.lib.to.ReportTO)

Example 8 with ReportTO

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;
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) ReportTO(org.apache.syncope.common.lib.to.ReportTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 9 with ReportTO

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());
    }
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) UserReportletConf(org.apache.syncope.common.lib.report.UserReportletConf) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ReportTO(org.apache.syncope.common.lib.to.ReportTO) Test(org.junit.jupiter.api.Test)

Example 10 with ReportTO

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());
}
Also used : ReportTO(org.apache.syncope.common.lib.to.ReportTO) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) BulkExecDeleteQuery(org.apache.syncope.common.rest.api.beans.BulkExecDeleteQuery) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

ReportTO (org.apache.syncope.common.lib.to.ReportTO)16 Test (org.junit.jupiter.api.Test)9 ImplementationTO (org.apache.syncope.common.lib.to.ImplementationTO)5 Response (javax.ws.rs.core.Response)4 UserReportletConf (org.apache.syncope.common.lib.report.UserReportletConf)3 ExecTO (org.apache.syncope.common.lib.to.ExecTO)3 ExecuteQuery (org.apache.syncope.common.rest.api.beans.ExecuteQuery)3 ArrayList (java.util.ArrayList)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 StringResourceModel (org.apache.wicket.model.StringResourceModel)2 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)1 URI (java.net.URI)1 Date (java.util.Date)1 MultilevelPanel (org.apache.syncope.client.console.panels.MultilevelPanel)1 ReportDirectoryPanel (org.apache.syncope.client.console.reports.ReportDirectoryPanel)1 ReportExecutionDetails (org.apache.syncope.client.console.reports.ReportExecutionDetails)1 ReportTemplateDirectoryPanel (org.apache.syncope.client.console.reports.ReportTemplateDirectoryPanel)1 JobActionPanel (org.apache.syncope.client.console.widgets.JobActionPanel)1 LoggerTO (org.apache.syncope.common.lib.log.LoggerTO)1 AuditReportletConf (org.apache.syncope.common.lib.report.AuditReportletConf)1