Search in sources :

Example 1 with DimensionalObject

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;
}
Also used : DimensionalObject(org.hisp.dhis.common.DimensionalObject)

Example 2 with DimensionalObject

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;
}
Also used : DimensionalObject(org.hisp.dhis.common.DimensionalObject)

Example 3 with DimensionalObject

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);
}
Also used : ArrayList(java.util.ArrayList) DimensionalObject(org.hisp.dhis.common.DimensionalObject)

Example 4 with DimensionalObject

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());
}
Also used : TrackedEntityAttributeDimension(org.hisp.dhis.trackedentity.TrackedEntityAttributeDimension) DimensionalItemObject(org.hisp.dhis.common.DimensionalItemObject) TrackedEntityAttribute(org.hisp.dhis.trackedentity.TrackedEntityAttribute) ListGrid(org.hisp.dhis.system.grid.ListGrid) Grid(org.hisp.dhis.common.Grid) EventChart(org.hisp.dhis.eventchart.EventChart) ListGrid(org.hisp.dhis.system.grid.ListGrid) GridHeader(org.hisp.dhis.common.GridHeader) DimensionalObject(org.hisp.dhis.common.DimensionalObject) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 5 with DimensionalObject

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;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) Calendar(org.hisp.dhis.calendar.Calendar) Period(org.hisp.dhis.period.Period) DateUtils.getMediumDateString(org.hisp.dhis.system.util.DateUtils.getMediumDateString) DimensionalObject(org.hisp.dhis.common.DimensionalObject) DataElement(org.hisp.dhis.dataelement.DataElement) DateTimeUnit(org.hisp.dhis.calendar.DateTimeUnit) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo)

Aggregations

DimensionalObject (org.hisp.dhis.common.DimensionalObject)44 ArrayList (java.util.ArrayList)14 BaseDimensionalObject (org.hisp.dhis.common.BaseDimensionalObject)14 DimensionalItemObject (org.hisp.dhis.common.DimensionalItemObject)13 DataQueryParams (org.hisp.dhis.analytics.DataQueryParams)11 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)10 Test (org.junit.Test)8 List (java.util.List)6 DhisConvenienceTest (org.hisp.dhis.DhisConvenienceTest)5 Grid (org.hisp.dhis.common.Grid)5 DataElement (org.hisp.dhis.dataelement.DataElement)5 Period (org.hisp.dhis.period.Period)5 DateUtils.getMediumDateString (org.hisp.dhis.system.util.DateUtils.getMediumDateString)5 Calendar (org.hisp.dhis.calendar.Calendar)4 User (org.hisp.dhis.user.User)4 CategoryOptionGroupSet (org.hisp.dhis.dataelement.CategoryOptionGroupSet)3 DataSet (org.hisp.dhis.dataset.DataSet)3 Indicator (org.hisp.dhis.indicator.Indicator)3 OrganisationUnitGroup (org.hisp.dhis.organisationunit.OrganisationUnitGroup)3 ListGrid (org.hisp.dhis.system.grid.ListGrid)3