use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class EventChart method series.
@Override
public List<DimensionalItemObject> series() {
String series = columnDimensions.get(0);
DimensionalObject object = getDimensionalObject(series, relativePeriodDate, relativeUser, true, organisationUnitsAtLevel, organisationUnitsInGroups, format);
DimensionalObjectUtils.setDimensionItemsForFilters(object, dataItemGrid, true);
return object != null ? object.getItems() : null;
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class EventChart method category.
@Override
public List<DimensionalItemObject> category() {
String category = rowDimensions.get(0);
DimensionalObject object = getDimensionalObject(category, relativePeriodDate, relativeUser, true, organisationUnitsAtLevel, organisationUnitsInGroups, format);
DimensionalObjectUtils.setDimensionItemsForFilters(object, dataItemGrid, true);
return object != null ? object.getItems() : null;
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class BaseChart method generateTitle.
public String generateTitle() {
List<String> titleItems = new ArrayList<>();
for (String filter : filterDimensions) {
DimensionalObject object = getDimensionalObject(filter, relativePeriodDate, relativeUser, true, organisationUnitsAtLevel, organisationUnitsInGroups, format);
if (object != null) {
String item = IdentifiableObjectUtils.join(object.getItems());
String filt = DimensionalObjectUtils.getPrettyFilter(object.getFilter());
if (item != null) {
titleItems.add(item);
}
if (filt != null) {
titleItems.add(filt);
}
}
}
return join(titleItems, DimensionalObjectUtils.TITLE_ITEM_SEP);
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class EventDataQueryServiceTest method testSetItemsForDimensionFilters.
@Test
public void testSetItemsForDimensionFilters() {
TrackedEntityAttribute tea = new TrackedEntityAttribute();
tea.setAutoFields();
TrackedEntityAttributeDimension tead = new TrackedEntityAttributeDimension(tea, null, "EQ:2");
EventChart eventChart = new EventChart();
eventChart.setAutoFields();
eventChart.getColumnDimensions().add(tea.getUid());
eventChart.getAttributeDimensions().add(tead);
Grid grid = new ListGrid();
grid.addHeader(new GridHeader(tea.getUid(), tea.getName()));
grid.addRow().addValue("1");
grid.addRow().addValue("2");
grid.addRow().addValue("3");
grid.addRow().addValue(null);
eventChart.populateAnalyticalProperties();
DimensionalObject dim = eventChart.getColumns().get(0);
DimensionalObjectUtils.setDimensionItemsForFilters(dim, grid, true);
assertNotNull(dim);
assertEquals(DimensionType.PROGRAM_ATTRIBUTE, dim.getDimensionType());
assertEquals(AnalyticsType.EVENT, dim.getAnalyticsType());
assertEquals(tead.getFilter(), dim.getFilter());
List<DimensionalItemObject> items = dim.getItems();
assertEquals(4, items.size());
assertNotNull(items.get(0).getUid());
assertNotNull(items.get(0).getName());
assertNotNull(items.get(0).getCode());
assertNotNull(items.get(0).getShortName());
}
use of org.hisp.dhis.common.DimensionalObject in project dhis2-core by dhis2.
the class AnalyticsUtils method getDimensionMetadataItemMap.
/**
* Returns a mapping between identifiers and meta data items for the given query.
*
* @param params the data query parameters.
* @return a mapping between identifiers and meta data items.
*/
public static Map<String, MetadataItem> getDimensionMetadataItemMap(DataQueryParams params) {
List<DimensionalObject> dimensions = params.getDimensionsAndFilters();
Map<String, MetadataItem> map = new HashMap<>();
Calendar calendar = PeriodType.getCalendar();
for (DimensionalObject dimension : dimensions) {
for (DimensionalItemObject item : dimension.getItems()) {
if (DimensionType.PERIOD == dimension.getDimensionType() && !calendar.isIso8601()) {
Period period = (Period) item;
DateTimeUnit dateTimeUnit = calendar.fromIso(period.getStartDate());
map.put(period.getPeriodType().getIsoDate(dateTimeUnit), new MetadataItem(period.getDisplayName()));
} else {
String legendSet = item.hasLegendSet() ? item.getLegendSet().getUid() : null;
map.put(item.getDimensionItem(), new MetadataItem(item.getDisplayProperty(params.getDisplayProperty()), legendSet));
}
if (DimensionType.ORGANISATION_UNIT == dimension.getDimensionType() && params.isHierarchyMeta()) {
OrganisationUnit unit = (OrganisationUnit) item;
for (OrganisationUnit ancestor : unit.getAncestors()) {
map.put(ancestor.getUid(), new MetadataItem(ancestor.getDisplayProperty(params.getDisplayProperty())));
}
}
if (DimensionItemType.DATA_ELEMENT == item.getDimensionItemType()) {
DataElement dataElement = (DataElement) item;
for (DataElementCategoryOptionCombo coc : dataElement.getCategoryOptionCombos()) {
map.put(coc.getUid(), new MetadataItem(coc.getDisplayProperty(params.getDisplayProperty())));
}
}
}
map.put(dimension.getDimension(), new MetadataItem(dimension.getDisplayProperty(params.getDisplayProperty())));
}
return map;
}
Aggregations