Search in sources :

Example 1 with ShowPivotTableScreen

use of io.jmix.reportsui.screen.report.run.ShowPivotTableScreen in project jmix by jmix-framework.

the class UiReportRunnerImpl method showResult.

protected void showResult(ReportOutputDocument document, UiReportRunContext context) {
    String templateCode = getTemplateCode(context);
    Map<String, Object> params = context.getParams();
    ReportOutputType outputType = context.getOutputType();
    if (document.getReportOutputType().getId().equals(JmixReportOutputType.chart.getId())) {
        ShowChartScreen showChartScreen = (ShowChartScreen) screens.create("report_ShowChart.screen", OpenMode.DIALOG);
        showChartScreen.setChartJson(new String(document.getContent(), StandardCharsets.UTF_8));
        showChartScreen.setReport((Report) document.getReport());
        showChartScreen.setTemplateCode(templateCode);
        showChartScreen.setReportParameters(params);
        showChartScreen.show();
    } else if (document.getReportOutputType().getId().equals(JmixReportOutputType.pivot.getId())) {
        ShowPivotTableScreen showPivotTableScreen = (ShowPivotTableScreen) screens.create("report_ShowPivotTable.screen", OpenMode.DIALOG);
        showPivotTableScreen.setPivotTableData(document.getContent());
        showPivotTableScreen.setReport((Report) document.getReport());
        showPivotTableScreen.setTemplateCode(templateCode);
        showPivotTableScreen.setParams(params);
        showPivotTableScreen.show();
    } else if (document.getReportOutputType().getId().equals(JmixReportOutputType.table.getId())) {
        ShowReportTableScreen reportTable = (ShowReportTableScreen) screens.create("report_ShowReportTable.screen", OpenMode.DIALOG);
        reportTable.setTableData(document.getContent());
        reportTable.setReport((Report) document.getReport());
        reportTable.setTemplateCode(templateCode);
        reportTable.setReportParameters(params);
        reportTable.show();
    } else {
        byte[] byteArr = document.getContent();
        com.haulmont.yarg.structure.ReportOutputType finalOutputType = (outputType != null) ? outputType.getOutputType() : document.getReportOutputType();
        DownloadFormat exportFormat = DownloadFormat.getByExtension(finalOutputType.getId());
        String outputFileName = context.getOutputNamePattern();
        String documentName = isNotBlank(outputFileName) ? outputFileName : document.getDocumentName();
        downloader.download(byteArr, documentName, exportFormat);
    }
}
Also used : ShowPivotTableScreen(io.jmix.reportsui.screen.report.run.ShowPivotTableScreen) DownloadFormat(io.jmix.ui.download.DownloadFormat) ShowReportTableScreen(io.jmix.reportsui.screen.report.run.ShowReportTableScreen) ShowChartScreen(io.jmix.reportsui.screen.report.run.ShowChartScreen)

Aggregations

ShowChartScreen (io.jmix.reportsui.screen.report.run.ShowChartScreen)1 ShowPivotTableScreen (io.jmix.reportsui.screen.report.run.ShowPivotTableScreen)1 ShowReportTableScreen (io.jmix.reportsui.screen.report.run.ShowReportTableScreen)1 DownloadFormat (io.jmix.ui.download.DownloadFormat)1