=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierValue.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierValue.java 2009-11-24 17:34:15 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierValue.java 2009-11-25 15:56:24 +0000 @@ -27,7 +27,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import org.hisp.dhis.datavalue.DeflatedDataValue; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.datavalue.DataValue; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.period.Period; /** * The OutlierValue class wraps an outlier DataValue. The value is outside of @@ -39,105 +43,154 @@ */ public class OutlierValue { - /** - * Outlier datavalue. - */ - private DeflatedDataValue outlier; + private DataElement dataElement; + + private Period period; + + private OrganisationUnit organisationUnit; + + private DataElementCategoryOptionCombo categoryOptionCombo; + + private double value; - /** - * Lower bound. This is the lower cut-off point for - * whether a value is considered an outlier or not. - */ private double lowerBound; - /** - * Upper boundary. - */ private double upperBound; // ------------------------------------------------------------------------- // Constructor // ------------------------------------------------------------------------- - public OutlierValue( DeflatedDataValue outlier, double lowerBound, double upperBound ) - { - this.outlier = outlier; - this.lowerBound = lowerBound; - this.upperBound = upperBound; - } - + public OutlierValue( DataElement dataElement, Period period, OrganisationUnit organisationUnit, + DataElementCategoryOptionCombo categoryOptionCombo, double value, double lowerBound, double upperBound ) + { + this.dataElement = dataElement; + this.period = period; + this.organisationUnit = organisationUnit; + this.categoryOptionCombo = categoryOptionCombo; + this.value = value; + this.lowerBound = lowerBound; + this.upperBound = upperBound; + } + + public OutlierValue( DataValue dataValue, double lowerBound, double upperBound ) + { + this.dataElement = dataValue.getDataElement(); + this.period = dataValue.getPeriod(); + this.organisationUnit = (OrganisationUnit) dataValue.getSource(); + this.categoryOptionCombo = dataValue.getOptionCombo(); + this.value = Double.valueOf( dataValue.getValue() ); + this.lowerBound = lowerBound; + this.upperBound = upperBound; + } + + // ------------------------------------------------------------------------- + // Logic + // ------------------------------------------------------------------------- + + public String getLowerBoundFormatted() + { + return String.format("%.2f", lowerBound); + } + + + public String getUpperBoundFormatted() + { + return String.format("%.2f", upperBound); + } + // ------------------------------------------------------------------------- // Setters and getters // ------------------------------------------------------------------------- - /** - * Returns the lower bound. The value is either smaller than the lower - * bound, or bigger than the upper bound. - * - * @return The lower bound for non-outlier values. - */ + public DataElement getDataElement() + { + return dataElement; + } + + public void setDataElement( DataElement dataElement ) + { + this.dataElement = dataElement; + } + + public Period getPeriod() + { + return period; + } + + public void setPeriod( Period period ) + { + this.period = period; + } + + public OrganisationUnit getOrganisationUnit() + { + return organisationUnit; + } + + public void setOrganisationUnit( OrganisationUnit organisationUnit ) + { + this.organisationUnit = organisationUnit; + } + + public DataElementCategoryOptionCombo getCategoryOptionCombo() + { + return categoryOptionCombo; + } + + public void setCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo ) + { + this.categoryOptionCombo = categoryOptionCombo; + } + + public double getValue() + { + return value; + } + + public void setValue( double value ) + { + this.value = value; + } + public double getLowerBound() { return lowerBound; } - /** - * Returns the upper bound. - * - * @see OutlierCollection#getLowerBound() - * @return The upper bound for non-outlier values. - */ + public void setLowerBound( double lowerBound ) + { + this.lowerBound = lowerBound; + } + public double getUpperBound() { return upperBound; } - - public String getLowerBoundFormatted() { - return String.format("%.2f", lowerBound); - } - - - public String getUpperBoundFormatted() { - return String.format("%.2f", upperBound); - } - - /** - * Returns the outlier. - * - * @return The outlier DataValue. - */ - public DeflatedDataValue getOutlier() - { - return outlier; - } - - /** - * Sets the outlier DataValue. - * - * @param outlier An outlier DataValue. - */ - public void setOutlier( DeflatedDataValue outlier ) - { - this.outlier = outlier; - } - - /** - * @param lowerBound the lowerBound to set - */ - public void setLowerBound( double lowerBound ) - { - this.lowerBound = lowerBound; - } - - /** - * @param upperBound the upperBound to set - */ public void setUpperBound( double upperBound ) { this.upperBound = upperBound; } + // ------------------------------------------------------------------------- + // hashCode and equals + // ------------------------------------------------------------------------- + + @Override + public int hashCode() + { + final int prime = 31; + int result = 1; + + result = prime * result + ( ( categoryOptionCombo == null ) ? 0 : categoryOptionCombo.hashCode() ); + result = prime * result + ( ( dataElement == null ) ? 0 : dataElement.hashCode() ); + result = prime * result + ( ( organisationUnit == null ) ? 0 : organisationUnit.hashCode() ); + result = prime * result + ( ( period == null ) ? 0 : period.hashCode() ); + + return result; + } + @Override public boolean equals( Object o ) { @@ -158,12 +211,7 @@ final OutlierValue other = (OutlierValue) o; - return outlier.equals( other.outlier ) && lowerBound == other.lowerBound && upperBound == other.upperBound; - } - - @Override - public int hashCode() - { - return outlier.hashCode(); + return dataElement.equals( other.dataElement ) && period.equals( other.period ) && + organisationUnit.equals( other.organisationUnit ) && categoryOptionCombo.equals( other.categoryOptionCombo ); } } === modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/AbstractOutlierAnalysisService.java' --- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/AbstractOutlierAnalysisService.java 2009-11-24 17:34:15 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/AbstractOutlierAnalysisService.java 2009-11-25 15:56:24 +0000 @@ -29,12 +29,14 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Map; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.Period; +import org.hisp.dhis.system.util.ConversionUtils; /** * @author Dag Haavi Finstad @@ -63,7 +65,11 @@ { Collection units = organisationUnitService.getOrganisationUnitWithChildren( organisationUnit.getId() ); - final Collection outlierCollection = new ArrayList(); + Map dataElementMap = ConversionUtils.getIdentifierMap( dataElements ); + Map periodMap = ConversionUtils.getIdentifierMap( periods ); + Map organisationUnitMap = ConversionUtils.getIdentifierMap( units ); + + Collection outlierCollection = new ArrayList(); for ( OrganisationUnit unit : units ) { @@ -73,9 +79,12 @@ { Collection categoryOptionCombos = dataElement.getCategoryCombo().getOptionCombos(); + Map categoryOptionComboMap = ConversionUtils.getIdentifierMap( categoryOptionCombos ); + for ( DataElementCategoryOptionCombo categoryOptionCombo : categoryOptionCombos ) { - outlierCollection.addAll( findOutliers( unit, dataElement, categoryOptionCombo, periods, stdDevFactor ) ); + outlierCollection.addAll( findOutliers( unit, dataElement, categoryOptionCombo, periods, stdDevFactor, + dataElementMap, periodMap, organisationUnitMap, categoryOptionComboMap ) ); } } } @@ -89,5 +98,7 @@ // ------------------------------------------------------------------------- protected abstract Collection findOutliers( OrganisationUnit organisationUnit, - DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, Collection periods, Double stdDevFactor ); + DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, Collection periods, Double stdDevFactor, + Map dataElementMap, Map periodMap, Map organisationUnitMap, + Map categoryOptionComboMap ); } === 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:53:40 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisService.java 2009-11-25 15:56:24 +0000 @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Map; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; @@ -70,8 +71,10 @@ // MinMaxOutlierAnalysisService implementation // ------------------------------------------------------------------------- - public Collection findOutliers( OrganisationUnit organisationUnit, DataElement dataElement, - DataElementCategoryOptionCombo categoryOptionCombo, Collection periods, Double stdDevFactor ) + public Collection findOutliers( OrganisationUnit organisationUnit, + DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, Collection periods, Double stdDevFactor, + Map dataElementMap, Map periodMap, Map organisationUnitMap, + Map categoryOptionComboMap ) { final Collection outlierValues = new ArrayList(); @@ -83,11 +86,13 @@ double upperBound = minMaxDataElement.getMax(); Collection outliers = outlierAnalysisStore. - getDeflatedDataValues( dataElement, categoryOptionCombo, organisationUnit, lowerBound, upperBound ); + getDeflatedDataValues( dataElement, categoryOptionCombo, periods, organisationUnit, lowerBound, upperBound ); for ( DeflatedDataValue outlier : outliers ) { - outlierValues.add( new OutlierValue( outlier, lowerBound, upperBound ) ); + outlierValues.add( new OutlierValue( dataElementMap.get( outlier.getDataElementId() ), periodMap.get( outlier.getPeriodId() ), + organisationUnitMap.get( outlier.getSourceId() ), categoryOptionComboMap.get( outlier.getCategoryOptionComboId() ), + Double.valueOf( outlier.getValue() ), lowerBound, upperBound ) ); } } === modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/StdDevOutlierAnalysisService.java' --- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/StdDevOutlierAnalysisService.java 2009-11-24 17:34:15 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/StdDevOutlierAnalysisService.java 2009-11-25 15:56:24 +0000 @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Map; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; @@ -64,13 +65,15 @@ // ------------------------------------------------------------------------- public Collection findOutliers( OrganisationUnit organisationUnit, DataElement dataElement, - DataElementCategoryOptionCombo categoryOptionCombo, Collection periods, Double stdDevFactor ) + DataElementCategoryOptionCombo categoryOptionCombo, Collection periods, Double stdDevFactor, + Map dataElementMap, Map periodMap, Map organisationUnitMap, + Map categoryOptionComboMap) { final Collection outlierValues = new ArrayList(); Double stdDev = outlierAnalysisStore.getStandardDeviation( dataElement, categoryOptionCombo, organisationUnit ); - if ( !isEqual( stdDev, 0.0 ) ) // If 0.0 no values found or no outliers exist + if ( !isEqual( stdDev, 0.0 ) ) // No values found or no outliers exist when 0.0 { Double avg = outlierAnalysisStore.getAverage( dataElement, categoryOptionCombo, organisationUnit ); @@ -79,11 +82,13 @@ double upperBound = avg + deviation; Collection outliers = outlierAnalysisStore. - getDeflatedDataValues( dataElement, categoryOptionCombo, organisationUnit, lowerBound, upperBound ); + getDeflatedDataValues( dataElement, categoryOptionCombo, periods, organisationUnit, lowerBound, upperBound ); for ( DeflatedDataValue outlier : outliers ) { - outlierValues.add( new OutlierValue( outlier, lowerBound, upperBound ) ); + outlierValues.add( new OutlierValue( dataElementMap.get( outlier.getDataElementId() ), periodMap.get( outlier.getPeriodId() ), + organisationUnitMap.get( outlier.getSourceId() ), categoryOptionComboMap.get( outlier.getCategoryOptionComboId() ), + Double.valueOf( outlier.getValue() ), lowerBound, upperBound ) ); } } === modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/jdbc/JdbcOutlierAnalysisStore.java' --- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/jdbc/JdbcOutlierAnalysisStore.java 2009-11-24 17:34:15 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/jdbc/JdbcOutlierAnalysisStore.java 2009-11-25 15:56:24 +0000 @@ -38,8 +38,11 @@ import org.hisp.dhis.datavalue.DeflatedDataValue; import org.hisp.dhis.jdbc.StatementBuilder; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.period.Period; import org.hisp.dhis.system.objectmapper.DeflatedDataValueRowMapper; import org.hisp.dhis.system.objectmapper.ObjectMapper; +import org.hisp.dhis.system.util.ConversionUtils; +import org.hisp.dhis.system.util.TextUtils; /** * @author Lars Helge Overland @@ -84,18 +87,21 @@ } public Collection getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, - OrganisationUnit organisationUnit, double lowerBound, double upperBound ) + Collection periods, OrganisationUnit organisationUnit, double lowerBound, double upperBound ) { final StatementHolder holder = statementManager.getHolder(); final ObjectMapper mapper = new ObjectMapper(); + final String periodIds = TextUtils.getCommaDelimitedString( ConversionUtils.getIdentifiers( Period.class, periods ) ); + try { final String sql = "SELECT * FROM datavalue " + "WHERE dataelementid='" + dataElement.getId() + "' " + "AND categoryoptioncomboid='" + categoryOptionCombo.getId() + "' " + + "AND periodid IN (" + periodIds + ") " + "AND sourceid='" + organisationUnit.getId() + "' " + "AND ( CAST( value AS " + statementBuilder.getDoubleColumnType() + " ) < '" + lowerBound + "' " + "OR CAST( value AS " + statementBuilder.getDoubleColumnType() + " ) > '" + upperBound + "' )"; === modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/jdbc/OutlierAnalysisStore.java' --- dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/jdbc/OutlierAnalysisStore.java 2009-11-24 17:34:15 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/jdbc/OutlierAnalysisStore.java 2009-11-25 15:56:24 +0000 @@ -33,6 +33,7 @@ import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.datavalue.DeflatedDataValue; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.period.Period; /** * @author Lars Helge Overland @@ -44,5 +45,5 @@ Double getAverage( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, OrganisationUnit organisationUnit ); Collection getDeflatedDataValues( DataElement dataElement, DataElementCategoryOptionCombo categoryOptionCombo, - OrganisationUnit organisationUnit, double lowerBound, double upperBound ); + Collection periods, OrganisationUnit organisationUnit, double lowerBound, double upperBound ); } === 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:53:40 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisServiceTest.java 2009-11-25 15:56:24 +0000 @@ -43,7 +43,6 @@ import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.datavalue.DataValueService; -import org.hisp.dhis.datavalue.DeflatedDataValue; import org.hisp.dhis.minmax.MinMaxDataElement; import org.hisp.dhis.minmax.MinMaxDataElementService; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -201,7 +200,7 @@ assertEquals( 2, result.size() ); equals( result, - new OutlierValue( new DeflatedDataValue( dataValueA ), minMaxDataElement.getMin(), minMaxDataElement.getMax() ), - new OutlierValue( new DeflatedDataValue( dataValueB ), minMaxDataElement.getMin(), minMaxDataElement.getMax() ) ); + new OutlierValue( dataValueA, minMaxDataElement.getMin(), minMaxDataElement.getMax() ), + new OutlierValue( dataValueB, minMaxDataElement.getMin(), minMaxDataElement.getMax() ) ); } } === modified file 'dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/outlieranalysis/StdDevOutlierAnalysisServiceTest.java' --- dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/outlieranalysis/StdDevOutlierAnalysisServiceTest.java 2009-11-24 17:34:15 +0000 +++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/outlieranalysis/StdDevOutlierAnalysisServiceTest.java 2009-11-25 15:56:24 +0000 @@ -43,7 +43,6 @@ import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.datavalue.DataValueService; -import org.hisp.dhis.datavalue.DeflatedDataValue; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.MonthlyPeriodType; @@ -187,7 +186,7 @@ assertEquals( 2, result.size() ); equals( result, - new OutlierValue( new DeflatedDataValue( dataValueA ), lowerBound, upperBound ), - new OutlierValue( new DeflatedDataValue( dataValueB ), lowerBound, upperBound ) ); + new OutlierValue( dataValueA, lowerBound, upperBound ), + new OutlierValue( dataValueB, lowerBound, upperBound ) ); } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java 2009-11-25 09:08:11 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java 2009-11-25 15:56:24 +0000 @@ -158,6 +158,7 @@ return query.executeUpdate(); } + @Deprecated public DataValue getDataValue( Source source, DataElement dataElement, Period period ) { Session session = sessionFactory.getCurrentSession(); === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java 2009-11-23 11:51:03 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/ConversionUtils.java 2009-11-25 15:56:24 +0000 @@ -30,8 +30,10 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -42,6 +44,7 @@ { /** * Creates a collection of the identifiers of the objects passed as argument. + * The object are assumed to have a int getId() method. * * @param clazz the clazz of the argument objects. * @param objects for which to get the identifiers. @@ -68,6 +71,26 @@ throw new RuntimeException( "Failed to convert objects", ex ); } } + /** + * Returns the identifier of the argument object. The object is assumed to + * have a int getId() method. + * + * @param object the object. + * @return the identifier of the argument object. + */ + public static Integer getIdentifier( Object object ) + { + try + { + Method method = object.getClass().getMethod( "getId", new Class[ 0 ] ); + + return (Integer) method.invoke( object, new Object[ 0 ] ); + } + catch ( Exception ex ) + { + throw new RuntimeException( "Failed to convert object", ex ); + } + } /** * Creates a collection of Integers out of a collection of Strings. @@ -164,4 +187,23 @@ return list; } + + /** + * Returns a Map based on an argument Collection of objects where the key is + * the object identifier and the value if the object itself. + * + * @param collection the Collection of objects. + * @return a Map with identifier object pairs. + */ + public static Map getIdentifierMap( Collection collection ) + { + Map map = new HashMap(); + + for ( T object : collection ) + { + map.put( getIdentifier( object ), object ); + } + + return map; + } } === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/outlieranalysis/GetOutliersAction.java' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/outlieranalysis/GetOutliersAction.java 2009-11-24 14:30:46 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/java/org/hisp/dhis/validationrule/action/outlieranalysis/GetOutliersAction.java 2009-11-25 15:56:24 +0000 @@ -27,7 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; @@ -141,6 +140,10 @@ this.fromDateString = fromDate.trim(); } + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + private String dataSetId; public void setDataset( String dataSet ) @@ -155,20 +158,6 @@ this.dataElementsById = dataElementsById; } - private Collection dataElements; - - public List getDataElements() - { - return new ArrayList( this.dataElements ); - } - - private OrganisationUnit source; - - public OrganisationUnit getSource() - { - return source; - } - private String outlierType; public void setOutlierType( String outlierType ) @@ -176,20 +165,6 @@ this.outlierType = outlierType; } - public String getOutlierType() - { - if ( outlierType.equals( TYPE_MINMAX ) ) - { - return "Min-max"; - } - if ( outlierType.equals( TYPE_STDDEV ) ) - { - return "Standard deviation"; - } - - return ""; - } - private Double standardDeviation; public void setStandardDeviation( Double standardDeviation ) @@ -197,6 +172,10 @@ this.standardDeviation = standardDeviation; } + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + private Collection outlierValues; public Collection getOutlierValues() @@ -210,7 +189,7 @@ { return searchTime; } - + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -219,9 +198,9 @@ { long startTime = System.currentTimeMillis(); - dataElements = dataElementService.getDataElements( ConversionUtils.getIntegerCollection( dataElementsById ) ); + Collection dataElements = dataElementService.getDataElements( ConversionUtils.getIntegerCollection( dataElementsById ) ); - source = selectionTreeManager.getSelectedOrganisationUnit(); + OrganisationUnit organisationUnit = selectionTreeManager.getSelectedOrganisationUnit(); DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) ); @@ -253,11 +232,11 @@ if ( outlierType.equals( TYPE_MINMAX ) ) { - outlierValues = minMaxOutlierAnalysisService.findOutliers( source, dataElements, periods, null ); + outlierValues = minMaxOutlierAnalysisService.findOutliers( organisationUnit, dataElements, periods, null ); } else if ( outlierType.equals( TYPE_STDDEV ) ) { - outlierValues = stdDevOutlierAnalysisService.findOutliers( source, dataElements, periods, standardDeviation ); + outlierValues = stdDevOutlierAnalysisService.findOutliers( organisationUnit, dataElements, periods, standardDeviation ); } else { === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties 2009-11-03 10:54:57 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/resources/org/hisp/dhis/validationrule/i18n_module.properties 2009-11-25 15:56:24 +0000 @@ -85,7 +85,7 @@ right_side_description= Right side description value= Value data_element= Data element -organisation_unit = Organisation unit +organisation_unit= Organisation unit period= Period organisation_unit_only= Organisation unit only organisation_unit_with_children= Organisation unit with children @@ -128,6 +128,7 @@ std_dev = Standard Deviation max = Max min = Min +values_found = values found select_std_dev = Select number of standard deviations waiting_for_user_to_choose_dataset = Waiting for user to select a data set select_parent_organisation_unit = Select parent organisation unit === modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/outlierForm.vm' --- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/outlierForm.vm 2009-11-24 14:30:46 +0000 +++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/outlierForm.vm 2009-11-25 15:56:24 +0000 @@ -101,14 +101,14 @@ -