/** {@inheritDoc} */ @Override protected ModelAndView onSubmit( HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { ReportParameters parameters = (ReportParameters) command; if ((parameters.getFormat() == ReportFormat.PDF) || (parameters.getFormat() == ReportFormat.SVG)) { response.setContentType("application/pdf;charset=UTF-8"); response.setHeader("Content-disposition", "inline; filename=report.pdf"); response.setHeader("Pragma", "public"); response.setHeader("Cache-Control", "cache"); response.setHeader("Cache-Control", "must-revalidate"); } if (parameters.getFormat() == ReportFormat.CSV) { response.setContentType("text/csv;charset=UTF-8"); response.setHeader("Content-disposition", "inline; filename=report.csv"); response.setHeader("Pragma", "public"); response.setHeader("Cache-Control", "cache"); response.setHeader("Cache-Control", "must-revalidate"); } m_reportWrapperService.runAndRender( parameters, ReportMode.IMMEDIATE, response.getOutputStream()); return null; }
/** {@inheritDoc} */ @Override public void runAndRender( ReportParameters parameters, ReportMode mode, OutputStream outputStream) { // TODO remove this debug code Map<String, Object> reportParms = parameters.getReportParms(mode); for (String key : reportParms.keySet()) { String value; if (reportParms.get(key) == null) { value = "NULL"; } else { value = reportParms.get(key).toString(); } log.debug("param " + key + " set " + value); } try { getReportService(parameters.getReportId()) .runAndRender( parameters.getReportParms(mode), parameters.getReportId(), parameters.getFormat(), outputStream); } catch (ReportException reportException) { log.error("failed to run or render report: " + parameters.getReportId(), reportException); } }
/** {@inheritDoc} */ @Override public void run( ReportParameters parameters, ReportMode mode, DeliveryOptions deliveryOptions, String reportId) { if (!deliveryOptions.getPersist()) { ByteArrayOutputStream out = new ByteArrayOutputStream(); BufferedOutputStream bout = new BufferedOutputStream(out); try { getReportService(reportId) .runAndRender( parameters.getReportParms(mode), reportId, deliveryOptions.getFormat(), bout); } catch (ReportException reportException) { log.error("failed to run or render report: " + reportId, reportException); } mailReport(deliveryOptions, out); } else { String outputPath; try { outputPath = getReportService(reportId).run(parameters.getReportParms(mode), reportId); ReportCatalogEntry catalogEntry = new ReportCatalogEntry(); catalogEntry.setReportId(reportId); catalogEntry.setTitle(deliveryOptions.getInstanceId()); catalogEntry.setLocation(outputPath); catalogEntry.setDate(new Date()); m_reportStoreService.save(catalogEntry); if (deliveryOptions.getMailTo().length() != 0) { ByteArrayOutputStream out = new ByteArrayOutputStream(); BufferedOutputStream bout = new BufferedOutputStream(out); getReportService(reportId) .render(reportId, outputPath, deliveryOptions.getFormat(), bout); mailReport(deliveryOptions, out); } } catch (ReportException reportException) { log.error("failed to run or render report: " + reportId, reportException); } } }
/** {@inheritDoc} */ @Override public boolean validate(ReportParameters parameters, String reportId) { return getReportService(reportId).validate(parameters.getReportParms(), reportId); }