← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13107: Min-max generation, fixed issue with negative values occurring as min-values for data elements of...

 

------------------------------------------------------------
revno: 13107
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-12-02 19:52:58 +0100
message:
  Min-max generation, fixed issue with negative values occurring as min-values for data elements of type positive / zero-or-positive number, and positive values occurring as max-values for data elements of type negative number 
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.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/dataanalysis/MinMaxOutlierAnalysisService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java	2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java	2013-12-02 18:52:58 +0000
@@ -51,6 +51,8 @@
 import org.hisp.dhis.system.util.FilterUtils;
 import org.hisp.dhis.system.util.MathUtils;
 
+import static org.hisp.dhis.dataelement.DataElement.*;
+
 /**
  * @author Lars Helge Overland
  */
@@ -124,7 +126,7 @@
         
         for ( DataElement dataElement : dataElements )
         {
-            if ( dataElement.getType().equals( DataElement.VALUE_TYPE_INT ) )
+            if ( VALUE_TYPE_INT.equals( dataElement.getType() ) )
             {
                 Collection<DataElementCategoryOptionCombo> categoryOptionCombos = dataElement.getCategoryCombo().getOptionCombos();
 
@@ -144,6 +146,16 @@
                             int min = (int) MathUtils.getLowBound( stdDev, stdDevFactor, avg );
                             int max = (int) MathUtils.getHighBound( stdDev, stdDevFactor, avg );
                             
+                            if ( VALUE_TYPE_POSITIVE_INT.equals( dataElement.getNumberType() ) || VALUE_TYPE_ZERO_OR_POSITIVE_INT.equals( dataElement.getNumberType() ) )
+                            {
+                                min = Math.max( 0, min ); // Cannot be < 0
+                            }
+                            
+                            if ( VALUE_TYPE_NEGATIVE_INT.equals( dataElement.getNumberType() ) )
+                            {
+                                max = Math.min( 0, max ); // Cannot be > 0
+                            }
+                            
                             OrganisationUnit source = new OrganisationUnit();
                             source.setId( unit );