Search in sources :

Example 1 with ReportExec

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

the class JPAReportExecDAO method delete.

@Override
public void delete(final String key) {
    ReportExec execution = find(key);
    if (execution == null) {
        return;
    }
    delete(execution);
}
Also used : ReportExec(org.apache.syncope.core.persistence.api.entity.ReportExec) JPAReportExec(org.apache.syncope.core.persistence.jpa.entity.JPAReportExec)

Example 2 with ReportExec

use of org.apache.syncope.core.persistence.api.entity.ReportExec 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 3 with ReportExec

use of org.apache.syncope.core.persistence.api.entity.ReportExec 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 4 with ReportExec

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

the class ReportLogic method deleteExecution.

@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_DELETE + "')")
@Override
public ExecTO deleteExecution(final String executionKey) {
    ReportExec reportExec = reportExecDAO.find(executionKey);
    if (reportExec == null) {
        throw new NotFoundException("Report execution " + executionKey);
    }
    ExecTO reportExecToDelete = binder.getExecTO(reportExec);
    reportExecDAO.delete(reportExec);
    return reportExecToDelete;
}
Also used : ExecTO(org.apache.syncope.common.lib.to.ExecTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) ReportExec(org.apache.syncope.core.persistence.api.entity.ReportExec) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 5 with ReportExec

use of org.apache.syncope.core.persistence.api.entity.ReportExec 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)

Aggregations

ReportExec (org.apache.syncope.core.persistence.api.entity.ReportExec)9 Report (org.apache.syncope.core.persistence.api.entity.Report)4 Date (java.util.Date)3 ReportTO (org.apache.syncope.common.lib.to.ReportTO)3 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 List (java.util.List)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 ExecTO (org.apache.syncope.common.lib.to.ExecTO)2 ReportExecExportFormat (org.apache.syncope.common.lib.types.ReportExecExportFormat)2 SchedulerException (org.quartz.SchedulerException)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 URI (java.net.URI)1 StandardCharsets (java.nio.charset.StandardCharsets)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1