use of org.hisp.dhis.analytics.resolver.ExpressionResolver in project dhis2-core by dhis2.
the class DataHandler method resolveIndicatorExpressions.
/**
* Resolves the numerator and denominator expressions of indicators in the
* data query.
*
* @param params the {@link DataQueryParams}.
* @return the resolved list of indicators.
*/
private List<Indicator> resolveIndicatorExpressions(DataQueryParams params) {
List<Indicator> indicators = asTypedList(params.getIndicators());
for (Indicator indicator : indicators) {
for (ExpressionResolver resolver : resolvers.getExpressionResolvers()) {
indicator.setNumerator(resolver.resolve(indicator.getNumerator()));
indicator.setDenominator(resolver.resolve(indicator.getDenominator()));
}
}
return indicators;
}
use of org.hisp.dhis.analytics.resolver.ExpressionResolver in project dhis2-core by dhis2.
the class IndicatorController method getExpressionDescription.
@PostMapping(value = "/expression/description", produces = APPLICATION_JSON_VALUE)
@ResponseBody
public WebMessage getExpressionDescription(@RequestBody String expression) {
String resolvingExpression = expression;
for (ExpressionResolver resolver : resolvers.getExpressionResolvers()) {
resolvingExpression = resolver.resolve(resolvingExpression);
}
String resolvedExpression = resolvingExpression;
ExpressionValidationOutcome result = expressionService.expressionIsValid(resolvedExpression, INDICATOR_EXPRESSION);
return new DescriptiveWebMessage(result.isValid() ? Status.OK : Status.ERROR, HttpStatus.OK).setDescription(result::isValid, () -> expressionService.getExpressionDescription(resolvedExpression, INDICATOR_EXPRESSION)).setMessage(i18nManager.getI18n().getString(result.getKey()));
}
Aggregations