← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18809: Data set report, nullpointer check

 

------------------------------------------------------------
revno: 18809
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-04-04 09:23:13 +0200
message:
  Data set report, nullpointer check
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/AnalyticsDataSetReportStore.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/dataset/Section.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java	2015-03-22 07:12:15 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java	2015-04-04 07:23:13 +0000
@@ -125,9 +125,14 @@
         dataElements.clear();
     }
 
+    public boolean hasCategoryCombo()
+    {
+        return getCategoryCombo() != null;
+    }
+
     public DataElementCategoryCombo getCategoryCombo()
     {
-        return dataElements != null && !dataElements.isEmpty() ? dataElements.iterator().next().getCategoryCombo() : null;
+        return dataElements != null && !dataElements.isEmpty() ? dataElements.get( 0 ).getCategoryCombo() : null;
     }
 
     public boolean hasMultiDimensionalDataElement()
@@ -170,7 +175,7 @@
     {
         return dataElements != null && !dataElements.isEmpty();
     }
-
+    
     @Override
     public boolean haveUniqueNames()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/AnalyticsDataSetReportStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/AnalyticsDataSetReportStore.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/AnalyticsDataSetReportStore.java	2015-04-04 07:23:13 +0000
@@ -111,11 +111,11 @@
         for ( Section section : dataSet.getSections() )
         {
             List<DataElement> dataElements = new ArrayList<>( section.getDataElements() );
-            List<DataElementCategory> categories = section.getCategoryCombo().getCategories();
+            List<DataElementCategory> categories = section.hasCategoryCombo() ? section.getCategoryCombo().getCategories() : null;
 
             FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );
 
-            if ( dataElements.isEmpty() || categories.isEmpty() )
+            if ( dataElements.isEmpty() || categories == null || categories.isEmpty() )
             {
                 continue;
             }