use of org.hisp.dhis.dxf2.webmessage.DescriptiveWebMessage 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