use of org.hisp.dhis.analytics.AggregationType in project dhis2-core by dhis2.
the class QueryPlannerUtils method getAggregationTypeDataElementMap.
/**
* Creates a mapping between the aggregation type and data element for the
* given data elements and period type.
*
* @param params the data query parameters.
*/
public static ListMap<AggregationType, DimensionalItemObject> getAggregationTypeDataElementMap(DataQueryParams params) {
List<DimensionalItemObject> dataElements = params.getDataElements();
PeriodType aggregationPeriodType = PeriodType.getPeriodTypeByName(params.getPeriodType());
ListMap<AggregationType, DimensionalItemObject> map = new ListMap<>();
for (DimensionalItemObject element : dataElements) {
DataElement de = (DataElement) element;
AggregationType type = ObjectUtils.firstNonNull(params.getAggregationType(), de.getAggregationType());
AggregationType aggregationType = getAggregationType(de.getValueType(), type, aggregationPeriodType, de.getPeriodType());
map.putValue(aggregationType, de);
}
return map;
}
use of org.hisp.dhis.analytics.AggregationType in project dhis2-core by dhis2.
the class QueryPlannerUtils method getAggregationType.
/**
* Puts the given element into the map according to the value type, aggregation
* operator, aggregation period type and data period type.
*
* @param valueType the value type.
* @param aggregationType the aggregation operator.
* @param aggregationPeriodType the aggregation period type.
* @param dataPeriodType the data period type.
*/
public static AggregationType getAggregationType(ValueType valueType, AggregationType aggregationType, PeriodType aggregationPeriodType, PeriodType dataPeriodType) {
AggregationType type;
boolean disaggregation = isDisaggregation(aggregationPeriodType, dataPeriodType);
boolean number = valueType.isNumeric();
if (aggregationType.isAverage() && ValueType.BOOLEAN == valueType) {
type = AggregationType.AVERAGE_BOOL;
} else if (AggregationType.AVERAGE_SUM_ORG_UNIT == aggregationType && number && disaggregation) {
type = AggregationType.AVERAGE_SUM_INT_DISAGGREGATION;
} else if (AggregationType.AVERAGE_SUM_ORG_UNIT == aggregationType && number) {
type = AggregationType.AVERAGE_SUM_INT;
} else if (AggregationType.AVERAGE == aggregationType && number && disaggregation) {
type = AggregationType.AVERAGE_INT_DISAGGREGATION;
} else if (AggregationType.AVERAGE == aggregationType && number) {
type = AggregationType.AVERAGE_INT;
} else {
type = aggregationType;
}
return type;
}
use of org.hisp.dhis.analytics.AggregationType in project dhis2-core by dhis2.
the class FunctionAggregationType method evaluate.
@Override
public Object evaluate(ExprContext ctx, CommonExpressionVisitor visitor) {
AggregationType aggregationType = parseAggregationType(ctx.aggregationType.getText());
QueryModifiers queryMods = visitor.getState().getQueryModsBuilder().aggregationType(aggregationType).build();
return visitor.visitWithQueryMods(ctx.expr(0), queryMods);
}
Aggregations