use of net.sf.jasperreports.engine.design.JRDesignReportTemplate in project midpoint by Evolveum.
the class ReportTypeUtil method loadJasperReport.
public static JasperReport loadJasperReport(ReportType reportType) throws SchemaException {
if (reportType.getTemplate() == null) {
throw new IllegalStateException("Could not create report. No jasper template defined.");
}
try {
// byte[] reportTemplate = Base64.decodeBase64(reportType.getTemplate());
//
// InputStream inputStreamJRXML = new ByteArrayInputStream(reportTemplate);
//JRXmlLoader.load(inputStreamJRXML);
JasperDesign jasperDesign = loadJasperDesign(reportType.getTemplate());
if (reportType.getTemplateStyle() != null) {
JRDesignReportTemplate templateStyle = new JRDesignReportTemplate(new JRDesignExpression("$P{" + PARAMETER_TEMPLATE_STYLES + "}"));
jasperDesign.addTemplate(templateStyle);
JRDesignParameter parameter = new JRDesignParameter();
parameter.setName(PARAMETER_TEMPLATE_STYLES);
parameter.setValueClass(JRTemplate.class);
parameter.setForPrompting(false);
jasperDesign.addParameter(parameter);
}
// if (StringUtils.isNotEmpty(finalQuery)){
JRDesignParameter parameter = new JRDesignParameter();
parameter.setName("finalQuery");
parameter.setValueClass(Object.class);
parameter.setForPrompting(false);
jasperDesign.addParameter(parameter);
// }
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
return jasperReport;
} catch (JRException ex) {
// LOGGER.error("Couldn't create jasper report design {}", ex.getMessage());
throw new SchemaException(ex.getMessage(), ex.getCause());
}
}
Aggregations