use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class ShowChartScreen method printReport.
@Subscribe("printReportBtn")
protected void printReport(Button.ClickEvent event) {
if (inputParametersFragment != null && inputParametersFragment.getReport() != null) {
ValidationErrors validationErrors = screenValidation.validateUiComponents(getWindow());
if (validationErrors.isEmpty()) {
Map<String, Object> parameters = inputParametersFragment.collectParameters();
Report report = inputParametersFragment.getReport();
String resultTemplateCode = templateCode;
if (templateCode == null) {
if (reportTemplateComboBox.getValue() != null) {
resultTemplateCode = reportTemplateComboBox.getValue().getCode();
} else {
resultTemplateCode = report.getTemplates().stream().filter(template -> template.getReportOutputType() == ReportOutputType.CHART).findFirst().map(ReportTemplate::getCode).orElse(null);
}
}
ReportOutputDocument reportResult = reportRunner.byReportEntity(report).withParams(parameters).withTemplateCode(resultTemplateCode).run();
openChart(new String(reportResult.getContent(), StandardCharsets.UTF_8));
} else {
screenValidation.showValidationErrors(this, validationErrors);
}
}
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class TemplateEditor method validateTemplateFile.
protected boolean validateTemplateFile() {
ReportTemplate template = getEditedEntity();
if (!Boolean.TRUE.equals(template.getCustom()) && hasTemplateOutput(template.getReportOutputType()) && template.getContent() == null) {
StringBuilder notification = new StringBuilder(messages.getMessage(getClass(), "template.uploadTemplate"));
if (StringUtils.isEmpty(template.getCode())) {
notification.append("\n").append(messages.getMessage(getClass(), "template.codeMsg"));
}
if (template.getOutputType() == null) {
notification.append("\n").append(messages.getMessage(getClass(), "template.outputTypeMsg"));
}
notifications.create(Notifications.NotificationType.TRAY).withCaption(messages.getMessage("validationFail.caption")).withDescription(notification.toString()).show();
return false;
}
return true;
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class TemplateEditor method onTemplateUploadFieldFileUploadSucceed.
@Subscribe("templateUploadField")
protected void onTemplateUploadFieldFileUploadSucceed(SingleFileUploadField.FileUploadSucceedEvent event) {
String fileName = templateUploadField.getFileName();
ReportTemplate reportTemplate = getEditedEntity();
reportTemplate.setName(fileName);
byte[] data = templateUploadField.getValue();
reportTemplate.setContent(data);
initTemplateEditor(reportTemplate);
setupTemplateTypeVisibility(hasTemplateOutput(reportTemplate.getReportOutputType()));
updateOutputType();
notifications.create(Notifications.NotificationType.TRAY).withCaption(messages.getMessage(getClass(), "templateEditor.uploadSuccess")).show();
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class TemplateEditor method validateInputOutputFormats.
protected boolean validateInputOutputFormats() {
ReportTemplate reportTemplate = getEditedEntity();
String name = reportTemplate.getName();
if (!Boolean.TRUE.equals(reportTemplate.getCustom()) && hasTemplateOutput(reportTemplate.getReportOutputType()) && name != null) {
String inputType = name.contains(".") ? name.substring(name.lastIndexOf(".") + 1) : "";
ReportOutputType outputTypeValue = outputTypeField.getValue();
if (!ReportPrintHelper.getInputOutputTypesMapping().containsKey(inputType) || !ReportPrintHelper.getInputOutputTypesMapping().get(inputType).contains(outputTypeValue)) {
notifications.create(Notifications.NotificationType.TRAY).withCaption(messages.getMessage(getClass(), "inputOutputTypesError")).show();
return false;
}
}
return true;
}
use of io.jmix.reports.entity.ReportTemplate in project jmix by jmix-framework.
the class PivotTableFormatter method renderDocument.
@Override
public void renderDocument() {
PivotTableDescription pivotTableDescription = ((ReportTemplate) reportTemplate).getPivotTableDescription();
beanFactory.getBean(StandardSerialization.class).serialize(new PivotTableData(PivotTableDescription.toJsonString(pivotTableDescription), getEntries(pivotTableDescription)), outputStream);
}
Aggregations