Search in sources :

Example 1 with ReportWithParamField

use of io.jmix.emailtemplatesui.dto.ReportWithParamField in project jmix by jmix-framework.

the class EmailTemplateParametersFragment method collectParameters.

public List<ReportWithParams> collectParameters() {
    List<ReportWithParams> reportDataList = new ArrayList<>();
    for (ReportWithParamField fieldValue : parameterComponents) {
        ReportWithParams reportData = new ReportWithParams(fieldValue.getReport());
        for (String paramName : fieldValue.getFields().keySet()) {
            Field parameterField = fieldValue.getFields().get(paramName);
            Object value = parameterField.getValue();
            reportData.put(paramName, value);
        }
        reportDataList.add(reportData);
    }
    return reportDataList;
}
Also used : ReportWithParamField(io.jmix.emailtemplatesui.dto.ReportWithParamField) ReportWithParams(io.jmix.emailtemplates.dto.ReportWithParams) ReportWithParamField(io.jmix.emailtemplatesui.dto.ReportWithParamField)

Example 2 with ReportWithParamField

use of io.jmix.emailtemplatesui.dto.ReportWithParamField in project jmix by jmix-framework.

the class EmailTemplateParametersFragment method createComponents.

public EmailTemplateParametersFragment createComponents() {
    clearComponents();
    try {
        List<ReportWithParams> parameters = getTemplateDefaultValues();
        List<Report> reports = parameters.stream().map(ReportWithParams::getReport).collect(Collectors.toList());
        parametersGrid.setRows(getRowCountForParameters(reports));
        int currentGridRow = 0;
        for (ReportWithParams reportData : parameters) {
            Report report = reportData.getReport();
            if (report != null && !report.getIsTmp()) {
                report = dataManager.load(Report.class).id(report.getId()).fetchPlan("report.edit").one();
            }
            if (report != null) {
                if (CollectionUtils.isNotEmpty(report.getInputParameters())) {
                    if (BooleanUtils.isNotTrue(hideReportCaption)) {
                        createReportNameLabel(report, currentGridRow);
                        currentGridRow++;
                    }
                    Map<String, Field> componentsMap = new HashMap<>();
                    for (ReportInputParameter parameter : report.getInputParameters()) {
                        if (BooleanUtils.isNotTrue(parameter.getHidden())) {
                            componentsMap.put(parameter.getAlias(), createComponent(parameter, reportData.getParams(), currentGridRow));
                            currentGridRow++;
                        }
                    }
                    parameterComponents.add(new ReportWithParamField(report, componentsMap));
                }
            }
        }
    } catch (ReportParameterTypeChangedException e) {
        notifications.create(Notifications.NotificationType.ERROR).withCaption(e.getMessage()).show();
    }
    return this;
}
Also used : ReportWithParamField(io.jmix.emailtemplatesui.dto.ReportWithParamField) ReportWithParams(io.jmix.emailtemplates.dto.ReportWithParams) TemplateReport(io.jmix.emailtemplates.entity.TemplateReport) Report(io.jmix.reports.entity.Report) ReportInputParameter(io.jmix.reports.entity.ReportInputParameter) ReportWithParamField(io.jmix.emailtemplatesui.dto.ReportWithParamField) ReportParameterTypeChangedException(io.jmix.emailtemplates.exception.ReportParameterTypeChangedException)

Aggregations

ReportWithParams (io.jmix.emailtemplates.dto.ReportWithParams)2 ReportWithParamField (io.jmix.emailtemplatesui.dto.ReportWithParamField)2 TemplateReport (io.jmix.emailtemplates.entity.TemplateReport)1 ReportParameterTypeChangedException (io.jmix.emailtemplates.exception.ReportParameterTypeChangedException)1 Report (io.jmix.reports.entity.Report)1 ReportInputParameter (io.jmix.reports.entity.ReportInputParameter)1