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);
}
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()));
}
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);
}
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());
}
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());
}
Aggregations