← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2064: Calmed logging of insignificant datavalues to debug and refactored some duplicate code.

 

------------------------------------------------------------
revno: 2064
committer: Jo Størset <storset@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2010-11-15 23:32:43 +0530
message:
  Calmed logging of insignificant datavalues to debug and refactored some duplicate code.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.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/datavalue/DefaultDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java	2010-10-22 10:11:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java	2010-11-15 18:02:43 +0000
@@ -76,19 +76,9 @@
 
     public void addDataValue( DataValue dataValue )
     {
-        if ( !dataValue.isNullValue() )
+        if ( !dataValue.isNullValue() && isSignificant( dataValue ) )
         {
-            if ( dataValue.isZero() && !dataValue.getDataElement().isZeroIsSignificant()
-                && !dataValue.getDataElement().getAggregationOperator().equals( AGGREGATION_OPERATOR_AVERAGE ) )
-            {
-                log.info( "DataValue was ignored as zero values are insignificant for this data element: "
-                    + dataValue.getDataElement() );
-                
-            }
-            else
-            {
-                dataValueStore.addDataValue( dataValue );
-            }
+            dataValueStore.addDataValue( dataValue );
         }
     }
 
@@ -98,18 +88,9 @@
         {
             this.deleteDataValue( dataValue );
         }
-        else
+        else if ( isSignificant( dataValue ) )
         {
-            if ( dataValue.isZero() && !dataValue.getDataElement().isZeroIsSignificant()
-                && !dataValue.getDataElement().getAggregationOperator().equals( AGGREGATION_OPERATOR_AVERAGE ) )
-            {
-                log.info( "DataValue was ignored as zero values are insignificant for this data element: "
-                    + dataValue.getDataElement() );
-            }
-            else
-            {
-                dataValueStore.updateDataValue( dataValue );
-            }
+            dataValueStore.updateDataValue( dataValue );
         }
     }
 
@@ -210,13 +191,25 @@
     {
         return dataValueStore.getDataValues( dataElement );
     }
-   
+
     @Override
     public DataValue getLatestDataValues( DataElement dataElement, PeriodType periodType,
         OrganisationUnit organisationUnit )
-    {        
+    {
         return dataValueStore.getLatestDataValues( dataElement, periodType, organisationUnit );
     }
 
-   
+    private boolean isSignificant( DataValue dataValue )
+    {
+        if ( dataValue.isZero() && !dataValue.getDataElement().isZeroIsSignificant()
+            && !dataValue.getDataElement().getAggregationOperator().equals( AGGREGATION_OPERATOR_AVERAGE ) )
+        {
+            log.debug( "DataValue was ignored as zero values are insignificant for this data element: "
+                + dataValue.getDataElement() );
+            return false;
+        }
+        return true;
+    }
+
+    
 }