use of org.hisp.dhis.dxf2.webmessage.DescriptiveWebMessage in project dhis2-core by dhis2.
the class ProgramIndicatorController method validateFilter.
@RequestMapping(value = "/filter/description", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public void validateFilter(@RequestBody String expression, HttpServletResponse response) throws IOException {
I18n i18n = i18nManager.getI18n();
String result = programIndicatorService.filterIsValid(expression);
DescriptiveWebMessage message = new DescriptiveWebMessage();
message.setStatus(ProgramIndicator.VALID.equals(result) ? Status.OK : Status.ERROR);
message.setMessage(i18n.getString(result));
if (message.isOk()) {
message.setDescription(programIndicatorService.getExpressionDescription(expression));
}
webMessageService.sendJson(message, response);
}
use of org.hisp.dhis.dxf2.webmessage.DescriptiveWebMessage in project dhis2-core by dhis2.
the class ProgramIndicatorController method getExpressionDescription.
@RequestMapping(value = "/expression/description", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public void getExpressionDescription(@RequestBody String expression, HttpServletResponse response) throws IOException {
I18n i18n = i18nManager.getI18n();
String result = programIndicatorService.expressionIsValid(expression);
DescriptiveWebMessage message = new DescriptiveWebMessage();
message.setStatus(ProgramIndicator.VALID.equals(result) ? Status.OK : Status.ERROR);
message.setMessage(i18n.getString(result));
if (message.isOk()) {
message.setDescription(programIndicatorService.getExpressionDescription(expression));
}
webMessageService.sendJson(message, response);
}
use of org.hisp.dhis.dxf2.webmessage.DescriptiveWebMessage in project dhis2-core by dhis2.
the class ProgramRuleController method validateCondition.
@PostMapping(value = "/condition/description", produces = APPLICATION_JSON_VALUE)
@ResponseBody
public WebMessage validateCondition(@RequestBody String condition, @RequestParam String programId) {
I18n i18n = i18nManager.getI18n();
RuleValidationResult result = programRuleEngineService.getDescription(condition, programId);
if (result.isValid()) {
return new DescriptiveWebMessage(Status.OK, HttpStatus.OK).setDescription(result.getDescription()).setMessage(i18n.getString(ProgramIndicator.VALID));
}
String description = null;
if (result.getErrorMessage() != null) {
description = result.getErrorMessage();
} else if (result.getException() != null) {
description = result.getException().getMessage();
}
return new DescriptiveWebMessage(Status.ERROR, HttpStatus.OK).setDescription(description).setMessage(i18n.getString(ProgramIndicator.EXPRESSION_NOT_VALID));
}
use of org.hisp.dhis.dxf2.webmessage.DescriptiveWebMessage in project dhis2-core by dhis2.
the class ProgramRuleActionController method getDataExpressionDescription.
@PostMapping(value = "/data/expression/description", produces = APPLICATION_JSON_VALUE)
@ResponseBody
public WebMessage getDataExpressionDescription(@RequestBody String condition, @RequestParam String programId) {
I18n i18n = i18nManager.getI18n();
RuleValidationResult result = programRuleEngineService.getDataExpressionDescription(condition, programId);
if (result.isValid()) {
return new DescriptiveWebMessage(Status.OK, HttpStatus.OK).setDescription(result.getDescription()).setMessage(i18n.getString(ProgramIndicator.VALID));
}
String description = null;
if (result.getErrorMessage() != null) {
description = result.getErrorMessage();
} else if (result.getException() != null) {
description = result.getException().getMessage();
}
return new DescriptiveWebMessage(Status.ERROR, HttpStatus.CONFLICT).setDescription(description).setMessage(i18n.getString(ProgramIndicator.EXPRESSION_NOT_VALID));
}
use of org.hisp.dhis.dxf2.webmessage.DescriptiveWebMessage in project dhis2-core by dhis2.
the class ExpressionController method getExpressionDescription.
@RequestMapping(value = "/description", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public void getExpressionDescription(@RequestParam String expression, HttpServletResponse response) throws IOException {
I18n i18n = i18nManager.getI18n();
ExpressionValidationOutcome result = expressionService.expressionIsValid(expression);
DescriptiveWebMessage message = new DescriptiveWebMessage();
message.setStatus(result.isValid() ? Status.OK : Status.ERROR);
message.setMessage(i18n.getString(result.getKey()));
if (result.isValid()) {
message.setDescription(expressionService.getExpressionDescription(expression));
}
webMessageService.sendJson(message, response);
}
Aggregations