Search in sources :

Example 16 with Report

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

the class ReportBrowser method reloadReport.

private Report reloadReport(Report report, FetchPlan fetchPlan) {
    MetaClass metaClass = metadata.getClass(Report.class);
    LoadContext<Report> lc = new LoadContext<>(metaClass);
    lc.setId(report.getId());
    lc.setFetchPlan(fetchPlan);
    report = dataManager.load(lc);
    return report;
}
Also used : MetaClass(io.jmix.core.metamodel.model.MetaClass) Report(io.jmix.reports.entity.Report)

Example 17 with Report

use of io.jmix.reports.entity.Report 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 18 with Report

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

the class ReportBrowser method onTableCopy.

@Subscribe("reportsTable.copy")
protected void onTableCopy(Action.ActionPerformedEvent event) {
    Report report = reportsTable.getSingleSelected();
    if (report != null) {
        copyReport(report);
        reportDl.load();
    } else {
        notifications.create(Notifications.NotificationType.HUMANIZED).withCaption(messages.getMessage(getClass(), "notification.selectReport")).show();
    }
}
Also used : Report(io.jmix.reports.entity.Report)

Example 19 with Report

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

the class ReportBrowser method onPopupCreateBtnWizard.

@Subscribe("popupCreateBtn.wizard")
protected void onPopupCreateBtnWizard(Action.ActionPerformedEvent event) {
    ReportWizardCreator wizard = screens.create(ReportWizardCreator.class, OpenMode.DIALOG);
    wizard.addAfterCloseListener(e -> {
        if (e.closedWith(StandardOutcome.COMMIT)) {
            Report item = wizard.getItem().getGeneratedReport();
            reportDc.getMutableItems().add(item);
            reportsTable.setSelected(item);
            ReportEditor reportEditor = (ReportEditor) screenBuilders.editor(reportsTable).withOpenMode(OpenMode.THIS_TAB).build();
            reportEditor.show().addAfterCloseListener(closeEvent -> {
                if (closeEvent.closedWith(StandardOutcome.COMMIT)) {
                    reportDc.replaceItem(reportEditor.getEditedEntity());
                }
                reportsTable.expandPath(reportDc.getItem(reportEditor.getEditedEntity()));
            });
        }
    });
    wizard.show();
}
Also used : Report(io.jmix.reports.entity.Report) ReportEditor(io.jmix.reportsui.screen.report.edit.ReportEditor) ReportWizardCreator(io.jmix.reportsui.screen.report.wizard.ReportWizardCreator)

Example 20 with Report

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

the class ShowReportTableScreen method printReport.

@Subscribe("printReportBtn")
protected void printReport(Button.ClickEvent button) {
    if (inputParametersFrame != null && inputParametersFrame.getReport() != null) {
        ValidationErrors validationErrors = screenValidation.validateUiComponents(getWindow());
        if (validationErrors.isEmpty()) {
            Map<String, Object> parameters = inputParametersFrame.collectParameters();
            Report report = inputParametersFrame.getReport();
            if (templateCode == null || templateCode.isEmpty())
                templateCode = findTableCode(report);
            ReportOutputDocument reportResult = reportRunner.byReportEntity(report).withParams(parameters).withTemplateCode(templateCode).run();
            JmixTableData dto = (JmixTableData) serialization.deserialize(reportResult.getContent());
            drawTables(dto);
        } else {
            screenValidation.showValidationErrors(this, validationErrors);
        }
    }
}
Also used : ReportOutputDocument(com.haulmont.yarg.reporting.ReportOutputDocument) Report(io.jmix.reports.entity.Report) JmixTableData(io.jmix.reports.entity.JmixTableData)

Aggregations

Report (io.jmix.reports.entity.Report)45 ReportTemplate (io.jmix.reports.entity.ReportTemplate)13 Subscribe (io.jmix.ui.screen.Subscribe)8 ReportOutputDocument (com.haulmont.yarg.reporting.ReportOutputDocument)7 TemplateReport (io.jmix.emailtemplates.entity.TemplateReport)7 MetaClass (io.jmix.core.metamodel.model.MetaClass)6 FluentUiReportRunner (io.jmix.reportsui.runner.FluentUiReportRunner)5 ReportWithParams (io.jmix.emailtemplates.dto.ReportWithParams)4 ReportInputParameter (io.jmix.reports.entity.ReportInputParameter)4 UiReportRunContext (io.jmix.reportsui.runner.UiReportRunContext)4 List (java.util.List)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 DataManager (io.jmix.core.DataManager)3 ParameterPrototype (io.jmix.reports.app.ParameterPrototype)3 ReportingException (io.jmix.reports.exception.ReportingException)3 ReportRunContext (io.jmix.reports.runner.ReportRunContext)3 LiteratureType (reports.ex2.entity.LiteratureType)3 Id (io.jmix.core.Id)2 CurrentUserSubstitution (io.jmix.core.usersubstitution.CurrentUserSubstitution)2 ParameterValue (io.jmix.emailtemplates.entity.ParameterValue)2