Search in sources :

Example 1 with FluentUiReportRunner

use of io.jmix.reportsui.runner.FluentUiReportRunner in project jmix by jmix-framework.

the class QueryStepFragment method onRunBtnClick.

@Subscribe("runBtn")
public void onRunBtnClick(Button.ClickEvent event) {
    ReportWizardCreator reportWizardCreator = (ReportWizardCreator) getFragment().getFrameOwner().getHostController();
    lastGeneratedTmpReport = reportWizardCreator.buildReport(true);
    if (lastGeneratedTmpReport != null) {
        FluentUiReportRunner fluentRunner = uiReportRunner.byReportEntity(lastGeneratedTmpReport).withParametersDialogShowMode(ParametersDialogShowMode.IF_REQUIRED);
        if (reportsClientProperties.getUseBackgroundReportProcessing()) {
            fluentRunner.inBackground(getFragment().getFrameOwner());
        }
        fluentRunner.runAndShow();
    }
}
Also used : FluentUiReportRunner(io.jmix.reportsui.runner.FluentUiReportRunner) ReportWizardCreator(io.jmix.reportsui.screen.report.wizard.ReportWizardCreator)

Example 2 with FluentUiReportRunner

use of io.jmix.reportsui.runner.FluentUiReportRunner in project jmix by jmix-framework.

the class InputParametersDialog method onPrintReportButtonClick.

@Subscribe("printReportButton")
public void onPrintReportButtonClick(Button.ClickEvent event) {
    if (inputParametersFragment.getReport() != null) {
        ValidationErrors validationErrors = screenValidation.validateUiComponents(getWindow());
        crossValidateParameters(validationErrors);
        if (validationErrors.isEmpty()) {
            ReportTemplate template = inputParametersFragment.getReportTemplate();
            if (template != null) {
                templateCode = template.getCode();
            }
            Report report = inputParametersFragment.getReport();
            Map<String, Object> parameters = inputParametersFragment.collectParameters();
            FluentUiReportRunner fluentRunner = uiReportRunner.byReportEntity(report).withParams(parameters).withTemplateCode(templateCode).withOutputNamePattern(outputFileName).withOutputType(inputParametersFragment.getOutputType()).withParametersDialogShowMode(ParametersDialogShowMode.NO);
            if (inBackground) {
                fluentRunner.inBackground(this);
            }
            if (bulkPrint) {
                fluentRunner.runMultipleReports(inputParameter.getAlias(), selectedEntities);
            } else {
                fluentRunner.runAndShow();
            }
        } else {
            screenValidation.showValidationErrors(this, validationErrors);
        }
    }
}
Also used : FluentUiReportRunner(io.jmix.reportsui.runner.FluentUiReportRunner) ValidationErrors(io.jmix.ui.component.ValidationErrors) Report(io.jmix.reports.entity.Report) ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Example 3 with FluentUiReportRunner

use of io.jmix.reportsui.runner.FluentUiReportRunner in project jmix by jmix-framework.

the class ReportBrowser method onTableRunReport.

@Subscribe("reportsTable.runReport")
protected void onTableRunReport(Action.ActionPerformedEvent event) {
    Report report = reportsTable.getSingleSelected();
    report = reloadReport(report, fetchPlanRepository.findFetchPlan(metadata.getClass(Report.class), "report.edit"));
    if (CollectionUtils.isNotEmpty(report.getInputParameters()) || inputParametersRequiredByTemplates(report)) {
        InputParametersDialog inputParametersDialog = screens.create(InputParametersDialog.class, OpenMode.DIALOG, new MapScreenOptions(ParamsMap.of("report", report)));
        inputParametersDialog.setInBackground(reportsClientProperties.getUseBackgroundReportProcessing());
        inputParametersDialog.show().addAfterCloseListener(e -> {
            reportsTable.focus();
        });
    } else {
        FluentUiReportRunner fluentRunner = uiReportRunner.byReportEntity(report).withParams(Collections.emptyMap());
        if (reportsClientProperties.getUseBackgroundReportProcessing()) {
            fluentRunner.inBackground(ReportBrowser.this);
        }
        fluentRunner.runAndShow();
    }
}
Also used : FluentUiReportRunner(io.jmix.reportsui.runner.FluentUiReportRunner) Report(io.jmix.reports.entity.Report) InputParametersDialog(io.jmix.reportsui.screen.report.run.InputParametersDialog)

Example 4 with FluentUiReportRunner

use of io.jmix.reportsui.runner.FluentUiReportRunner in project jmix by jmix-framework.

the class AbstractPrintFormAction method runAndShow.

public void runAndShow(Report report, FrameOwner screen, ReportInputParameter reportInputParameter, Object parameterValue, @Nullable String outputFileName) {
    List<ReportInputParameter> params = report.getInputParameters();
    boolean reportHasMoreThanOneParameter = params != null && params.size() > 1;
    boolean inputParametersRequiredByTemplates = inputParametersRequiredByTemplates(report);
    Object resultingParamValue = convertParameterIfNecessary(reportInputParameter, parameterValue, reportHasMoreThanOneParameter || inputParametersRequiredByTemplates);
    boolean reportTypeIsSingleEntity = ParameterType.ENTITY == reportInputParameter.getType() && resultingParamValue instanceof Collection;
    boolean moreThanOneEntitySelected = resultingParamValue instanceof Collection && ((Collection) resultingParamValue).size() > 1;
    if (reportHasMoreThanOneParameter || inputParametersRequiredByTemplates) {
        boolean bulkPrint = reportTypeIsSingleEntity && moreThanOneEntitySelected;
        openReportParamsDialog(report, ParamsMap.of(reportInputParameter.getAlias(), resultingParamValue), outputFileName, reportInputParameter, bulkPrint);
    } else {
        FluentUiReportRunner fluentRunner = uiReportRunner.byReportEntity(report).withParametersDialogShowMode(ParametersDialogShowMode.NO).withOutputNamePattern(outputFileName);
        if (reportsClientProperties.getUseBackgroundReportProcessing()) {
            fluentRunner.inBackground(screen);
        }
        if (reportTypeIsSingleEntity) {
            Collection selectedEntities = (Collection) resultingParamValue;
            if (moreThanOneEntitySelected) {
                fluentRunner.runMultipleReports(reportInputParameter.getAlias(), selectedEntities);
            } else if (selectedEntities.size() == 1) {
                fluentRunner.addParam(reportInputParameter.getAlias(), selectedEntities.iterator().next()).runAndShow();
            }
        } else {
            fluentRunner.addParam(reportInputParameter.getAlias(), resultingParamValue).runAndShow();
        }
    }
}
Also used : FluentUiReportRunner(io.jmix.reportsui.runner.FluentUiReportRunner) ReportInputParameter(io.jmix.reports.entity.ReportInputParameter) Collection(java.util.Collection)

Example 5 with FluentUiReportRunner

use of io.jmix.reportsui.runner.FluentUiReportRunner in project jmix by jmix-framework.

the class ReportRun method onReportsTableRunReport.

@Subscribe("reportsTable.runReport")
protected void onReportsTableRunReport(Action.ActionPerformedEvent event) {
    Report report = reportsTable.getSingleSelected();
    if (report != null) {
        report = dataManager.load(Id.of(report)).fetchPlan("report.edit").one();
        FluentUiReportRunner fluentRunner = uiReportRunner.byReportEntity(report).withParametersDialogShowMode(ParametersDialogShowMode.IF_REQUIRED);
        if (reportsClientProperties.getUseBackgroundReportProcessing()) {
            fluentRunner.inBackground(ReportRun.this);
        }
        fluentRunner.runAndShow();
    }
}
Also used : FluentUiReportRunner(io.jmix.reportsui.runner.FluentUiReportRunner) Report(io.jmix.reports.entity.Report)

Aggregations

FluentUiReportRunner (io.jmix.reportsui.runner.FluentUiReportRunner)6 Report (io.jmix.reports.entity.Report)3 ReportWizardCreator (io.jmix.reportsui.screen.report.wizard.ReportWizardCreator)2 ReportInputParameter (io.jmix.reports.entity.ReportInputParameter)1 ReportTemplate (io.jmix.reports.entity.ReportTemplate)1 InputParametersDialog (io.jmix.reportsui.screen.report.run.InputParametersDialog)1 ValidationErrors (io.jmix.ui.component.ValidationErrors)1 Collection (java.util.Collection)1