if (ReportOutputType.custom != reportTemplate.getOutputType()) { ReportOutputType finalOutputType = (outputType != null ) ? outputType : reportTemplate.getOutputType(); outputName = format("%s.%s", StringUtils.substringBeforeLast(outputName, "."), finalOutputType.getId());
if (ReportOutputType.custom != reportTemplate.getOutputType()) { ReportOutputType finalOutputType = (outputType != null ) ? outputType : reportTemplate.getOutputType(); outputName = format("%s.%s", StringUtils.substringBeforeLast(outputName, "."), finalOutputType.getId());
protected AbstractFormatter(FormatterFactoryInput formatterFactoryInput) { Preconditions.checkNotNull("\"rootBand\" parameter can not be null", formatterFactoryInput.getRootBand()); Preconditions.checkNotNull("\"reportTemplate\" parameter can not be null", formatterFactoryInput.getReportTemplate()); this.rootBand = formatterFactoryInput.getRootBand(); this.reportTemplate = formatterFactoryInput.getReportTemplate(); this.outputType = (formatterFactoryInput.getOutputType() != null) ? formatterFactoryInput.getOutputType() : reportTemplate.getOutputType(); this.outputStream = formatterFactoryInput.getOutputStream(); this.contentInliners.add(new BitmapContentInliner()); this.contentInliners.add(new HtmlContentInliner()); this.contentInliners.add(new ImageContentInliner()); }
protected AbstractFormatter(FormatterFactoryInput formatterFactoryInput) { checkNotNull(formatterFactoryInput.getRootBand(), "\"rootBand\" parameter can not be null"); checkNotNull(formatterFactoryInput.getReportTemplate(), "\"reportTemplate\" parameter can not be null"); this.rootBand = formatterFactoryInput.getRootBand(); this.reportTemplate = formatterFactoryInput.getReportTemplate(); this.outputType = (formatterFactoryInput.getOutputType() != null) ? formatterFactoryInput.getOutputType() : reportTemplate.getOutputType(); this.outputStream = formatterFactoryInput.getOutputStream(); }
protected ReportOutputDocument runReport(Report report, ReportTemplate reportTemplate, ReportOutputType outputType, Map<String, Object> params, OutputStream outputStream) { try { Preconditions.checkNotNull(report, "\"report\" parameter can not be null"); Preconditions.checkNotNull(reportTemplate, "\"reportTemplate\" can not be null"); Preconditions.checkNotNull(params, "\"params\" can not be null"); Preconditions.checkNotNull(outputStream, "\"outputStream\" can not be null"); Map<String, Object> handledParams = handleParameters(report, params); logReport("Started report [%s] with parameters [%s]", report, handledParams); ReportOutputType finalOutputType = (outputType != null) ? outputType : reportTemplate.getOutputType(); BandData rootBand = loadBandData(report, handledParams); generateReport(report, reportTemplate, finalOutputType, outputStream, handledParams, rootBand); logReport("Finished report [%s] with parameters [%s]", report, handledParams); String outputName = resolveOutputFileName(report, reportTemplate, outputType, rootBand); return createReportOutputDocument(report, finalOutputType, outputName, rootBand); } catch (ReportingInterruptedException e) { logReport("Report is canceled by user request. Report [%s] with parameters [%s].", report, params); throw e; } catch (ReportingException e) { logReport("An error occurred while running report [%s] with parameters [%s].", report, params); logException(e); //validation exception is usually shown to clients, so probably there is no need to add report name there (to keep the original message) if (!(e instanceof ValidationException)) { e.setReportDetails(format(" Report name [%s]", report.getName())); } throw e; } }
protected ReportOutputDocument runReport(Report report, ReportTemplate reportTemplate, ReportOutputType outputType, Map<String, Object> params, OutputStream outputStream) { try { Preconditions.checkNotNull(report, "\"report\" parameter can not be null"); Preconditions.checkNotNull(reportTemplate, "\"reportTemplate\" can not be null"); Preconditions.checkNotNull(params, "\"params\" can not be null"); Preconditions.checkNotNull(outputStream, "\"outputStream\" can not be null"); Map<String, Object> handledParams = handleParameters(report, params); logReport("Started report [%s] with parameters [%s]", report, handledParams); ReportOutputType finalOutputType = (outputType != null) ? outputType : reportTemplate.getOutputType(); BandData rootBand = loadBandData(report, handledParams); generateReport(report, reportTemplate, finalOutputType, outputStream, handledParams, rootBand); logReport("Finished report [%s] with parameters [%s]", report, handledParams); String outputName = resolveOutputFileName(report, reportTemplate, outputType, rootBand); return createReportOutputDocument(report, finalOutputType, outputName, rootBand); } catch (ReportingInterruptedException e) { logReport("Report is canceled by user request. Report [%s] with parameters [%s].", report, params); throw e; } catch (ReportingException e) { logReport("An error occurred while running report [%s] with parameters [%s].", report, params); logException(e); //validation exception is usually shown to clients, so probably there is no need to add report name there (to keep the original message) if (!(e instanceof ValidationException)) { e.setReportDetails(format(" Report name [%s]", report.getName())); } throw e; } }
protected void writeTemplates(Report report, Element root) { Map<String, ReportTemplate> reportTemplates = report.getReportTemplates(); Element reportTemplatesElement = root.addElement("templates"); for (ReportTemplate reportTemplate : reportTemplates.values()) { Element reportTemplateElement = reportTemplatesElement.addElement("template"); reportTemplateElement.addAttribute("code", reportTemplate.getCode()); reportTemplateElement.addAttribute("documentName", reportTemplate.getDocumentName()); reportTemplateElement.addAttribute("documentPath", reportTemplate.getDocumentPath()); reportTemplateElement.addAttribute("outputType", reportTemplate.getOutputType().getId()); reportTemplateElement.addAttribute("outputNamePattern", reportTemplate.getOutputNamePattern()); } }
protected void writeTemplates(Report report, Element root) { Map<String, ReportTemplate> reportTemplates = report.getReportTemplates(); Element reportTemplatesElement = root.addElement("templates"); for (ReportTemplate reportTemplate : reportTemplates.values()) { Element reportTemplateElement = reportTemplatesElement.addElement("template"); reportTemplateElement.addAttribute("code", reportTemplate.getCode()); reportTemplateElement.addAttribute("documentName", reportTemplate.getDocumentName()); reportTemplateElement.addAttribute("documentPath", reportTemplate.getDocumentPath()); reportTemplateElement.addAttribute("outputType", reportTemplate.getOutputType().getId()); reportTemplateElement.addAttribute("outputNamePattern", reportTemplate.getOutputNamePattern()); } }