← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3877: Proper double comparison in datamart

 

------------------------------------------------------------
revno: 3877
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-06-12 10:23:05 +0200
message:
  Proper double comparison in datamart
modified:
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java
  dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.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-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java	2011-06-07 12:43:08 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java	2011-06-12 08:23:05 +0000
@@ -154,6 +154,8 @@
     public int export( Collection<Integer> dataElementIds, Collection<Integer> indicatorIds,
         Collection<Integer> periodIds, Collection<Integer> organisationUnitIds, boolean useIndexes, ProcessState state )
     {
+        log.info( "Data mart export process started" );
+        
         int count = 0;
 
         TimeUtils.start();
@@ -298,7 +300,7 @@
             log.info( "Created indexes: " + TimeUtils.getHMS() );
         }
         
-        log.info( "Export process completed: " + TimeUtils.getHMS() );
+        log.info( "Data mart export process completed: " + TimeUtils.getHMS() );
 
         TimeUtils.stop();
 

=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java	2011-06-10 09:19:09 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/indicator/DefaultIndicatorDataMart.java	2011-06-12 08:23:05 +0000
@@ -31,6 +31,7 @@
 import static org.hisp.dhis.system.util.DateUtils.daysBetween;
 import static org.hisp.dhis.system.util.MathUtils.calculateExpression;
 import static org.hisp.dhis.system.util.MathUtils.getRounded;
+import static org.hisp.dhis.system.util.MathUtils.isEqual;
 
 import java.util.Collection;
 import java.util.Map;
@@ -137,11 +138,11 @@
                     {
                         final double denominatorValue = calculateExpression( expressionService.generateExpression( indicator.getExplodedDenominator(), valueMap, days ) );
 
-                        if ( denominatorValue != 0 )
+                        if ( !isEqual( denominatorValue, 0d ) )
                         {
                             final double numeratorValue = calculateExpression( expressionService.generateExpression( indicator.getExplodedNumerator(), valueMap, days ) );
                          
-                            if ( !( omitZeroNumerator && numeratorValue == 0 ) )
+                            if ( !( omitZeroNumerator && isEqual( numeratorValue, 0d ) ) )
                             {
                                 final double annualizationFactor = DateUtils.getAnnualizationFactor( indicator, period.getStartDate(), period.getEndDate() );                            
                                 final double factor = indicator.getIndicatorType().getFactor();                            

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java	2011-05-10 08:58:10 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java	2011-06-12 08:23:05 +0000
@@ -193,7 +193,7 @@
     
     /**
      * Tests whether the two decimal numbers are equal with a tolerance of 0.01.
-     * If one or both of the numbers are null, false is retured.
+     * If one or both of the numbers are null, false is returned.
      * 
      * @param d1 the first value.
      * @param d2 the second value.
@@ -210,6 +210,18 @@
     }
     
     /**
+     * Tests whether the two decimal numbers are equal with a tolerance of 0.01.
+     * 
+     * @param d1 the first value.
+     * @param d2 the second value.
+     * @return true if the two decimal numbers are equal with a tolerance of 0.01.
+     */
+    public static boolean isEqual( double d1, double d2 )
+    {
+        return Math.abs( d1 - d2 ) < TOLERANCE;
+    }
+    
+    /**
      * Returns a random int between 0 and 999.
      */
     public static int getRandom()

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java	2011-04-12 19:30:34 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/ValidationAction.java	2011-06-12 08:23:05 +0000
@@ -210,7 +210,7 @@
                     minmaxs );
             }
     
-            log.info( "Number of outlier values: " + dataValues.size() );
+            log.debug( "Number of outlier values: " + dataValues.size() );
     
             // ---------------------------------------------------------------------
             // Validation rule analysis
@@ -218,7 +218,7 @@
     
             results = new ArrayList<ValidationResult>( validationRuleService.validate( dataSet, period, orgUnit ) );
     
-            log.info( "Number of validation violations: " + results.size() );
+            log.debug( "Number of validation violations: " + results.size() );
     
             if ( results.size() > 0 )
             {