Search in sources :

Example 1 with ReportTemplate

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

the class JPAReportTemplateDAO method delete.

@Override
public void delete(final String key) {
    ReportTemplate template = find(key);
    if (template == null) {
        return;
    }
    entityManager().remove(template);
}
Also used : JPAReportTemplate(org.apache.syncope.core.persistence.jpa.entity.JPAReportTemplate) ReportTemplate(org.apache.syncope.core.persistence.api.entity.ReportTemplate)

Example 2 with ReportTemplate

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

the class ReportDataBinderImpl method getReport.

@Override
public void getReport(final Report report, final ReportTO reportTO) {
    BeanUtils.copyProperties(reportTO, report, IGNORE_REPORT_PROPERTIES);
    ReportTemplate template = reportTemplateDAO.find(reportTO.getTemplate());
    if (template == null) {
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing);
        sce.getElements().add("template");
        throw sce;
    }
    report.setTemplate(template);
    reportTO.getReportlets().forEach(reportletKey -> {
        Implementation reportlet = implementationDAO.find(reportletKey);
        if (reportlet == null) {
            LOG.debug("Invalid " + Implementation.class.getSimpleName() + " {}, ignoring...", reportletKey);
        } else {
            report.add(reportlet);
        }
    });
    // remove all implementations not contained in the TO
    report.getReportlets().removeIf(reportlet -> !reportTO.getReportlets().contains(reportlet.getKey()));
}
Also used : ReportTemplate(org.apache.syncope.core.persistence.api.entity.ReportTemplate) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation)

Example 3 with ReportTemplate

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

the class ReportTemplateLogic method create.

@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_TEMPLATE_CREATE + "')")
public ReportTemplateTO create(final String key) {
    if (reportTemplateDAO.find(key) != null) {
        throw new DuplicateException(key);
    }
    ReportTemplate reportTemplate = entityFactory.newEntity(ReportTemplate.class);
    reportTemplate.setKey(key);
    reportTemplateDAO.save(reportTemplate);
    return getReportTemplateTO(key);
}
Also used : DuplicateException(org.apache.syncope.core.persistence.api.dao.DuplicateException) ReportTemplate(org.apache.syncope.core.persistence.api.entity.ReportTemplate) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 4 with ReportTemplate

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

the class ReportTemplateTest method find.

@Test
public void find() {
    ReportTemplate optin = reportTemplateDAO.find("sample");
    assertNotNull(optin);
    assertNotNull(optin.getFOTemplate());
    assertNotNull(optin.getCSVTemplate());
    assertNotNull(optin.getHTMLTemplate());
}
Also used : ReportTemplate(org.apache.syncope.core.persistence.api.entity.ReportTemplate) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 5 with ReportTemplate

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

the class ReportTemplateTest method save.

@Test
public void save() {
    ReportTemplate template = entityFactory.newEntity(ReportTemplate.class);
    template.setKey("new");
    template.setCSVTemplate("<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'></xsl:stylesheet>");
    ReportTemplate actual = reportTemplateDAO.save(template);
    assertNotNull(actual);
    assertNotNull(actual.getKey());
    assertNotNull(actual.getCSVTemplate());
    assertNull(actual.getHTMLTemplate());
    actual.setHTMLTemplate("<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'></xsl:stylesheet>");
    actual = reportTemplateDAO.save(actual);
    assertNotNull(actual.getCSVTemplate());
    assertNotNull(actual.getHTMLTemplate());
}
Also used : ReportTemplate(org.apache.syncope.core.persistence.api.entity.ReportTemplate) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

ReportTemplate (org.apache.syncope.core.persistence.api.entity.ReportTemplate)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)3 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)2 Test (org.junit.jupiter.api.Test)2 ReportTemplateTO (org.apache.syncope.common.lib.to.ReportTemplateTO)1 DuplicateException (org.apache.syncope.core.persistence.api.dao.DuplicateException)1 Entity (org.apache.syncope.core.persistence.api.entity.Entity)1 Implementation (org.apache.syncope.core.persistence.api.entity.Implementation)1 Report (org.apache.syncope.core.persistence.api.entity.Report)1 JPAReportTemplate (org.apache.syncope.core.persistence.jpa.entity.JPAReportTemplate)1