dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #21019
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9847: Null checks
------------------------------------------------------------
revno: 9847
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-02-19 15:20:08 +0100
message:
Null checks
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.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-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 2013-02-01 14:57:34 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/expression/DefaultExpressionService.java 2013-02-19 14:20:08 +0000
@@ -144,6 +144,11 @@
public Double getIndicatorValue( Indicator indicator, Period period, Map<DataElementOperand, Double> valueMap,
Map<String, Double> constantMap, Integer days )
{
+ if ( indicator == null || indicator.getNumerator() == null || indicator.getDenominator() == null )
+ {
+ return null;
+ }
+
final double denominatorValue = calculateExpression( generateExpression( indicator.getDenominator(), valueMap, constantMap, days, false ) );
if ( !isEqual( denominatorValue, 0d ) )
@@ -244,8 +249,18 @@
for ( Indicator indicator : indicators )
{
- dataElements.addAll( getDataElementsInExpression( indicator.getNumerator() ) );
- dataElements.addAll( getDataElementsInExpression( indicator.getDenominator() ) );
+ Set<DataElement> numerator = getDataElementsInExpression( indicator.getNumerator() );
+ Set<DataElement> denominator = getDataElementsInExpression( indicator.getDenominator() );
+
+ if ( numerator != null )
+ {
+ dataElements.addAll( numerator );
+ }
+
+ if ( denominator != null )
+ {
+ dataElements.addAll( denominator );
+ }
}
return dataElements;