use of org.hisp.dhis.common.DimensionalObject.CATEGORYOPTIONCOMBO_DIM_ID in project dhis2-core by dhis2.
the class MetadataHandler method addMetaData.
/**
* Adds meta data values to the given grid based on the given data query
* parameters.
*
* @param params the {@link DataQueryParams}.
* @param grid the grid.
*/
void addMetaData(DataQueryParams params, Grid grid) {
if (!params.isSkipMeta()) {
Map<String, Object> metaData = new HashMap<>();
Map<String, Object> internalMetaData = new HashMap<>();
// -----------------------------------------------------------------
// Items / names element
// -----------------------------------------------------------------
Map<String, String> cocNameMap = getCocNameMap(params);
metaData.put(ITEMS.getKey(), getDimensionMetadataItemMap(params));
// -----------------------------------------------------------------
// Item order elements
// -----------------------------------------------------------------
Map<String, Object> dimensionItems = new HashMap<>();
Calendar calendar = PeriodType.getCalendar();
List<String> periodUids = calendar.isIso8601() ? getUids(params.getDimensionOrFilterItems(PERIOD_DIM_ID)) : getLocalPeriodIdentifiers(params.getDimensionOrFilterItems(PERIOD_DIM_ID), calendar);
dimensionItems.put(PERIOD_DIM_ID, periodUids);
dimensionItems.put(CATEGORYOPTIONCOMBO_DIM_ID, Sets.newHashSet(cocNameMap.keySet()));
for (DimensionalObject dim : params.getDimensionsAndFilters()) {
if (!dimensionItems.containsKey(dim.getDimension())) {
dimensionItems.put(dim.getDimension(), getDimensionalItemIds(dim.getItems()));
}
}
metaData.put(DIMENSIONS.getKey(), dimensionItems);
// -----------------------------------------------------------------
// Organisation unit hierarchy
// -----------------------------------------------------------------
List<OrganisationUnit> organisationUnits = asTypedList(params.getDimensionOrFilterItems(ORGUNIT_DIM_ID));
List<OrganisationUnit> roots = dataQueryService.getUserOrgUnits(params, null);
if (params.isHierarchyMeta()) {
metaData.put(ORG_UNIT_HIERARCHY.getKey(), getParentGraphMap(organisationUnits, roots));
}
if (params.isShowHierarchy()) {
Map<Object, List<?>> ancestorMap = organisationUnits.stream().collect(toMap(OrganisationUnit::getUid, ou -> ou.getAncestorNames(roots, true)));
internalMetaData.put(ORG_UNIT_ANCESTORS.getKey(), ancestorMap);
metaData.put(ORG_UNIT_NAME_HIERARCHY.getKey(), getParentNameGraphMap(organisationUnits, roots, true));
}
grid.setMetaData(copyOf(metaData));
grid.setInternalMetaData(copyOf(internalMetaData));
}
}
Aggregations