Search in sources :

Example 16 with ReportTemplate

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

the class ReportBrowser method copyReport.

protected Report copyReport(Report source) {
    source = dataManager.load(Id.of(source)).fetchPlan("report.edit").one();
    Report copiedReport = metadataTools.deepCopy(source);
    copiedReport.setId(UuidProvider.createUuid());
    copiedReport.setName(reportsUtils.generateReportName(source.getName()));
    copiedReport.setCode(null);
    for (ReportTemplate copiedTemplate : copiedReport.getTemplates()) {
        copiedTemplate.setId(UuidProvider.createUuid());
    }
    reports.save(copiedReport);
    return copiedReport;
}
Also used : Report(io.jmix.reports.entity.Report) ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Example 17 with ReportTemplate

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

the class ReportEditTemplatesFragment method onTemplatesTableDefault.

@Subscribe("templatesTable.default")
protected void onTemplatesTableDefault(Action.ActionPerformedEvent event) {
    ReportTemplate template = templatesTable.getSingleSelected();
    if (template != null) {
        reportDc.getItem().setDefaultTemplate(template);
    }
    event.getSource().refreshState();
    templatesTable.focus();
}
Also used : ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Example 18 with ReportTemplate

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

the class ReportEditTemplatesFragment method onTemplatesTableCopy.

@Subscribe("templatesTable.copy")
protected void onTemplatesTableCopy(Action.ActionPerformedEvent event) {
    ReportTemplate template = templatesTable.getSingleSelected();
    if (template != null) {
        ReportTemplate copy = metadataTools.copy(template);
        copy.setId(UuidProvider.createUuid());
        copy.setVersion(null);
        String copyNamingPattern = messages.getMessage(getClass(), "template.copyNamingPattern");
        String copyCode = String.format(copyNamingPattern, StringUtils.isEmpty(copy.getCode()) ? StringUtils.EMPTY : copy.getCode());
        List<String> codes = templatesDc.getItems().stream().map(ReportTemplate::getCode).filter(o -> !StringUtils.isEmpty(o)).collect(Collectors.toList());
        if (codes.contains(copyCode)) {
            String code = copyCode;
            int i = 0;
            while ((codes.contains(code))) {
                i += 1;
                code = copyCode + " " + i;
            }
            copyCode = code;
        }
        copy.setCode(copyCode);
        templatesDc.getMutableItems().add(copy);
    }
}
Also used : UuidProvider(io.jmix.core.UuidProvider) ReportTemplate(io.jmix.reports.entity.ReportTemplate) PolicyStore(io.jmix.security.constraint.PolicyStore) Autowired(org.springframework.beans.factory.annotation.Autowired) Metadata(io.jmix.core.Metadata) CollectionPropertyContainer(io.jmix.ui.model.CollectionPropertyContainer) SecureOperations(io.jmix.security.constraint.SecureOperations) StringUtils(org.apache.commons.lang3.StringUtils) Collectors(java.util.stream.Collectors) Table(io.jmix.ui.component.Table) Messages(io.jmix.core.Messages) Objects(java.util.Objects) List(java.util.List) InstanceContainer(io.jmix.ui.model.InstanceContainer) io.jmix.ui.screen(io.jmix.ui.screen) RemoveOperation(io.jmix.ui.RemoveOperation) Action(io.jmix.ui.action.Action) MetadataTools(io.jmix.core.MetadataTools) Report(io.jmix.reports.entity.Report) ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Example 19 with ReportTemplate

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

the class ShowPivotTableScreen method printReport.

@Subscribe("printReportBtn")
protected void printReport(Button.ClickEvent event) {
    if (inputParametersFragment != null && inputParametersFragment.getReport() != null) {
        ValidationErrors validationErrors = screenValidation.validateUiComponents(getWindow());
        if (validationErrors.isEmpty()) {
            Map<String, Object> parameters = inputParametersFragment.collectParameters();
            Report report = inputParametersFragment.getReport();
            String resultTemplateCode = templateCode;
            if (templateCode == null) {
                if (reportTemplateComboBox.getValue() != null) {
                    resultTemplateCode = reportTemplateComboBox.getValue().getCode();
                } else {
                    resultTemplateCode = report.getTemplates().stream().filter(template -> template.getReportOutputType() == ReportOutputType.PIVOT_TABLE).findFirst().map(ReportTemplate::getCode).orElse(null);
                }
            }
            ReportOutputDocument document = reportRunner.byReportEntity(report).withParams(parameters).withTemplateCode(resultTemplateCode).run();
            PivotTableData result = (PivotTableData) serialization.deserialize(document.getContent());
            openPivotTable(result.getPivotTableJson(), result.getValues());
        } else {
            screenValidation.showValidationErrors(this, validationErrors);
        }
    }
}
Also used : ReportOutputDocument(com.haulmont.yarg.reporting.ReportOutputDocument) Report(io.jmix.reports.entity.Report) PivotTableData(io.jmix.reports.entity.PivotTableData) ReportTemplate(io.jmix.reports.entity.ReportTemplate)

Example 20 with ReportTemplate

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

the class InputParametersFragment method updateOutputTypes.

protected void updateOutputTypes() {
    if (!containsAlterableTemplate(report)) {
        setOutputTypeVisible(false);
        return;
    }
    ReportTemplate template;
    if (report.getTemplates() != null && report.getTemplates().size() > 1) {
        template = templateComboBox.getValue();
    } else {
        template = report.getDefaultTemplate();
    }
    if (template != null && supportAlterableForTemplate(template)) {
        List<ReportOutputType> outputTypes = ReportPrintHelper.getInputOutputTypesMapping().get(template.getExt());
        if (outputTypes != null && !outputTypes.isEmpty()) {
            outputTypeComboBox.setOptionsList(outputTypes);
            if (outputTypeComboBox.getValue() == null) {
                outputTypeComboBox.setValue(template.getReportOutputType());
            }
            setOutputTypeVisible(true);
        } else {
            outputTypeComboBox.setValue(null);
            setOutputTypeVisible(false);
        }
    } else {
        outputTypeComboBox.setValue(null);
        setOutputTypeVisible(false);
    }
}
Also used : ReportTemplate(io.jmix.reports.entity.ReportTemplate) ReportOutputType(io.jmix.reports.entity.ReportOutputType)

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