use of net.sf.jasperreports.engine.JasperCompileManager in project opennms by OpenNMS.
the class JasperReportService method compileReport.
/**
* Compiles the given {@link JasperDesign} (*.jrxml) to a {@link JasperReport} (*.jasper)
*
* @param jasperDesign The Design (*.jrxml) to compile
* @return The compiled report (*.jasper)
* @throws ReportException If the design could not be compiled.
*/
private JasperReport compileReport(JasperDesign jasperDesign) throws ReportException {
try {
JasperReport report;
// If the target report is written in Java, use our custom JDT compiler
if (JRReport.LANGUAGE_JAVA.equals(jasperDesign.getLanguage())) {
JasperReportsContext reportsContext = new SimpleJasperReportsContext();
JRPropertiesUtil.getInstance(reportsContext).setProperty(JRCompiler.COMPILER_PREFIX + JRReport.LANGUAGE_JAVA, CustomJRJdtCompiler.class.getCanonicalName());
JasperCompileManager jasperCompilerManager = JasperCompileManager.getInstance(reportsContext);
report = jasperCompilerManager.compile(jasperDesign);
} else {
// Otherwise, use the default that Jasper providers
report = JasperCompileManager.compileReport(jasperDesign);
}
for (Object eachKey : System.getProperties().keySet()) {
String eachStringKey = (String) eachKey;
if (eachStringKey.startsWith("net.sf.jasperreports")) {
report.setProperty(eachStringKey, System.getProperty(eachStringKey));
}
}
compileSubreportsRecursively(report);
return report;
} catch (final JRException e) {
LOG.error("unable to compile jasper report {}", e);
throw new ReportException("unable to compile jasperReport", e);
}
}
Aggregations