Search in sources :

Example 6 with ValidationResult

use of org.hisp.dhis.validation.ValidationResult in project dhis2-core by dhis2.

the class FormUtilsImpl method getValidationRuleViolations.

@Override
public List<String> getValidationRuleViolations(OrganisationUnit organisationUnit, DataSet dataSet, Period period) {
    List<ValidationResult> validationRuleResults = new ArrayList<>(validationService.startInteractiveValidationAnalysis(dataSet, period, organisationUnit, null));
    List<String> validationRuleViolations = new ArrayList<>(validationRuleResults.size());
    for (ValidationResult result : validationRuleResults) {
        ValidationRule rule = result.getValidationRule();
        StringBuilder sb = new StringBuilder();
        sb.append(expressionService.getExpressionDescription(rule.getLeftSide().getExpression()));
        sb.append(" ").append(rule.getOperator().getMathematicalOperator()).append(" ");
        sb.append(expressionService.getExpressionDescription(rule.getRightSide().getExpression()));
        validationRuleViolations.add(sb.toString());
    }
    return validationRuleViolations;
}
Also used : ValidationResult(org.hisp.dhis.validation.ValidationResult) ValidationRule(org.hisp.dhis.validation.ValidationRule)

Aggregations

ValidationResult (org.hisp.dhis.validation.ValidationResult)6 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)3 SendStrategy (org.hisp.dhis.notification.SendStrategy)2 Period (org.hisp.dhis.period.Period)2 Clock (org.hisp.dhis.system.util.Clock)2 User (org.hisp.dhis.user.User)2 com.google.common.collect (com.google.common.collect)1 java.util (java.util)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 NotNull (javax.validation.constraints.NotNull)1 CompareToBuilder (org.apache.commons.lang3.builder.CompareToBuilder)1 EqualsBuilder (org.apache.commons.lang3.builder.EqualsBuilder)1 HashCodeBuilder (org.apache.commons.lang3.builder.HashCodeBuilder)1 Log (org.apache.commons.logging.Log)1 LogFactory (org.apache.commons.logging.LogFactory)1