use of org.hisp.dhis.common.CombinationGenerator in project dhis2-core by dhis2.
the class DefaultAnalyticsService method getAggregatedDataValuesTableLayout.
/**
* Returns a Grid with aggregated data in table layout.
*
* @param params the {@link DataQueryParams}.
* @param columns the column dimensions.
* @param rows the row dimensions.
* @return a Grid with aggregated data in table layout.
*/
private Grid getAggregatedDataValuesTableLayout(DataQueryParams params, List<String> columns, List<String> rows) {
params.setOutputIdScheme(null);
Grid grid = getAggregatedDataValues(params);
ListUtils.removeEmptys(columns);
ListUtils.removeEmptys(rows);
queryPlanner.validateTableLayout(params, columns, rows);
ReportTable reportTable = new ReportTable();
List<DimensionalItemObject[]> tableColumns = new ArrayList<>();
List<DimensionalItemObject[]> tableRows = new ArrayList<>();
if (columns != null) {
for (String dimension : columns) {
reportTable.getColumnDimensions().add(dimension);
tableColumns.add(params.getDimensionItemArrayExplodeCoc(dimension));
}
}
if (rows != null) {
for (String dimension : rows) {
reportTable.getRowDimensions().add(dimension);
tableRows.add(params.getDimensionItemArrayExplodeCoc(dimension));
}
}
reportTable.setGridTitle(IdentifiableObjectUtils.join(params.getFilterItems())).setGridColumns(new CombinationGenerator<>(tableColumns.toArray(IRT2D)).getCombinations()).setGridRows(new CombinationGenerator<>(tableRows.toArray(IRT2D)).getCombinations());
addListIfEmpty(reportTable.getGridColumns());
addListIfEmpty(reportTable.getGridRows());
reportTable.setHideEmptyRows(params.isHideEmptyRows());
reportTable.setHideEmptyColumns(params.isHideEmptyColumns());
reportTable.setShowHierarchy(params.isShowHierarchy());
Map<String, Object> valueMap = AnalyticsUtils.getAggregatedDataValueMapping(grid);
return reportTable.getGrid(new ListGrid(grid.getMetaData(), grid.getInternalMetaData()), valueMap, params.getDisplayProperty(), false);
}
Aggregations