Search in sources :

Example 1 with AggregatableDataElementFilter

use of org.hisp.dhis.system.filter.AggregatableDataElementFilter in project dhis2-core by dhis2.

the class GetDataElementsAction method execute.

// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@Override
public String execute() throws Exception {
    if (id != null && id != ALL) {
        DataElementGroup dataElementGroup = dataElementService.getDataElementGroup(id);
        if (dataElementGroup != null) {
            dataElements = new ArrayList<>(dataElementGroup.getMembers());
        }
    } else if (categoryComboId != null && categoryComboId != ALL) {
        DataElementCategoryCombo categoryCombo = categoryService.getDataElementCategoryCombo(categoryComboId);
        if (categoryCombo != null) {
            dataElements = new ArrayList<>(dataElementService.getDataElementByCategoryCombo(categoryCombo));
        }
    } else if (dataSetId != null) {
        DataSet dataset = dataSetService.getDataSet(dataSetId);
        if (dataset != null) {
            dataElements = new ArrayList<>(dataset.getDataElements());
        }
    } else if (periodTypeName != null) {
        PeriodType periodType = periodService.getPeriodTypeByName(periodTypeName);
        if (periodType != null) {
            dataElements = new ArrayList<>(dataElementService.getDataElementsByPeriodType(periodType));
        }
    } else if (domain != null) {
        if (domain.equals(DataElementDomain.AGGREGATE.getValue())) {
            dataElements = new ArrayList<>(dataElementService.getDataElementsByDomainType(DataElementDomain.AGGREGATE));
        } else {
            dataElements = new ArrayList<>(dataElementService.getDataElementsByDomainType(DataElementDomain.TRACKER));
        }
    } else {
        dataElements = new ArrayList<>(dataElementService.getAllDataElements());
        ContextUtils.clearIfNotModified(ServletActionContext.getRequest(), ServletActionContext.getResponse(), dataElements);
    }
    if (key != null) {
        dataElements = IdentifiableObjectUtils.filterNameByKey(dataElements, key, true);
    }
    if (dataElements == null) {
        dataElements = new ArrayList<>();
    }
    Collections.sort(dataElements);
    if (aggregate) {
        FilterUtils.filter(dataElements, new AggregatableDataElementFilter());
    }
    if (usePaging) {
        this.paging = createPaging(dataElements.size());
        dataElements = dataElements.subList(paging.getStartPos(), paging.getEndPos());
    }
    return SUCCESS;
}
Also used : PeriodType(org.hisp.dhis.period.PeriodType) DataElementCategoryCombo(org.hisp.dhis.dataelement.DataElementCategoryCombo) DataSet(org.hisp.dhis.dataset.DataSet) DataElementGroup(org.hisp.dhis.dataelement.DataElementGroup) ArrayList(java.util.ArrayList) AggregatableDataElementFilter(org.hisp.dhis.system.filter.AggregatableDataElementFilter)

Aggregations

ArrayList (java.util.ArrayList)1 DataElementCategoryCombo (org.hisp.dhis.dataelement.DataElementCategoryCombo)1 DataElementGroup (org.hisp.dhis.dataelement.DataElementGroup)1 DataSet (org.hisp.dhis.dataset.DataSet)1 PeriodType (org.hisp.dhis.period.PeriodType)1 AggregatableDataElementFilter (org.hisp.dhis.system.filter.AggregatableDataElementFilter)1