Search in sources :

Example 6 with Report

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);
}
Also used : ReportExecExportFormat(org.apache.syncope.common.lib.types.ReportExecExportFormat) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Date(java.util.Date) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Autowired(org.springframework.beans.factory.annotation.Autowired) TextSerializer(org.apache.syncope.core.logic.cocoon.TextSerializer) ByteArrayInputStream(java.io.ByteArrayInputStream) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) XMLGenerator(org.apache.cocoon.sax.component.XMLGenerator) Method(java.lang.reflect.Method) Triple(org.apache.commons.lang3.tuple.Triple) XMLSerializer(org.apache.cocoon.sax.component.XMLSerializer) ExecTO(org.apache.syncope.common.lib.to.ExecTO) MimeConstants(org.apache.xmlgraphics.util.MimeConstants) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) JobNamer(org.apache.syncope.core.provisioning.api.job.JobNamer) Pipeline(org.apache.cocoon.pipeline.Pipeline) Collectors(java.util.stream.Collectors) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) StandardCharsets(java.nio.charset.StandardCharsets) IOUtils(org.apache.commons.io.IOUtils) EntityFactory(org.apache.syncope.core.persistence.api.entity.EntityFactory) List(java.util.List) JobAction(org.apache.syncope.common.lib.types.JobAction) ReportTO(org.apache.syncope.common.lib.to.ReportTO) ConfDAO(org.apache.syncope.core.persistence.api.dao.ConfDAO) XSLTTransformer(org.apache.syncope.core.logic.cocoon.XSLTTransformer) SAXPipelineComponent(org.apache.cocoon.sax.SAXPipelineComponent) StandardEntitlement(org.apache.syncope.common.lib.types.StandardEntitlement) ZipInputStream(java.util.zip.ZipInputStream) ReportExecStatus(org.apache.syncope.common.lib.types.ReportExecStatus) FopSerializer(org.apache.syncope.core.logic.cocoon.FopSerializer) StreamSource(javax.xml.transform.stream.StreamSource) OrderByClause(org.apache.syncope.core.persistence.api.dao.search.OrderByClause) HashMap(java.util.HashMap) ArrayUtils(org.apache.commons.lang3.ArrayUtils) JobKey(org.quartz.JobKey) ReportExecDAO(org.apache.syncope.core.persistence.api.dao.ReportExecDAO) SchedulerException(org.quartz.SchedulerException) ReportDataBinder(org.apache.syncope.core.provisioning.api.data.ReportDataBinder) ClientExceptionType(org.apache.syncope.common.lib.types.ClientExceptionType) JobTO(org.apache.syncope.common.lib.to.JobTO) OutputStream(java.io.OutputStream) Report(org.apache.syncope.core.persistence.api.entity.Report) ReportDAO(org.apache.syncope.core.persistence.api.dao.ReportDAO) NonCachingPipeline(org.apache.cocoon.pipeline.NonCachingPipeline) Component(org.springframework.stereotype.Component) ReportExec(org.apache.syncope.core.persistence.api.entity.ReportExec) JobType(org.apache.syncope.common.lib.types.JobType) Transactional(org.springframework.transaction.annotation.Transactional) ExecTO(org.apache.syncope.common.lib.to.ExecTO) 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 7 with Report

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

Example 8 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() {
    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());
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) ReportExec(org.apache.syncope.core.persistence.api.entity.ReportExec) Date(java.util.Date) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 9 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);
    assertNotNull(report.getExecs());
    assertFalse(report.getExecs().isEmpty());
    assertEquals(1, report.getExecs().size());
}
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 10 with Report

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);
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) ReportExec(org.apache.syncope.core.persistence.api.entity.ReportExec) 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