← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12419: Null check

 

------------------------------------------------------------
revno: 12419
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-10-03 15:24:21 +0200
message:
  Null check
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
  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/event/data/DefaultEventAnalyticsService.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-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2013-10-03 12:17:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2013-10-03 13:24:21 +0000
@@ -620,9 +620,12 @@
     {
         Map<String, String> map = new HashMap<String, String>();
         
-        for ( OrganisationUnit unit : organisationUnits )
+        if ( organisationUnits != null )
         {
-            map.put( unit.getUid(), unit.getParentGraph() );
+            for ( OrganisationUnit unit : organisationUnits )
+            {
+                map.put( unit.getUid(), unit.getParentGraph() );
+            }
         }
         
         return map;

=== 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-10-03 12:17:41 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-10-03 13:24:21 +0000
@@ -60,6 +60,7 @@
 import static org.hisp.dhis.reporttable.ReportTable.addIfEmpty;
 import static org.hisp.dhis.system.util.DateUtils.daysBetween;
 import static org.hisp.dhis.organisationunit.OrganisationUnit.getParentGrapMap;
+import static org.hisp.dhis.system.util.CollectionUtils.emptyIfNull;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -387,7 +388,8 @@
             
             Map<String, String> uidNameMap = getUidNameMap( params );
             Map<String, String> cocNameMap = getCocNameMap( grid, cocIndex );
-            Map<String, String> ouParentGraphMap = getParentGrapMap( asTypedList( params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class ) );
+            Map<String, String> ouParentGraphMap = getParentGrapMap( asTypedList( 
+                emptyIfNull( params.getDimensionOrFilter( ORGUNIT_DIM_ID ) ), OrganisationUnit.class ) );
             
             uidNameMap.putAll( cocNameMap );
             

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2013-10-03 12:17:41 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2013-10-03 13:24:21 +0000
@@ -34,6 +34,7 @@
 import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID;
 import static org.hisp.dhis.common.NameableObjectUtils.asTypedList;
 import static org.hisp.dhis.organisationunit.OrganisationUnit.getParentGrapMap;
+import static org.hisp.dhis.system.util.CollectionUtils.emptyIfNull;
 
 import java.util.ArrayList;
 import java.util.Date;
@@ -168,7 +169,8 @@
         Map<Object, Object> metaData = new HashMap<Object, Object>();        
         
         Map<String, String> uidNameMap = getUidNameMap( params );
-        Map<String, String> ouParentGraphMap = getParentGrapMap( asTypedList( params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class ) );
+        Map<String, String> ouParentGraphMap = getParentGrapMap( asTypedList( 
+            emptyIfNull( params.getDimensionOrFilter( ORGUNIT_DIM_ID ) ), OrganisationUnit.class ) );
         
         metaData.put( NAMES_META_KEY, uidNameMap );
         metaData.put( ORGUNIT_DIM_ID, ouParentGraphMap );
@@ -233,7 +235,8 @@
         Map<Object, Object> metaData = new HashMap<Object, Object>();
         
         Map<String, String> uidNameMap = getUidNameMap( params );
-        Map<String, String> ouParentGraphMap = getParentGrapMap( asTypedList( params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class ) );
+        Map<String, String> ouParentGraphMap = getParentGrapMap( asTypedList( 
+            emptyIfNull( params.getDimensionOrFilter( ORGUNIT_DIM_ID ) ), OrganisationUnit.class ) );
         
         metaData.put( NAMES_META_KEY, uidNameMap );
         metaData.put( ORGUNIT_DIM_ID, ouParentGraphMap );