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;
}
Aggregations