← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 467: Added some missing files in API

 

------------------------------------------------------------
revno: 467
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Sat 2009-07-25 13:04:24 +0200
message:
  Added some missing files in API
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierAnalysisService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierValue.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.
=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis'
=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierAnalysisService.java	2009-07-25 11:04:24 +0000
@@ -0,0 +1,79 @@
+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.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 the datavalues with the selected periods.
+     * 
+     * @param organisationUnit The organisation unit.
+     * @param dataElement The data element.
+     * @param periods The periods.
+     * @param stdDevFactor The standard deviation factor.
+     * 
+     * @return A Collection of OutlierValue objects. An empty collection is
+     *         returned if no outliers were found.
+     */
+    Collection<OutlierValue> findOutliers( OrganisationUnit organisationUnit, DataElement dataElement, Collection<Period> periods,
+        Double stdDevFactor );
+
+    /**
+     * 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 dataElements The DataElements.
+     * @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<OutlierValue> findOutliers( Collection<? extends OrganisationUnit> organisationUnits, Collection<DataElement> dataElements,
+        Collection<Period> periods, Double stdDevFactor );
+
+}

=== added 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	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierValue.java	2009-07-25 11:04:24 +0000
@@ -0,0 +1,169 @@
+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 org.hisp.dhis.datavalue.DataValue;
+
+/**
+ * The OutlierValue class wraps an outlier DataValue. The value is outside of
+ * the interval (getLowerBound(), getUpperBound()).
+ * 
+ * @author Dag Haavi Finstad
+ * @version $Id: OutlierValue.java 1020 2009-06-05 01:30:07Z daghf $
+ * 
+ */
+public class OutlierValue
+{
+    /**
+     * Outlier datavalue.
+     */
+    private DataValue dataValue;
+
+    /**
+     * 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( DataValue outlierValue, double lowerBound, double upperBound )
+    {
+        this.dataValue = outlierValue;
+        this.lowerBound = lowerBound;
+        this.upperBound = 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 double getLowerBound()
+    {
+        return lowerBound;
+    }
+
+    /**
+     * Returns the upper bound.
+     * 
+     * @see OutlierCollection#getLowerBound()
+     * @return The upper bound for non-outlier values.
+     */
+    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 DataValue getOutlier()
+    {
+        return dataValue;
+    }
+
+    /**
+     * Sets the outlier DataValue.
+     * 
+     * @param outlier An outlier DataValue.
+     */
+    public void setOutlier( DataValue outlier )
+    {
+        this.dataValue = outlier;
+    }
+
+    @Override
+    public boolean equals( Object o )
+    {
+        if ( this == o )
+        {
+            return true;
+        }
+
+        if ( o == null )
+        {
+            return false;
+        }
+
+        if ( !(o instanceof OutlierValue) )
+        {
+            return false;
+        }
+
+        final OutlierValue other = (OutlierValue) o;
+
+        return dataValue.equals( other.getOutlier() );
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return dataValue.hashCode();
+    }
+
+    /**
+     * @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;
+    }
+
+}