use of org.hisp.dhis.expression.ParseType.INDICATOR_EXPRESSION in project dhis2-core by dhis2.
the class CategoryOptionResolver method resolve.
@Override
public String resolve(String expression) {
Set<DimensionalItemId> dimItemIds = expressionService.getExpressionDimensionalItemIds(expression, INDICATOR_EXPRESSION);
for (DimensionalItemId id : dimItemIds) {
if (id.getItem() != null && id.getId1() != null && id.getId1().startsWith(CATEGORY_OPTION_PREFIX)) {
CategoryOption co = categoryOptionStore.getByUid(id.getId1().replace(CATEGORY_OPTION_PREFIX, EMPTY_STRING));
if (co != null) {
List<String> resolved = co.getCategoryOptionCombos().stream().map(coc -> id.getItem().replace(id.getId1(), coc.getUid())).collect(Collectors.toList());
expression = expression.replace(id.getItem(), LEFT_BRACKET + Joiner.on("+").join(resolved) + RIGHT_BRACKET);
}
}
}
return expression;
}
use of org.hisp.dhis.expression.ParseType.INDICATOR_EXPRESSION in project dhis2-core by dhis2.
the class DataElementGroupResolver method resolve.
@Override
public String resolve(String expression) {
Set<DimensionalItemId> dimItemIds = expressionService.getExpressionDimensionalItemIds(expression, INDICATOR_EXPRESSION);
for (DimensionalItemId id : dimItemIds) {
if (id.getItem() != null && id.getId0() != null && id.getId0().startsWith(DATA_ELEMENT_GROUP_PREFIX)) {
DataElementGroup deGroup = dataElementGroupStore.getByUid(id.getId0().replace(DATA_ELEMENT_GROUP_PREFIX, EMPTY_STRING));
if (deGroup != null) {
List<String> resolved = deGroup.getMembers().stream().map(de -> id.getItem().replace(id.getId0(), de.getUid())).collect(Collectors.toList());
expression = expression.replace(id.getItem(), LEFT_BRACKET + Joiner.on("+").join(resolved) + RIGHT_BRACKET);
}
}
}
return expression;
}
Aggregations