← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11087: Analytics, fixed bug, annualized indicators did not work properly when period was filter

 

------------------------------------------------------------
revno: 11087
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-05-29 18:06:43 +0200
message:
  Analytics, fixed bug, annualized indicators did not work properly when period was filter
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.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
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2013-05-28 14:34:42 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2013-05-29 16:06:43 +0000
@@ -412,7 +412,7 @@
     }
     
     /**
-     * Returns the period type of the first period specified as filter. Returns
+     * Returns the period type of the first period specified as filter, or
      * null if there is no period filter.
      */
     public PeriodType getFilterPeriodType()
@@ -428,6 +428,22 @@
     }
     
     /**
+     * Returns the first period specified as filter, or null if there is no
+     * period filter.
+     */
+    public Period getFilterPeriod()
+    {
+        List<NameableObject> filterPeriods = getFilterPeriods();
+        
+        if ( filterPeriods != null && !filterPeriods.isEmpty() )
+        {
+            return (Period) filterPeriods.get( 0 );
+        }
+        
+        return null;
+    }
+    
+    /**
      * Returns the number of dimension option permutations. Merges the three data
      * dimensions into one prior to the calculation.
      */

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-05-28 17:05:43 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-05-29 16:06:43 +0000
@@ -221,6 +221,8 @@
 
             Map<String, Double> constantMap = constantService.getConstantMap();
 
+            Period filterPeriod = dataSourceParams.getFilterPeriod();
+            
             for ( Indicator indicator : indicators )
             {
                 for ( List<DimensionItem> options : dimensionItemPermutations )
@@ -231,7 +233,7 @@
                     
                     if ( valueMap != null )
                     {
-                        Period period = (Period) DimensionItem.getPeriodItem( options );
+                        Period period = filterPeriod != null ? filterPeriod : (Period) DimensionItem.getPeriodItem( options );
                         
                         Double value = expressionService.getIndicatorValue( indicator, period, valueMap, constantMap, null );