Search in sources :

Example 1 with TemplateTableDescription

use of io.jmix.reports.entity.table.TemplateTableDescription 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 2 with TemplateTableDescription

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

the class TableGenerator method generate.

@Override
public byte[] generate(ReportData reportData) {
    TemplateTableDescription templateTableDescription = dataManager.create(TemplateTableDescription.class);
    List<TemplateTableBand> bands = new LinkedList<>();
    for (int i = 0; i < reportData.getReportRegions().size(); i++) {
        ReportRegion reportRegion = reportData.getReportRegions().get(i);
        TemplateTableBand band = dataManager.create(TemplateTableBand.class);
        band.setPosition(i);
        band.setBandName(reportRegion.getNameForBand());
        List<TemplateTableColumn> columns = new LinkedList<>();
        for (int j = 0; j < reportRegion.getRegionProperties().size(); j++) {
            RegionProperty regionProperty = reportData.getReportRegions().get(i).getRegionProperties().get(j);
            String caption = regionProperty.getHierarchicalLocalizedNameExceptRoot().replace('.', ' ');
            TemplateTableColumn column = dataManager.create(TemplateTableColumn.class);
            column.setPosition(j);
            column.setKey(regionProperty.getHierarchicalNameExceptRoot());
            column.setCaption(caption);
            columns.add(column);
        }
        band.setColumns(columns);
        bands.add(band);
    }
    templateTableDescription.setTemplateTableBands(bands);
    return TemplateTableDescription.toJsonString(templateTableDescription).getBytes(StandardCharsets.UTF_8);
}
Also used : TemplateTableDescription(io.jmix.reports.entity.table.TemplateTableDescription) RegionProperty(io.jmix.reports.entity.wizard.RegionProperty) TemplateTableColumn(io.jmix.reports.entity.table.TemplateTableColumn) TemplateTableBand(io.jmix.reports.entity.table.TemplateTableBand) ReportRegion(io.jmix.reports.entity.wizard.ReportRegion) LinkedList(java.util.LinkedList)

Aggregations

TemplateTableDescription (io.jmix.reports.entity.table.TemplateTableDescription)2 JmixTableData (io.jmix.reports.entity.JmixTableData)1 ReportTemplate (io.jmix.reports.entity.ReportTemplate)1 TemplateTableBand (io.jmix.reports.entity.table.TemplateTableBand)1 TemplateTableColumn (io.jmix.reports.entity.table.TemplateTableColumn)1 RegionProperty (io.jmix.reports.entity.wizard.RegionProperty)1 ReportRegion (io.jmix.reports.entity.wizard.ReportRegion)1 LinkedList (java.util.LinkedList)1