← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1114: Work in progress on outlier analysis.

 

------------------------------------------------------------
revno: 1114
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Tue 2009-11-24 18:53:40 +0100
message:
  Work in progress on outlier analysis.
modified:
  dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisService.java
  dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisServiceTest.java
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.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-administration/src/main/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisService.java'
--- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisService.java	2009-11-24 17:34:15 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisService.java	2009-11-24 17:53:40 +0000
@@ -33,8 +33,6 @@
 
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.datamart.DataMartService;
-import org.hisp.dhis.datavalue.DataValue;
 import org.hisp.dhis.datavalue.DeflatedDataValue;
 import org.hisp.dhis.minmax.MinMaxDataElement;
 import org.hisp.dhis.minmax.MinMaxDataElementService;
@@ -77,27 +75,22 @@
     {
         final Collection<OutlierValue> outlierValues = new ArrayList<OutlierValue>();
 
-        final Collection<MinMaxDataElement> minMaxDataElements = 
-            minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataElement );
+        MinMaxDataElement minMaxDataElement = minMaxDataElementService.getMinMaxDataElement( organisationUnit, dataElement, categoryOptionCombo );
 
-        for ( MinMaxDataElement minMaxDataElement : minMaxDataElements )
+        if ( minMaxDataElement != null )
         {
             double lowerBound = minMaxDataElement.getMin();
             double upperBound = minMaxDataElement.getMax();
-            
-            for ( Period period : periods )
-            {    
-                final DataValue dataValue = null; //outlierAnalysisStore.getDeflatedDataValue( dataElement, categoryOptionCombo, period, organisationUnit );
-    
-                final int value = Integer.parseInt( dataValue.getValue() );
+
+            Collection<DeflatedDataValue> outliers = outlierAnalysisStore.
+                getDeflatedDataValues( dataElement, categoryOptionCombo, organisationUnit, lowerBound, upperBound );
+
+            for ( DeflatedDataValue outlier : outliers )
+            {
+                outlierValues.add( new OutlierValue( outlier, lowerBound, upperBound ) );
+            }
+        }
         
-                if ( value < lowerBound || value > upperBound )
-                {
-                    outlierValues.add( new OutlierValue( new DeflatedDataValue( dataValue ), lowerBound, upperBound ) );
-                }
-            }
-        }        
-
         return outlierValues;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisServiceTest.java'
--- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisServiceTest.java	2009-11-24 17:34:15 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisServiceTest.java	2009-11-24 17:53:40 +0000
@@ -51,7 +51,6 @@
 import org.hisp.dhis.period.MonthlyPeriodType;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -104,7 +103,7 @@
     public void setUpTest()
         throws Exception
     {
-        minMaxOutlierAnalysisService = (MinMaxOutlierAnalysisService) getBean( "org.hisp.dhis.outlieranalysis.MinMaxOutlierAnalysisService" );
+        minMaxOutlierAnalysisService = (OutlierAnalysisService) getBean( "org.hisp.dhis.outlieranalysis.MinMaxOutlierAnalysisService" );
 
         dataElementService = (DataElementService) getBean( DataElementService.ID );
 
@@ -167,7 +166,6 @@
     // ----------------------------------------------------------------------
 
     @Test
-    @Ignore //TODO
     public void testGetFindOutliers()
     {
         // testvalues = [5, 5, -5, -5, 10, -10, 13, -13, 41, -41]
@@ -201,11 +199,9 @@
         Collection<OutlierValue> result = minMaxOutlierAnalysisService.findOutliers( 
             organisationUnitA, dataElementsA, periods, null );
 
-        Collection<OutlierValue> ref = new ArrayList<OutlierValue>();
-        ref.add( new OutlierValue( new DeflatedDataValue( dataValueA ), minMaxDataElement.getMin(), minMaxDataElement.getMax() ) );
-        ref.add( new OutlierValue( new DeflatedDataValue( dataValueB ), minMaxDataElement.getMin(), minMaxDataElement.getMax() ) );
-
         assertEquals( 2, result.size() );
-        assertEquals( ref, result );
+        equals( result,
+            new OutlierValue( new DeflatedDataValue( dataValueA ), minMaxDataElement.getMin(), minMaxDataElement.getMax() ),
+            new OutlierValue( new DeflatedDataValue( dataValueB ), minMaxDataElement.getMin(), minMaxDataElement.getMax() ) );
     }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java	2009-11-01 20:57:16 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/dbms/HibernateDbmsManager.java	2009-11-24 17:53:40 +0000
@@ -113,6 +113,7 @@
         emptyTable( "datasetmembers" );        
         emptyTable( "dataset" );
 
+        emptyTable( "minmaxdataelement" );
         emptyTable( "expressiondataelement" );
         emptyTable( "calculateddataelement" );
         emptyTable( "dataelementgroupsetmembers" );