dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31843
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16265: Data entry validation, fixed issue, related to data element totals in validation rules
------------------------------------------------------------
revno: 16265
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-07-27 21:59:20 +0200
message:
Data entry validation, fixed issue, related to data element totals in validation rules
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidatorThread.java
--
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/ExpressionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2014-07-26 17:33:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/expression/ExpressionService.java 2014-07-27 19:59:20 +0000
@@ -206,7 +206,8 @@
/**
* Returns all operands included in an expression string. The operand is on
- * the form <data element id>.<category option combo id>.
+ * the form #{data-element-id.category-option combo-id}. Requires that the
+ * expression has been exploded in order to handle data element totals.
*
* @param expression The expression string.
* @return A Set of Operands.
@@ -357,7 +358,7 @@
/**
* Returns all Operands included in the formulas for the given collection of
* Indicators. Requires that the explodedNumerator and explodedDenominator
- * properties have been populated.
+ * properties have been populated in order to handle totals.
*
* @param indicators the collection of Indicators.
*/
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2014-07-26 17:33:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2014-07-27 19:59:20 +0000
@@ -200,7 +200,11 @@
final String expressionString = generateExpression( expression.getExplodedExpressionFallback(), valueMap, constantMap,
orgUnitCountMap, days, expression.isNullIfBlank() );
- return expressionString != null ? calculateExpression( expressionString ) : null;
+ Double result = expressionString != null ? calculateExpression( expressionString ) : null;
+
+ log.debug( "Expression: " + expression.getExplodedExpressionFallback() + ", generated: " + expressionString + ", result: " + result );
+
+ return result;
}
public Double getExpressionValue( Expression expression, Map<DataElementOperand, Double> valueMap,
@@ -209,7 +213,11 @@
final String expressionString = generateExpression( expression.getExplodedExpressionFallback(), valueMap, constantMap, orgUnitCountMap, days,
expression.isNullIfBlank(), incompleteValues );
- return expressionString != null ? calculateExpression( expressionString ) : null;
+ Double result = expressionString != null ? calculateExpression( expressionString ) : null;
+
+ log.debug( "Expression: " + expression.getExplodedExpressionFallback() + ", generated: " + expressionString + ", result: " + result );
+
+ return result;
}
@Transactional
@@ -335,7 +343,12 @@
while ( matcher.find() )
{
- operandsInExpression.add( DataElementOperand.getOperand( matcher.group() ) );
+ DataElementOperand operand = DataElementOperand.getOperand( matcher.group() );
+
+ if ( operand.getOptionComboId() != null )
+ {
+ operandsInExpression.add( operand );
+ }
}
}
=== 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 2014-07-27 16:58:03 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/ValidatorThread.java 2014-07-27 19:59:20 +0000
@@ -136,8 +136,8 @@
for ( int optionCombo : attributeOptionCombos )
{
- Double leftSide = leftSideValues.get ( optionCombo );
- Double rightSide = rightSideValues.get ( optionCombo );
+ Double leftSide = leftSideValues.get( optionCombo );
+ Double rightSide = rightSideValues.get( optionCombo );
boolean violation = false;
if ( Operator.compulsory_pair.equals( rule.getOperator() ) )