=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java 2012-09-23 07:25:57 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Expression.java 2012-10-10 12:49:27 +0000 @@ -33,6 +33,8 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; + +import org.apache.commons.lang.Validate; import org.hisp.dhis.common.BaseIdentifiableObject; import org.hisp.dhis.common.Dxf2Namespace; import org.hisp.dhis.common.annotation.Scanned; @@ -293,4 +295,17 @@ { this.nullIfBlank = nullIfBlank; } + + public void mergeWith( Expression other ) + { + Validate.notNull( other ); + + expression = other.getExpression() == null ? expression : other.getExpression(); + description = other.getDescription() == null ? description : other.getDescription(); + nullIfBlank = other.isNullIfBlank(); + dataElementsInExpression = other.getDataElementsInExpression() == null ? + dataElementsInExpression : new HashSet( other.getDataElementsInExpression() ); + optionCombosInExpression = other.getOptionCombosInExpression() == null ? + optionCombosInExpression : new HashSet( other.getOptionCombosInExpression() ); + } } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java 2012-05-21 13:28:46 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRule.java 2012-10-10 12:49:27 +0000 @@ -260,10 +260,18 @@ description = validationRule.getDescription() == null ? description : validationRule.getDescription(); type = validationRule.getType() == null ? type : validationRule.getType(); operator = validationRule.getOperator() == null ? operator : validationRule.getOperator(); - leftSide = validationRule.getLeftSide() == null ? leftSide : validationRule.getLeftSide(); - rightSide = validationRule.getRightSide() == null ? rightSide : validationRule.getRightSide(); periodType = validationRule.getPeriodType() == null ? periodType : validationRule.getPeriodType(); + if ( leftSide != null && validationRule.getLeftSide() != null ) + { + leftSide.mergeWith( validationRule.getLeftSide() ); + } + + if ( rightSide != null && validationRule.getRightSide() != null ) + { + rightSide.mergeWith( validationRule.getRightSide() ); + } + groups.clear(); } }