dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03277
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1110: Work in progress on outlier analysis.
------------------------------------------------------------
revno: 1110
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Tue 2009-11-24 15:30:46 +0100
message:
Work in progress on outlier analysis.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierAnalysisService.java
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/resources/META-INF/dhis/beans.xml
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/StdDevOutlierAnalysisServiceTest.java
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/webapp/dhis-web-validationrule/outlierForm.vm
--
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-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2009-11-10 11:45:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2009-11-24 14:30:46 +0000
@@ -162,7 +162,7 @@
* OrganisationUnit. Both root and target OrganisationUnits are included in
* the returned collection.
*
- * @param id the id of the OrganisationUnit to trace backwards from.
+ * @param id the id of the OrganisationUnit to trace upwards from.
* @return the list of OrganisationUnits from a root to the given
* OrganisationUnit, or an empty list if the given OrganisationUnit
* doesn't exist.
=== modified 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-11-24 14:09:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/outlieranalysis/OutlierAnalysisService.java 2009-11-24 14:30:46 +0000
@@ -53,13 +53,13 @@
* outliers.
*
* @param organisationUnits The organisation units.
- * @param dataElements The DataElements.
+ * @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<OutlierValue> findOutliers( Collection<? extends OrganisationUnit> organisationUnits, Collection<DataElement> dataElements,
+ Collection<OutlierValue> findOutliers( OrganisationUnit organisationUnit, Collection<DataElement> dataElements,
Collection<Period> periods, Double stdDevFactor );
}
=== 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 14:09:45 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/java/org/hisp/dhis/outlieranalysis/AbstractOutlierAnalysisService.java 2009-11-24 14:30:46 +0000
@@ -29,11 +29,10 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Queue;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
/**
@@ -43,26 +42,43 @@
public abstract class AbstractOutlierAnalysisService
implements OutlierAnalysisService
{
- public final Collection<OutlierValue> findOutliers( Collection<? extends OrganisationUnit> organisationUnits,
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private OrganisationUnitService organisationUnitService;
+
+ public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
+ {
+ this.organisationUnitService = organisationUnitService;
+ }
+
+ // -------------------------------------------------------------------------
+ // OutlierAnalysisService implementation
+ // -------------------------------------------------------------------------
+
+ public final Collection<OutlierValue> findOutliers( OrganisationUnit organisationUnit,
Collection<DataElement> dataElements, Collection<Period> periods, Double stdDevFactor )
{
- final Queue<OrganisationUnit> organisationUnitQueue = new LinkedList<OrganisationUnit>( organisationUnits );
+ Collection<OrganisationUnit> units = organisationUnitService.getOrganisationUnitWithChildren( organisationUnit.getId() );
+
final Collection<OutlierValue> outlierCollection = new ArrayList<OutlierValue>();
- while ( !organisationUnitQueue.isEmpty() )
+ for ( OrganisationUnit unit : units )
{
- final OrganisationUnit organisationUnit = organisationUnitQueue.remove();
- organisationUnitQueue.addAll( organisationUnit.getChildren() );
-
for ( DataElement dataElement : dataElements )
{
- outlierCollection.addAll( findOutliers( organisationUnit, dataElement, periods, stdDevFactor ) );
+ outlierCollection.addAll( findOutliers( unit, dataElement, periods, stdDevFactor ) );
}
}
return outlierCollection;
}
-
+
+ // -------------------------------------------------------------------------
+ // Abstract methods
+ // -------------------------------------------------------------------------
+
protected abstract Collection<OutlierValue> findOutliers( OrganisationUnit organisationUnit,
DataElement dataElement, Collection<Period> periods, Double stdDevFactor );
}
=== modified file 'dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml 2009-10-18 22:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/main/resources/META-INF/dhis/beans.xml 2009-11-24 14:30:46 +0000
@@ -98,12 +98,16 @@
<bean id="org.hisp.dhis.outlieranalysis.StdDevOutlierAnalysisService"
class="org.hisp.dhis.outlieranalysis.StdDevOutlierAnalysisService">
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
<property name="dataValueService"
ref="org.hisp.dhis.datavalue.DataValueService"/>
</bean>
<bean id="org.hisp.dhis.outlieranalysis.MinMaxOutlierAnalysisService"
class="org.hisp.dhis.outlieranalysis.MinMaxOutlierAnalysisService">
+ <property name="organisationUnitService"
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
<property name="minMaxDataElementService"
ref="org.hisp.dhis.minmax.MinMaxDataElementService" />
<property name="dataValueService"
=== 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-10-18 22:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/outlieranalysis/MinMaxOutlierAnalysisServiceTest.java 2009-11-24 14:30:46 +0000
@@ -92,10 +92,6 @@
private OrganisationUnit organisationUnitA;
- private OrganisationUnit organisationUnitB;
-
- private Set<OrganisationUnit> organisationUnitsA = new HashSet<OrganisationUnit>();
-
private MinMaxDataElement minMaxDataElement;
// ----------------------------------------------------------------------
@@ -154,13 +150,8 @@
periodJ = createPeriod( new MonthlyPeriodType(), getDate( 2000, 12, 1 ), getDate( 2000, 12, 30 ) );
organisationUnitA = createOrganisationUnit( 'A' );
- organisationUnitB = createOrganisationUnit( 'B' );
organisationUnitService.addOrganisationUnit( organisationUnitA );
- organisationUnitService.addOrganisationUnit( organisationUnitB );
-
- organisationUnitsA.add( organisationUnitA );
- organisationUnitsA.add( organisationUnitB );
}
// ----------------------------------------------------------------------
@@ -199,7 +190,7 @@
periods.add( periodE );
Collection<OutlierValue> result = minMaxOutlierAnalysisService.findOutliers(
- organisationUnitsA, dataElementsA, periods, null );
+ organisationUnitA, dataElementsA, periods, null );
Collection<OutlierValue> ref = new ArrayList<OutlierValue>();
ref.add( new OutlierValue( dataValueA, 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-10-18 22:44:41 +0000
+++ dhis-2/dhis-services/dhis-service-administration/src/test/java/org/hisp/dhis/outlieranalysis/StdDevOutlierAnalysisServiceTest.java 2009-11-24 14:30:46 +0000
@@ -87,9 +87,6 @@
private Period periodJ;
private OrganisationUnit organisationUnitA;
- private OrganisationUnit organisationUnitB;
-
- private Set<OrganisationUnit> organisationUnitsA = new HashSet<OrganisationUnit>();
// ----------------------------------------------------------------------
// Fixture
@@ -144,13 +141,8 @@
periodJ = createPeriod( new MonthlyPeriodType(), getDate( 2000, 12, 1 ), getDate( 2000, 12, 30 ) );
organisationUnitA = createOrganisationUnit( 'A' );
- organisationUnitB = createOrganisationUnit( 'B' );
organisationUnitService.addOrganisationUnit( organisationUnitA );
- organisationUnitService.addOrganisationUnit( organisationUnitB );
-
- organisationUnitsA.add( organisationUnitA );
- organisationUnitsA.add( organisationUnitB );
}
// ----------------------------------------------------------------------
@@ -186,7 +178,7 @@
periods.add( periodE );
Collection<OutlierValue> result = stdDevOutlierAnalysisService.findOutliers(
- organisationUnitsA, dataElementsA, periods, stdDevFactor );
+ organisationUnitA, dataElementsA, periods, stdDevFactor );
Collection<OutlierValue> ref = new ArrayList<OutlierValue>();
ref.add( new OutlierValue( dataValueA, -34.51 * stdDevFactor, 34.51 * stdDevFactor ) );
=== 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-10-10 14:26:24 +0000
+++ 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
@@ -162,11 +162,11 @@
return new ArrayList<DataElement>( this.dataElements );
}
- private Collection<OrganisationUnit> sources = null;
+ private OrganisationUnit source;
- public Collection<OrganisationUnit> getSources()
+ public OrganisationUnit getSource()
{
- return (sources == null ? new ArrayList<OrganisationUnit>(0) : sources);
+ return source;
}
private String outlierType;
@@ -221,7 +221,7 @@
dataElements = dataElementService.getDataElements( ConversionUtils.getIntegerCollection( dataElementsById ) );
- sources = selectionTreeManager.getSelectedOrganisationUnits();
+ source = selectionTreeManager.getSelectedOrganisationUnit();
DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) );
@@ -253,11 +253,11 @@
if ( outlierType.equals( TYPE_MINMAX ) )
{
- outlierValues = minMaxOutlierAnalysisService.findOutliers( sources, dataElements, periods, null );
+ outlierValues = minMaxOutlierAnalysisService.findOutliers( source, dataElements, periods, null );
}
else if ( outlierType.equals( TYPE_STDDEV ) )
{
- outlierValues = stdDevOutlierAnalysisService.findOutliers( sources, dataElements, periods, standardDeviation );
+ outlierValues = stdDevOutlierAnalysisService.findOutliers( source, dataElements, periods, standardDeviation );
}
else
{
=== 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-03 10:54:57 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/outlierForm.vm 2009-11-24 14:30:46 +0000
@@ -80,7 +80,7 @@
<div id="selectionTree" style="width:40em;height:20em;overflow:auto;/*border:1px solid #cccccc*/"></div>
<script type="text/javascript">
- selectionTreeSelection.setMultipleSelectionAllowed( true );
+ selectionTreeSelection.setMultipleSelectionAllowed( false );
// selectionTreeSelection.setOnSelectFunction( treeClicked );
// selectionTreeSelection.setListenerFunction( selectCompleted );
selectionTree.buildSelectionTree();