use of org.hisp.dhis.rules.models.RuleValidationResult 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.rules.models.RuleValidationResult in project dhis2-core by dhis2.
the class ProgramRuleEngineDescriptionTest method testProgramRuleWithD2HasValueTrackedEntityAttribute2.
@Test
void testProgramRuleWithD2HasValueTrackedEntityAttribute2() {
programRuleWithD2HasValue.setCondition(conditionWithD2HasValue2);
RuleValidationResult result = validateRuleCondition(programRuleWithD2HasValue.getCondition(), program);
assertNotNull(result);
assertEquals("AttributeA", result.getDescription());
assertTrue(result.isValid());
}
use of org.hisp.dhis.rules.models.RuleValidationResult in project dhis2-core by dhis2.
the class ProgramRuleEngineDescriptionTest method testProgramRuleWithNumericDataElement.
@Test
void testProgramRuleWithNumericDataElement() {
RuleValidationResult result = validateRuleCondition(programRuleNumericDE.getCondition(), program);
assertNotNull(result);
assertEquals("DataElementE == 14", result.getDescription());
assertTrue(result.isValid());
}
use of org.hisp.dhis.rules.models.RuleValidationResult in project dhis2-core by dhis2.
the class ProgramRuleEngineDescriptionTest method testExtractDataMatrixValue.
@Test
void testExtractDataMatrixValue() {
RuleValidationResult result = validateRuleCondition(extractDataMatrixValueExpression, program);
assertNotNull(result);
assertTrue(result.isValid());
}
use of org.hisp.dhis.rules.models.RuleValidationResult in project dhis2-core by dhis2.
the class ProgramRuleEngineDescriptionTest method testProgramRuleWithNumericTrackedEntityAttribute.
@Test
void testProgramRuleWithNumericTrackedEntityAttribute() {
RuleValidationResult result = validateRuleCondition(programRuleNumericAtt.getCondition(), program);
assertNotNull(result);
assertEquals("AttributeB == 12 || Current date", result.getDescription());
assertTrue(result.isValid());
}
Aggregations