/** * Renders the report for a given query to html * * @param sessionId * @param report * @param acceptedPage * @param template * @return * @throws Exception * @throws IOException * @throws ResourceException */ public void renderReportHtml( String sessionId, String templateName, HtmlReport report, Integer acceptedPage) throws Exception { SaikuMasterModel model = sessionHolder.getModel(sessionId); if (model == null) { throw new SaikuAdhocException( Messages.getErrorString("ReportGeneratorService.ERROR_0001_MASTERMODEL_NOT_FOUND")); } sessionHolder.materializeModel(sessionId); String path = prptManager.getTemplatePath(); String solution = prptManager.getSolution(); if (templateName != null && !templateName.equals("default")) { ReportTemplate template = prptManager.getTemplate(path, solution, templateName); model.setReportTemplate(template); } MasterReport output = processReport(model); ByteArrayOutputStream stream = new ByteArrayOutputStream(); generateHtmlReport( output, stream, ParamUtils.getReportParameters("", model), report, acceptedPage); String string = stream.toString(); // if(log.isDebugEnabled()){ // writeHtmlFile(string); // } report.setData(string); }
/** * Generate the report * * @param output * @param stream * @param report * @param acceptedPage * @param query2 * @throws Exception */ private void generateHtmlReport( MasterReport output, OutputStream stream, Map<String, Object> reportParameters, HtmlReport report, Integer acceptedPage) throws Exception { final SimpleReportingComponent reportComponent = prptManager.getReportingComponent(); reportComponent.setReport(output); reportComponent.setPaginateOutput(true); reportComponent.setInputs(reportParameters); reportComponent.setDefaultOutputTarget(HtmlTableModule.TABLE_HTML_PAGE_EXPORT_TYPE); reportComponent.setOutputTarget(HtmlTableModule.TABLE_HTML_PAGE_EXPORT_TYPE); reportComponent.setDashboardMode(true); reportComponent.setOutputStream(stream); reportComponent.setAcceptedPage(acceptedPage); // reportComponent.setUseContentRepository(false); reportComponent.validate(); reportComponent.execute(); report.setCurrentPage(reportComponent.getAcceptedPage()); report.setPageCount(reportComponent.getPageCount()); }
public MasterReport getMasterReport(String fullPath, SimpleReportingComponent reportComponent) throws SaikuAdhocException { try { return prptManager.getMasterReport(fullPath, reportComponent); } catch (Exception e) { throw new SaikuAdhocException( Messages.getErrorString("Repository.ERROR_0001_PRPT_TEMPLATE_NOT_FOUND")); } }