=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis' === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisService.java 2009-12-23 17:34:18 +0000 @@ -0,0 +1,47 @@ +package org.hisp.dhis.dataanalysis; + +/* + * Copyright (c) 2004-2009, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Collection; + +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.datavalue.DeflatedDataValue; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.period.Period; + +/** + * @author Dag Haavi Finstad + * @version $Id: StdDevOutlierAnalysisService.java 882 2009-05-14 23:09:31Z daghf $ + */ +public interface DataAnalysisService +{ + String ID = DataAnalysisService.class.getName(); + + Collection analyse( OrganisationUnit organisationUnit, Collection dataElements, + Collection periods, Double stdDevFactor ); +} === added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataanalysis/DataAnalysisStore.java 2009-12-23 17:34:18 +0000 @@ -0,0 +1,50 @@ +package org.hisp.dhis.dataanalysis; + +/* + * Copyright (c) 2004-${year}, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Collection; + +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.datavalue.DeflatedDataValue; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodType; + +/** + * @author Lars Helge Overland + */ +public interface DataAnalysisStore +{ + Double getStandardDeviation( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, OrganisationUnit organisationUnit ); + + Double getAverage( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, OrganisationUnit organisationUnit ); + + Collection getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, + Collection periods, OrganisationUnit organisationUnit, PeriodType periodType, int lowerBound, int upperBound ); +} === removed directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis' === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierAnalysisService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierAnalysisService.java 2009-12-23 12:09:02 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierAnalysisService.java 1970-01-01 00:00:00 +0000 @@ -1,66 +0,0 @@ -package org.hisp.dhis.outlieranalysis; - -/* - * Copyright (c) 2004-2009, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; - -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.datavalue.DeflatedDataValue; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.Period; - - -/** - * Defines service functionality for finding outlier DataValues. - * - * @author Dag Haavi Finstad - * @version $Id: StdDevOutlierAnalysisService.java 882 2009-05-14 23:09:31Z daghf $ - * - */ -public interface OutlierAnalysisService -{ - String ID = OutlierAnalysisService.class.getName(); - - /** - * Finds possible outliers for a collection of sources, dataelements and periods. - * - * Checks for every combination in the cartesian product of sources, - * dataelements and periods if the corresponding datavalues are possible - * outliers. - * - * @param organisationUnits The organisation units. - * @param dataElement The DataElement. - * @param period The period. - * @param stdDevFactor The standard deviation factor. - * @return A collection of OutlierValue objects. If no values were found, an - * empty collection is returned. - */ - Collection findOutliers( OrganisationUnit organisationUnit, Collection dataElements, - Collection periods, Double stdDevFactor ); - -} === removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierAnalysisStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierAnalysisStore.java 2009-12-23 17:00:56 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierAnalysisStore.java 1970-01-01 00:00:00 +0000 @@ -1,50 +0,0 @@ -package org.hisp.dhis.outlieranalysis; - -/* - * Copyright (c) 2004-${year}, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; - -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.datavalue.DeflatedDataValue; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.period.PeriodType; - -/** - * @author Lars Helge Overland - */ -public interface OutlierAnalysisStore -{ - Double getStandardDeviation( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, OrganisationUnit organisationUnit ); - - Double getAverage( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, OrganisationUnit organisationUnit ); - - Collection getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, - Collection periods, OrganisationUnit organisationUnit, PeriodType periodType, int lowerBound, int upperBound ); -} === renamed directory 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/outlieranalysis' => 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis' === 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/outlieranalysis/MinMaxOutlierAnalysisService.java 2009-12-23 17:00:56 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxOutlierAnalysisService.java 2009-12-23 17:34:18 +0000 @@ -1,4 +1,4 @@ -package org.hisp.dhis.outlieranalysis; +package org.hisp.dhis.dataanalysis; /* * Copyright (c) 2004-${year}, University of Oslo @@ -44,7 +44,7 @@ * @author Lars Helge Overland */ public class MinMaxOutlierAnalysisService - implements OutlierAnalysisService + implements DataAnalysisService { // ------------------------------------------------------------------------- // Dependencies @@ -64,18 +64,18 @@ this.organisationUnitService = organisationUnitService; } - private OutlierAnalysisStore outlierAnalysisStore; + private DataAnalysisStore dataAnalysisStore; - public void setOutlierAnalysisStore( OutlierAnalysisStore outlierAnalysisStore ) + public void setDataAnalysisStore( DataAnalysisStore dataAnalysisStore ) { - this.outlierAnalysisStore = outlierAnalysisStore; + this.dataAnalysisStore = dataAnalysisStore; } - + // ------------------------------------------------------------------------- // MinMaxOutlierAnalysisService implementation // ------------------------------------------------------------------------- - public final Collection findOutliers( OrganisationUnit organisationUnit, + public final Collection analyse( OrganisationUnit organisationUnit, Collection dataElements, Collection periods, Double stdDevFactor ) { Collection units = organisationUnitService.getOrganisationUnitWithChildren( organisationUnit.getId() ); @@ -114,7 +114,7 @@ if ( minMaxDataElement != null ) { - return outlierAnalysisStore.getDeflatedDataValues( dataElement, categoryOptionCombo, periods, + return dataAnalysisStore.getDeflatedDataValues( dataElement, categoryOptionCombo, periods, organisationUnit, dataElement.getPeriodType(), minMaxDataElement.getMin(), minMaxDataElement.getMax() ); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxValueMap.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/outlieranalysis/MinMaxValueMap.java 2009-12-23 12:54:35 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/MinMaxValueMap.java 2009-12-23 17:34:18 +0000 @@ -1,4 +1,4 @@ -package org.hisp.dhis.outlieranalysis; +package org.hisp.dhis.dataanalysis; /* * Copyright (c) 2004-${year}, University of Oslo === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/outlieranalysis/StdDevOutlierAnalysisService.java 2009-12-23 17:00:56 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/StdDevOutlierAnalysisService.java 2009-12-23 17:34:18 +0000 @@ -1,4 +1,4 @@ -package org.hisp.dhis.outlieranalysis; +package org.hisp.dhis.dataanalysis; /* * Copyright (c) 2004-${year}, University of Oslo @@ -44,17 +44,17 @@ * @author Lars Helge Overland */ public class StdDevOutlierAnalysisService - implements OutlierAnalysisService + implements DataAnalysisService { // ------------------------------------------------------------------------- // Dependencies // ------------------------------------------------------------------------- - private OutlierAnalysisStore outlierAnalysisStore; + private DataAnalysisStore dataAnalysisStore; - public void setOutlierAnalysisStore( OutlierAnalysisStore outlierAnalysisStore ) + public void setDataAnalysisStore( DataAnalysisStore dataAnalysisStore ) { - this.outlierAnalysisStore = outlierAnalysisStore; + this.dataAnalysisStore = dataAnalysisStore; } private OrganisationUnitService organisationUnitService; @@ -68,7 +68,7 @@ // OutlierAnalysisService implementation // ------------------------------------------------------------------------- - public final Collection findOutliers( OrganisationUnit organisationUnit, + public final Collection analyse( OrganisationUnit organisationUnit, Collection dataElements, Collection periods, Double stdDevFactor ) { Collection units = organisationUnitService.getOrganisationUnitWithChildren( organisationUnit.getId() ); @@ -101,17 +101,17 @@ private Collection findOutliers( OrganisationUnit organisationUnit, DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, Collection periods, Double stdDevFactor ) { - Double stdDev = outlierAnalysisStore.getStandardDeviation( dataElement, categoryOptionCombo, organisationUnit ); + Double stdDev = dataAnalysisStore.getStandardDeviation( dataElement, categoryOptionCombo, organisationUnit ); if ( !isEqual( stdDev, 0.0 ) ) // No values found or no outliers exist when 0.0 { - Double avg = outlierAnalysisStore.getAverage( dataElement, categoryOptionCombo, organisationUnit ); + Double avg = dataAnalysisStore.getAverage( dataElement, categoryOptionCombo, organisationUnit ); double deviation = stdDev * stdDevFactor; Double lowerBound = avg - deviation; Double upperBound = avg + deviation; - return outlierAnalysisStore.getDeflatedDataValues( dataElement, categoryOptionCombo, periods, + return dataAnalysisStore.getDeflatedDataValues( dataElement, categoryOptionCombo, periods, organisationUnit, dataElement.getPeriodType(), lowerBound.intValue(), upperBound.intValue() ); } === renamed file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/outlieranalysis/jdbc/JdbcOutlierAnalysisStore.java' => 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/outlieranalysis/jdbc/JdbcOutlierAnalysisStore.java 2009-12-23 17:00:56 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataanalysis/jdbc/JdbcDataAnalysisStore.java 2009-12-23 17:34:18 +0000 @@ -1,4 +1,4 @@ -package org.hisp.dhis.outlieranalysis.jdbc; +package org.hisp.dhis.dataanalysis.jdbc; /* * Copyright (c) 2004-${year}, University of Oslo @@ -34,12 +34,12 @@ import org.amplecode.quick.StatementHolder; import org.amplecode.quick.StatementManager; import org.amplecode.quick.mapper.ObjectMapper; +import org.hisp.dhis.dataanalysis.DataAnalysisStore; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.datavalue.DeflatedDataValue; import org.hisp.dhis.jdbc.StatementBuilder; import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.outlieranalysis.OutlierAnalysisStore; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.system.objectmapper.DeflatedDataValueNameMinMaxRowMapper; @@ -49,8 +49,8 @@ /** * @author Lars Helge Overland */ -public class JdbcOutlierAnalysisStore - implements OutlierAnalysisStore +public class JdbcDataAnalysisStore + implements DataAnalysisStore { // ------------------------------------------------------------------------- // Dependencies === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2009-12-23 12:54:35 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2009-12-23 17:34:18 +0000 @@ -169,8 +169,8 @@ - + @@ -323,22 +323,22 @@ ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupSetStore"/> - + - + - + - + @@ -616,7 +616,7 @@ - +