Search in sources :

Example 6 with ReportTemplate

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

the class JmixTableFormatter method transformData.

protected JmixTableData transformData(BandData rootBand) {
    TemplateTableDescription templateTableDescription = ((ReportTemplate) reportTemplate).getTemplateTableDescription();
    Map<String, List<KeyValueEntity>> transformedData = new LinkedHashMap<>();
    Map<String, Set<JmixTableData.ColumnInfo>> headerMap = new HashMap<>();
    Map<String, List<BandData>> childrenBands = rootBand.getChildrenBands();
    if (templateTableDescription.getTemplateTableBands().size() > 0) {
        return getTableData(templateTableDescription, transformedData, headerMap, childrenBands);
    } else {
        return getTableData(transformedData, headerMap, childrenBands);
    }
}
Also used : TemplateTableDescription(io.jmix.reports.entity.table.TemplateTableDescription) ReportTemplate(io.jmix.reports.entity.ReportTemplate) JmixTableData(io.jmix.reports.entity.JmixTableData)

Example 7 with ReportTemplate

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

the class ChartWidgetEdit method onReportComboBoxValueChange.

@Subscribe("reportComboBox")
public void onReportComboBoxValueChange(HasValue.ValueChangeEvent<Report> event) {
    Report report = event.getValue();
    if (report != null) {
        List<ReportTemplate> chartTemplates = getChartsTemplates(report);
        templateComboBox.setOptionsList(chartTemplates);
        reportId = report.getId();
        if (ReportOutputType.CHART == report.getDefaultTemplate().getReportOutputType()) {
            templateComboBox.setValue(report.getDefaultTemplate());
            templateId = report.getDefaultTemplate().getId();
        }
    }
}
Also used : Report(io.jmix.reports.entity.Report) ReportTemplate(io.jmix.reports.entity.ReportTemplate) Subscribe(io.jmix.ui.screen.Subscribe)

Example 8 with ReportTemplate

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

the class TemplateEditor method onAfterInit.

@Subscribe
protected void onAfterInit(AfterInitEvent event) {
    templateDc.addItemPropertyChangeListener(e -> {
        ReportTemplate reportTemplate = getEditedEntity();
        switch(e.getProperty()) {
            case REPORT_OUTPUT_TYPE:
                {
                    ReportOutputType prevOutputType = (ReportOutputType) e.getPrevValue();
                    ReportOutputType newOutputType = (ReportOutputType) e.getValue();
                    setupVisibility(reportTemplate.getCustom(), newOutputType);
                    if (hasHtmlCsvTemplateOutput(prevOutputType) && !hasTemplateOutput(newOutputType)) {
                        dialogs.createMessageDialog().withCaption(messages.getMessage(getClass(), "templateEditor.warning")).withMessage(messages.getMessage(getClass(), "templateEditor.clearTemplateMessage")).show();
                    }
                    break;
                }
            case CUSTOM:
                {
                    setupVisibility(Boolean.TRUE.equals(e.getValue()), reportTemplate.getReportOutputType());
                    break;
                }
            case CUSTOM_DEFINE_BY:
                {
                    boolean isGroovyScript = hasScriptCustomDefinedBy(reportTemplate.getCustomDefinedBy());
                    fullScreenLinkButton.setVisible(isGroovyScript);
                    customDefinitionHelpLinkButton.setVisible(isGroovyScript);
                    break;
                }
        }
    });
    initOutputTypeList();
}
Also used : ReportTemplate(io.jmix.reports.entity.ReportTemplate) ReportOutputType(io.jmix.reports.entity.ReportOutputType)

Example 9 with ReportTemplate

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

the class TemplateEditor method onBeforeCommit.

@Subscribe
protected void onBeforeCommit(BeforeCommitChangesEvent event) {
    if (!validateTemplateFile() || !validateInputOutputFormats()) {
        event.preventCommit();
    }
    ReportTemplate reportTemplate = getEditedEntity();
    for (DescriptionEditFragment fragment : getDescriptionEditFragments()) {
        if (fragment.isApplicable(reportTemplate.getReportOutputType())) {
            if (!fragment.applyChanges()) {
                event.preventCommit();
            }
        }
    }
    if (!Boolean.TRUE.equals(reportTemplate.getCustom())) {
        reportTemplate.setCustomDefinition("");
    }
    String extension = FilenameUtils.getExtension(templateUploadField.getFileName());
    if (extension != null) {
        ReportOutputType outputType = ReportOutputType.getTypeFromExtension(extension.toUpperCase());
        if (hasHtmlCsvTemplateOutput(outputType)) {
            byte[] bytes = templateFileEditor.getValue() == null ? new byte[0] : templateFileEditor.getValue().getBytes(StandardCharsets.UTF_8);
            reportTemplate.setContent(bytes);
        }
    }
}
Also used : ReportTemplate(io.jmix.reports.entity.ReportTemplate) ReportOutputType(io.jmix.reports.entity.ReportOutputType)

Example 10 with ReportTemplate

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

the class TemplateEditor method initUploadField.

protected void initUploadField() {
    ReportTemplate reportTemplate = getEditedEntity();
    byte[] templateFile = reportTemplate.getContent();
    if (templateFile != null && !hasChartTemplateOutput(reportTemplate.getReportOutputType())) {
        temporaryStorage.saveFile(templateFile);
        templateUploadField.setValue(templateFile);
        templateUploadField.setFileName(reportTemplate.getName());
    }
    templateUploadField.setEditable(isUpdatePermitted(reportTemplate));
}
Also used : ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Aggregations

ReportTemplate (io.jmix.reports.entity.ReportTemplate)26 Report (io.jmix.reports.entity.Report)14 ReportOutputType (io.jmix.reports.entity.ReportOutputType)6 ReportOutputDocument (com.haulmont.yarg.reporting.ReportOutputDocument)4 Subscribe (io.jmix.ui.screen.Subscribe)3 List (java.util.List)3 DataManager (io.jmix.core.DataManager)2 PivotTableData (io.jmix.reports.entity.PivotTableData)2 ReportRunContext (io.jmix.reports.runner.ReportRunContext)2 HashMap (java.util.HashMap)2 Collectors (java.util.stream.Collectors)2 ZipArchiveEntry (org.apache.commons.compress.archivers.zip.ZipArchiveEntry)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 OpenOfficeException (com.haulmont.yarg.exception.OpenOfficeException)1 ReportingInterruptedException (com.haulmont.yarg.exception.ReportingInterruptedException)1 NoFreePortsException (com.haulmont.yarg.formatters.impl.doc.connector.NoFreePortsException)1 ReportingAPI (com.haulmont.yarg.reporting.ReportingAPI)1 RunParams (com.haulmont.yarg.reporting.RunParams)1 EntityStates (io.jmix.core.EntityStates)1 Id (io.jmix.core.Id)1