Search in sources :

Example 16 with Report

use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.

the class ReportLogic method getReference.

@Override
protected Triple<JobType, String, String> getReference(final JobKey jobKey) {
    String key = JobNamer.getReportKeyFromJobName(jobKey.getName());
    Report report = reportDAO.find(key);
    return report == null ? null : Triple.of(JobType.REPORT, key, binder.buildRefDesc(report));
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report)

Example 17 with Report

use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.

the class ReportLogic method actionJob.

@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_EXECUTE + "')")
@Override
public void actionJob(final String key, final JobAction action) {
    Report report = reportDAO.find(key);
    if (report == null) {
        throw new NotFoundException("Report " + key);
    }
    doActionJob(JobNamer.getJobKey(report), action);
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 18 with Report

use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.

the class ReportTest method delete.

@Test
public void delete() {
    Report report = reportDAO.find("0062ea9c-924d-4ecf-9961-4492a8cc6d1b");
    assertNotNull(report);
    reportDAO.delete("0062ea9c-924d-4ecf-9961-4492a8cc6d1b");
    report = reportDAO.find("0062ea9c-924d-4ecf-9961-4492a8cc6d1b");
    assertNull(report);
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 19 with Report

use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.

the class ReportTest method save.

@Test
public void save() {
    Implementation reportlet1 = entityFactory.newEntity(Implementation.class);
    reportlet1.setKey("UserReportlet" + UUID.randomUUID().toString());
    reportlet1.setEngine(ImplementationEngine.JAVA);
    reportlet1.setType(ImplementationType.REPORTLET);
    reportlet1.setBody(POJOHelper.serialize(new UserReportletConf("first")));
    reportlet1 = implementationDAO.save(reportlet1);
    Implementation reportlet2 = entityFactory.newEntity(Implementation.class);
    reportlet2.setKey("UserReportlet" + UUID.randomUUID().toString());
    reportlet2.setEngine(ImplementationEngine.JAVA);
    reportlet2.setType(ImplementationType.REPORTLET);
    reportlet2.setBody(POJOHelper.serialize(new UserReportletConf("second")));
    reportlet2 = implementationDAO.save(reportlet2);
    int beforeCount = reportDAO.findAll().size();
    Report report = entityFactory.newEntity(Report.class);
    report.setName("new report");
    report.setActive(true);
    report.add(reportlet1);
    report.add(reportlet2);
    report.setTemplate(reportTemplateDAO.find("sample"));
    report = reportDAO.save(report);
    assertNotNull(report);
    assertNotNull(report.getKey());
    int afterCount = reportDAO.findAll().size();
    assertEquals(afterCount, beforeCount + 1);
}
Also used : UserReportletConf(org.apache.syncope.common.lib.report.UserReportletConf) Report(org.apache.syncope.core.persistence.api.entity.Report) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 20 with Report

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);
    report = reportDAO.find(UUID.randomUUID().toString());
    assertNull(report);
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

Report (org.apache.syncope.core.persistence.api.entity.Report)20 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)9 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)7 SchedulerException (org.quartz.SchedulerException)7 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)6 Test (org.junit.jupiter.api.Test)6 Date (java.util.Date)4 ReportExec (org.apache.syncope.core.persistence.api.entity.ReportExec)4 HashMap (java.util.HashMap)2 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)2 ExecTO (org.apache.syncope.common.lib.to.ExecTO)2 JobTO (org.apache.syncope.common.lib.to.JobTO)2 ReportTO (org.apache.syncope.common.lib.to.ReportTO)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Method (java.lang.reflect.Method)1