← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12426: Nullpointer fix

 

------------------------------------------------------------
revno: 12426
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-10-04 12:59:00 +0200
message:
  Nullpointer fix
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.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/common/IdentifiableObjectUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java	2013-10-03 08:22:21 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/IdentifiableObjectUtils.java	2013-10-04 10:59:00 +0000
@@ -253,9 +253,12 @@
     {
         List<Integer> integers = new ArrayList<Integer>();
 
-        for ( IdentifiableObject identifiableObject : identifiableObjects )
+        if ( identifiableObjects != null )
         {
-            integers.add( identifiableObject.getId() );
+            for ( IdentifiableObject identifiableObject : identifiableObjects )
+            {
+                integers.add( identifiableObject.getId() );
+            }
         }
 
         return integers;
@@ -272,9 +275,12 @@
     {
         Map<String, String> map = new HashMap<String, String>();
         
-        for ( IdentifiableObject object : objects )
+        if ( objects != null )
         {
-            map.put( object.getUid(), object.getDisplayName() );
+            for ( IdentifiableObject object : objects )
+            {
+                map.put( object.getUid(), object.getDisplayName() );
+            }
         }
         
         return map;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java	2013-09-17 16:22:09 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/NameableObjectUtils.java	2013-10-04 10:59:00 +0000
@@ -47,9 +47,12 @@
     {
         List<NameableObject> list = new ArrayList<NameableObject>();
         
-        for ( NameableObject object : objects )
+        if ( objects != null )
         {
-            list.add( object );
+            for ( NameableObject object : objects )
+            {
+                list.add( object );
+            }
         }
         
         return list;
@@ -81,9 +84,12 @@
     {
         List<T> list = new ArrayList<T>();
         
-        for ( NameableObject object : collection )
+        if ( collection != null )
         {
-            list.add( (T) object );
+            for ( NameableObject object : collection )
+            {
+                list.add( (T) object );
+            }
         }
         
         return list;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java	2013-10-03 08:22:21 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/AnalyticsService.java	2013-10-04 10:59:00 +0000
@@ -95,6 +95,7 @@
 {
     final String NAMES_META_KEY = "names";
     final String PAGER_META_KEY = "pager";
+    final String OU_HIERARCHY_KEY = "ouHierarchy";
     
     /**
      * Generates aggregated values for the given query.

=== 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 13:24:21 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-10-04 10:59:00 +0000
@@ -55,12 +55,11 @@
 import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT;
 import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT_CHILDREN;
 import static org.hisp.dhis.organisationunit.OrganisationUnit.KEY_USER_ORGUNIT_GRANDCHILDREN;
+import static org.hisp.dhis.organisationunit.OrganisationUnit.getParentGrapMap;
 import static org.hisp.dhis.period.PeriodType.getPeriodTypeFromIsoString;
 import static org.hisp.dhis.reporttable.ReportTable.IRT2D;
 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;
@@ -389,7 +388,7 @@
             Map<String, String> uidNameMap = getUidNameMap( params );
             Map<String, String> cocNameMap = getCocNameMap( grid, cocIndex );
             Map<String, String> ouParentGraphMap = getParentGrapMap( asTypedList( 
-                emptyIfNull( params.getDimensionOrFilter( ORGUNIT_DIM_ID ) ), OrganisationUnit.class ) );
+                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 13:24:21 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2013-10-04 10:59:00 +0000
@@ -34,7 +34,6 @@
 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;
@@ -170,7 +169,7 @@
         
         Map<String, String> uidNameMap = getUidNameMap( params );
         Map<String, String> ouParentGraphMap = getParentGrapMap( asTypedList( 
-            emptyIfNull( params.getDimensionOrFilter( ORGUNIT_DIM_ID ) ), OrganisationUnit.class ) );
+            params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class ) );
         
         metaData.put( NAMES_META_KEY, uidNameMap );
         metaData.put( ORGUNIT_DIM_ID, ouParentGraphMap );
@@ -236,7 +235,7 @@
         
         Map<String, String> uidNameMap = getUidNameMap( params );
         Map<String, String> ouParentGraphMap = getParentGrapMap( asTypedList( 
-            emptyIfNull( params.getDimensionOrFilter( ORGUNIT_DIM_ID ) ), OrganisationUnit.class ) );
+            params.getDimensionOrFilter( ORGUNIT_DIM_ID ), OrganisationUnit.class ) );
         
         metaData.put( NAMES_META_KEY, uidNameMap );
         metaData.put( ORGUNIT_DIM_ID, ouParentGraphMap );