← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20253: Data set report. Aborting analytics query for sub-totals if category is not a data dimension

 

------------------------------------------------------------
revno: 20253
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-21 12:58:41 +0200
message:
  Data set report. Aborting analytics query for sub-totals if category is not a data dimension
modified:
  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-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-08-26 09:42:00 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/AnalyticsDataSetReportStore.java	2015-09-21 10:58:41 +0000
@@ -35,6 +35,8 @@
 import java.util.Map.Entry;
 import java.util.Set;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.analytics.AnalyticsService;
 import org.hisp.dhis.analytics.DataQueryParams;
 import org.hisp.dhis.dataelement.DataElement;
@@ -55,6 +57,8 @@
 public class AnalyticsDataSetReportStore
     implements DataSetReportStore
 {
+    private static final Log log = LogFactory.getLog( AnalyticsDataSetReportStore.class );
+    
     private AnalyticsService analyticsService;
     
     public void setAnalyticsService( AnalyticsService analyticsService )
@@ -72,7 +76,7 @@
     {
         List<DataElement> dataElements = new ArrayList<>( dataSet.getDataElements() );
         
-        FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );
+        FilterUtils.filter( dataElements, AggregatableDataElementFilter.INSTANCE );
         
         if ( dataElements.isEmpty() )
         {
@@ -114,7 +118,7 @@
             List<DataElement> dataElements = new ArrayList<>( section.getDataElements() );
             List<DataElementCategory> categories = section.hasCategoryCombo() ? section.getCategoryCombo().getCategories() : null;
 
-            FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );
+            FilterUtils.filter( dataElements, AggregatableDataElementFilter.INSTANCE );
 
             if ( dataElements.isEmpty() || categories == null || categories.isEmpty() )
             {
@@ -125,6 +129,12 @@
             {
                 if ( category.isDefault() )
                 {
+                    continue; // No need for sub-total for default
+                }
+                
+                if ( !category.isDataDimension() )
+                {
+                    log.warn( "Could not get sub-total for category: " + category.getUid() + " for data set report: " + dataSet + ", not a data dimension" );
                     continue;
                 }
                 
@@ -158,7 +168,7 @@
     {
         List<DataElement> dataElements = new ArrayList<>( dataSet.getDataElements() );
 
-        FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );
+        FilterUtils.filter( dataElements, AggregatableDataElementFilter.INSTANCE );
 
         if ( dataElements.isEmpty() )
         {