Search in sources :

Example 1 with PivotTableData

use of io.jmix.reports.entity.PivotTableData in project jmix by jmix-framework.

the class ShowPivotTableScreen method onBeforeShow.

@Subscribe
protected void onBeforeShow(BeforeShowEvent event) {
    if (report != null) {
        reportSelectorBox.setVisible(false);
        if (pivotTableData != null) {
            PivotTableData result = (PivotTableData) serialization.deserialize(pivotTableData);
            initFragments(result.getPivotTableJson(), result.getValues(), params);
        }
    } else {
        showStubText();
    }
    reportEntityComboBox.addValueChangeListener(e -> {
        report = e.getValue();
        initFragments(null, null, null);
        initReportTemplatesComboBox();
    });
}
Also used : PivotTableData(io.jmix.reports.entity.PivotTableData)

Example 2 with PivotTableData

use of io.jmix.reports.entity.PivotTableData in project jmix by jmix-framework.

the class ShowPivotTableScreen 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.PIVOT_TABLE).findFirst().map(ReportTemplate::getCode).orElse(null);
                }
            }
            ReportOutputDocument document = reportRunner.byReportEntity(report).withParams(parameters).withTemplateCode(resultTemplateCode).run();
            PivotTableData result = (PivotTableData) serialization.deserialize(document.getContent());
            openPivotTable(result.getPivotTableJson(), result.getValues());
        } else {
            screenValidation.showValidationErrors(this, validationErrors);
        }
    }
}
Also used : ReportOutputDocument(com.haulmont.yarg.reporting.ReportOutputDocument) Report(io.jmix.reports.entity.Report) PivotTableData(io.jmix.reports.entity.PivotTableData) ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Example 3 with PivotTableData

use of io.jmix.reports.entity.PivotTableData 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

PivotTableData (io.jmix.reports.entity.PivotTableData)3 ReportTemplate (io.jmix.reports.entity.ReportTemplate)2 ReportOutputDocument (com.haulmont.yarg.reporting.ReportOutputDocument)1 StandardSerialization (io.jmix.core.impl.StandardSerialization)1 Report (io.jmix.reports.entity.Report)1 PivotTableDescription (io.jmix.reports.entity.pivottable.PivotTableDescription)1