← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22155: Implement validation operator exclusive_pair

 

------------------------------------------------------------
revno: 22155
committer: jimgrace@xxxxxxxxx
branch nick: dhis2
timestamp: Mon 2016-03-07 09:52:03 -0500
message:
  Implement validation operator exclusive_pair
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Operator.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidatorThread.java
  dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/addValidationRuleForm.vm
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/general.js
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/validationRule.js
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleForm.vm
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Operator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Operator.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/Operator.java	2016-03-07 14:52:03 +0000
@@ -37,7 +37,8 @@
     greater_than_or_equal_to( ">=" ), 
     less_than( "<" ), 
     less_than_or_equal_to( "<=" ),
-    compulsory_pair( "[Compulsory pair]" );
+    compulsory_pair( "[Compulsory pair]"),
+    exclusive_pair( "[Exclusive pair]" );
 
     private final String mathematicalOperator;
 

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidatorThread.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidatorThread.java	2016-01-13 12:54:38 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidatorThread.java	2016-03-07 14:52:03 +0000
@@ -142,7 +142,8 @@
                                     periodTypeX, periodTypes, lastUpdatedMap, sourceDataElements );
 
                                 if ( !leftSideValues.isEmpty()
-                                    || Operator.compulsory_pair.equals( rule.getOperator() ) )
+                                    || Operator.compulsory_pair.equals( rule.getOperator() )
+                                    || Operator.exclusive_pair.equals( rule.getOperator() ))
                                 {
                                     Map<Integer, Double> rightSideValues = getRuleExpressionValueMap(
                                         rule.getRightSide(), currentValueMap, incompleteValuesMap, sourceX.getSource(),
@@ -150,11 +151,13 @@
                                         sourceDataElements );
 
                                     if ( !rightSideValues.isEmpty()
-                                        || Operator.compulsory_pair.equals( rule.getOperator() ) )
+                                        || Operator.compulsory_pair.equals( rule.getOperator() )
+                                        || Operator.compulsory_pair.equals( rule.getOperator() ))
                                     {
                                         Set<Integer> attributeOptionCombos = leftSideValues.keySet();
 
-                                        if ( Operator.compulsory_pair.equals( rule.getOperator() ) )
+                                        if ( Operator.compulsory_pair.equals( rule.getOperator() ) ||
+                                            Operator.exclusive_pair.equals( rule.getOperator() ) )
                                         {
                                             attributeOptionCombos = new HashSet<>( attributeOptionCombos );
                                             attributeOptionCombos.addAll( rightSideValues.keySet() );
@@ -171,6 +174,10 @@
                                                 violation = (leftSide != null && rightSide == null)
                                                     || (leftSide == null && rightSide != null);
                                             }
+                                            else if ( Operator.exclusive_pair.equals( rule.getOperator() ) )
+                                            {
+                                                violation = ( leftSide != null && rightSide != null );
+                                            }
                                             else if ( leftSide != null && rightSide != null )
                                             {
                                                 violation = !expressionIsTrue( leftSide, rule.getOperator(),

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties	2015-12-08 21:44:36 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties	2016-03-07 14:52:03 +0000
@@ -129,6 +129,7 @@
 skip_for_missing_values=Skip for missing values
 select_parameters=Select parameters
 compulsory_pair=Compulsory pair
+exclusive_pair=Exclusive pair
 visible_in_validation_alerts=visible in validation alerts
 tip=Tip
 use=use

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/addValidationRuleForm.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/addValidationRuleForm.vm	2015-12-25 09:55:06 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/addValidationRuleForm.vm	2016-03-07 14:52:03 +0000
@@ -79,6 +79,7 @@
 				<option value="less_than">$i18n.getString( "less_than" )</option>
 				<option value="less_than_or_equal_to">$i18n.getString( "less_than_or_equal_to" )</option>
                 <option value="compulsory_pair" id="compulsory_pair">$i18n.getString( "compulsory_pair" )</option>
+                <option value="exclusive_pair" id="exclusive_pair">$i18n.getString( "exclusive_pair" )</option>
 			</select>
 		</td>
 	</tr>

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/general.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/general.js	2015-12-25 09:55:06 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/general.js	2016-03-07 14:52:03 +0000
@@ -115,6 +115,10 @@
     {
         return i18n_compulsory_pair;
     }
+	else if ( operator == "exclusive_pair" )
+	{
+		return i18n_exclusive_pair;
+	}
     
     return null;
 }

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/validationRule.js'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/validationRule.js	2015-12-25 09:55:06 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/javascript/validationRule.js	2016-03-07 14:52:03 +0000
@@ -7,6 +7,7 @@
     hideById('annualSampleCountTR');
 
     showById('compulsory_pair');
+    showById('exclusive_pair');
   }
   else {
     showById('organisationUnitLevelTR');
@@ -14,10 +15,11 @@
     showById('annualSampleCountTR');
 
     var op = document.getElementById('operator');
-    if( 'compulsory_pair' == op.value ) {
+    if( 'compulsory_pair' == op.value || 'exclusive_pair' == op.value ) {
       showById('select_operator');
       op.selectedIndex = 0;
     }
     hideById('compulsory_pair');
+    hideById('exclusive_pair');
   }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleForm.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleForm.vm	2015-12-25 09:55:06 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/updateValidationRuleForm.vm	2016-03-07 14:52:03 +0000
@@ -87,6 +87,7 @@
 				<option value="less_than" #if ( $validationRule.operator == 'less_than' )selected="selected"#end>$i18n.getString( "less_than" )</option>
 				<option value="less_than_or_equal_to" #if ( $validationRule.operator == 'less_than_or_equal_to' )selected="selected"#end>$i18n.getString( "less_than_or_equal_to" )</option>
                 <option value="compulsory_pair" id="compulsory_pair" #if ( $validationRule.operator == 'compulsory_pair' )selected="selected"#end>$i18n.getString( "compulsory_pair" )</option>
+                <option value="exclusive_pair" id="exclusive_pair" #if ( $validationRule.operator == 'exclusive_pair' )selected="selected"#end>$i18n.getString( "exclusive_pair" )</option>
 			</select>
 		</td>
 	</tr>

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm	2015-12-25 09:55:06 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/validationRule.vm	2016-03-07 14:52:03 +0000
@@ -44,6 +44,7 @@
   var i18n_less_than = '$i18n.getString( "less_than" )';
   var i18n_less_than_or_equal_to = '$i18n.getString( "less_than_or_equal_to" )';
   var i18n_compulsory_pair = '$i18n.getString( "compulsory_pair" )';
+  var i18n_exclusive_pair = '$i18n.getString( "exclusive_pair" )';
 </script>
 
 <h3>$encoder.htmlEncode( $i18n.getString( "validation_rule_management" ) ) #openHelp( "validationRule" )</h3>