← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13935: Support for org unit group counts in indicators, done

 

------------------------------------------------------------
revno: 13935
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-02-04 23:38:37 +0200
message:
  Support for org unit group counts in indicators, done
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/DimensionItem.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	2014-02-04 14:46:45 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2014-02-04 21:38:37 +0000
@@ -729,7 +729,7 @@
             
             ListUtils.removeAll( keys, ougInx );
 
-            String permKey = StringUtils.join( keys, DIMENSION_SEP );
+            String permKey = StringUtils.trimToNull( StringUtils.join( keys, DIMENSION_SEP ) );
             
             Integer count = orgUnitCountMap.get( key ).intValue();
             

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DimensionItem.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DimensionItem.java	2014-02-04 08:24:06 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DimensionItem.java	2014-02-04 21:38:37 +0000
@@ -145,6 +145,27 @@
         
         return null;
     }
+
+    /**
+     * Returns the organisation unit dimension item object from the given list of
+     * dimension items. If no items are given, items are null or there are no 
+     * period dimension, null is returned.
+     */
+    public static NameableObject getOrganisationUnitItem( List<DimensionItem> items )
+    {
+        if ( items != null && !items.isEmpty() )
+        {
+            for ( DimensionItem item : items )
+            {
+                if ( DimensionalObject.ORGUNIT_DIM_ID.equals( item.getDimension() ) )
+                {
+                    return item.getItem();
+                }
+            }
+        }
+        
+        return null;
+    }
     
     // -------------------------------------------------------------------------
     // hashCode, equals and toString

=== 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	2014-02-04 14:46:45 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2014-02-04 21:38:37 +0000
@@ -247,6 +247,8 @@
 
             Period filterPeriod = dataSourceParams.getFilterPeriod();
 
+            Map<String, Map<String, Integer>> permutationOrgUnitTargetMap = getOrgUnitTargetMap( dataSourceParams, indicators );
+            
             for ( Indicator indicator : indicators )
             {
                 for ( List<DimensionItem> options : dimensionItemPermutations )
@@ -264,7 +266,13 @@
                     
                     int days = daysBetween( period.getStartDate(), period.getEndDate() );
                     
-                    Double value = expressionService.getIndicatorValue( indicator, period, valueMap, constantMap, null, days ); //TODO oug
+                    OrganisationUnit unit = (OrganisationUnit) DimensionItem.getOrganisationUnitItem( options );
+                    
+                    String ou = unit != null ? unit.getUid() : null;
+                    
+                    Map<String, Integer> orgUnitCountMap = permutationOrgUnitTargetMap != null ? permutationOrgUnitTargetMap.get( ou ) : null;
+                    
+                    Double value = expressionService.getIndicatorValue( indicator, period, valueMap, constantMap, orgUnitCountMap, days );
 
                     if ( value != null )
                     {