=== 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 outlierValues = new ArrayList(); - final Collection 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 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 result = minMaxOutlierAnalysisService.findOutliers( organisationUnitA, dataElementsA, periods, null ); - Collection ref = new ArrayList(); - 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" );