Search in sources :

Example 21 with ReportTemplate

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);
        }
    }
}
Also used : ReportOutputDocument(com.haulmont.yarg.reporting.ReportOutputDocument) Report(io.jmix.reports.entity.Report) ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Example 22 with ReportTemplate

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;
}
Also used : ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Example 23 with ReportTemplate

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();
}
Also used : ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Example 24 with ReportTemplate

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;
}
Also used : ReportTemplate(io.jmix.reports.entity.ReportTemplate) ReportOutputType(io.jmix.reports.entity.ReportOutputType)

Example 25 with ReportTemplate

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);
}
Also used : StandardSerialization(io.jmix.core.impl.StandardSerialization) PivotTableDescription(io.jmix.reports.entity.pivottable.PivotTableDescription) PivotTableData(io.jmix.reports.entity.PivotTableData) ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Aggregations

ReportTemplate (io.jmix.reports.entity.ReportTemplate)26 Report (io.jmix.reports.entity.Report)14 ReportOutputType (io.jmix.reports.entity.ReportOutputType)6 ReportOutputDocument (com.haulmont.yarg.reporting.ReportOutputDocument)4 Subscribe (io.jmix.ui.screen.Subscribe)3 List (java.util.List)3 DataManager (io.jmix.core.DataManager)2 PivotTableData (io.jmix.reports.entity.PivotTableData)2 ReportRunContext (io.jmix.reports.runner.ReportRunContext)2 HashMap (java.util.HashMap)2 Collectors (java.util.stream.Collectors)2 ZipArchiveEntry (org.apache.commons.compress.archivers.zip.ZipArchiveEntry)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 OpenOfficeException (com.haulmont.yarg.exception.OpenOfficeException)1 ReportingInterruptedException (com.haulmont.yarg.exception.ReportingInterruptedException)1 NoFreePortsException (com.haulmont.yarg.formatters.impl.doc.connector.NoFreePortsException)1 ReportingAPI (com.haulmont.yarg.reporting.ReportingAPI)1 RunParams (com.haulmont.yarg.reporting.RunParams)1 EntityStates (io.jmix.core.EntityStates)1 Id (io.jmix.core.Id)1