use of com.qcadoo.report.internal.util.ReportFormatFactory in project qcadoo by qcadoo.
the class ReportServiceImpl method generateReport.
private byte[] generateReport(final JasperReport template, final ReportType type, final Map<String, Object> parameters, final Locale locale) throws ReportException {
Session session = null;
try {
session = sessionFactory.openSession();
parameters.put(JRParameter.REPORT_LOCALE, locale);
parameters.put("Author", pdfHelper.getDocumentAuthor());
parameters.put(JRHibernateQueryExecuterFactory.PARAMETER_HIBERNATE_SESSION, session);
ResourceBundle resourceBundle = new MessageSourceResourceBundle(messageSource, locale);
parameters.put(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle);
parameters.put(JRParameter.REPORT_FORMAT_FACTORY, new ReportFormatFactory());
JasperPrint jasperPrint = JasperFillManager.fillReport(template, parameters);
JRExporter exporter = getExporter(type);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, stream);
exporter.exportReport();
return stream.toByteArray();
} catch (JRException e) {
throw new ReportException(ReportException.Type.GENERATE_REPORT_EXCEPTION, e);
} finally {
if (session != null) {
session.close();
}
}
}
Aggregations