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);
}
}
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);
}
Aggregations