@Override public InputStream getDocumentContent() { if (getContent() == null) { return null; } return new ByteArrayInputStream(getContent()); }
public PivotTableDescription getPivotTableDescription() { if (getContent() == null) return null; return PivotTableDescription.fromJsonString(new String(getContent(), StandardCharsets.UTF_8)); }
@Nullable public AbstractChartDescription getChartDescription() { if (getContent() == null) { return null; } return AbstractChartDescription.fromJsonString(new String(getContent(), StandardCharsets.UTF_8)); }
protected boolean validateTemplateFile() { ReportTemplate template = getItem(); if (!Boolean.TRUE.equals(template.getCustom()) && hasTemplateOutput(template.getReportOutputType()) && template.getContent() == null) { StringBuilder notification = new StringBuilder(getMessage("template.uploadTemplate")); if (StringUtils.isEmpty(template.getCode())) { notification.append("\n").append(getMessage("template.codeMsg")); } if (template.getOutputType() == null) { notification.append("\n").append(getMessage("template.outputTypeMsg")); } showNotification(getMessage("validationFail.caption"), notification.toString(), NotificationType.TRAY); return false; } return true; } }
protected void initTemplateEditor(ReportTemplate reportTemplate) { templateFileEditor.setMode(SourceCodeEditor.Mode.HTML); String extension = FilenameUtils.getExtension(templateUploadField.getFileName()); if (extension == null) { visibleTemplateEditor(null); return; } ReportOutputType outputType = ReportOutputType.getTypeFromExtension(extension.toUpperCase()); visibleTemplateEditor(outputType); if (hasHtmlCsvTemplateOutput(outputType)) { String templateContent = new String(reportTemplate.getContent(), StandardCharsets.UTF_8); templateFileEditor.setValue(templateContent); } templateFileEditor.setEditable(security.isEntityOpPermitted(reportTemplate.getMetaClass(), EntityOp.UPDATE)); }
ReportTemplate template = report.getTemplates().get(i); if (template.getContent() != null) { byte[] fileBytes = template.getContent(); ArchiveEntry zipEntryTemplate = newStoredEntry( "templates/" + i + "/" + template.getName(), fileBytes);
protected void showChart() { byte[] content = wizard.buildReport(true).getDefaultTemplate().getContent(); String chartDescriptionJson = new String(content, StandardCharsets.UTF_8); AbstractChartDescription chartDescription = AbstractChartDescription.fromJsonString(chartDescriptionJson); RandomChartDataGenerator randomChartDataGenerator = new RandomChartDataGenerator(); List<Map<String, Object>> randomChartData = randomChartDataGenerator.generateRandomChartData(chartDescription); ChartToJsonConverter chartToJsonConverter = new ChartToJsonConverter(); String chartJson = null; if (chartDescription instanceof PieChartDescription) { chartJson = chartToJsonConverter.convertPieChart((PieChartDescription) chartDescription, randomChartData); } else if (chartDescription instanceof SerialChartDescription) { chartJson = chartToJsonConverter.convertSerialChart((SerialChartDescription) chartDescription, randomChartData); } wizard.openFrame(wizard.chartPreviewBox, ShowChartController.JSON_CHART_SCREEN_ID, ParamsMap.of(ShowChartController.CHART_JSON_PARAMETER, chartJson)); } }
byte[] templateFile = reportTemplate.getContent(); if (templateFile != null) { templateUploadField.setContentProvider(() -> new ByteArrayInputStream(templateFile));