← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9285: Null checks

 

------------------------------------------------------------
revno: 9285
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-12-12 16:47:03 +0100
message:
  Null checks
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/table/JdbcAnalyticsTableManager.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	2012-12-12 15:29:04 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2012-12-12 15:47:03 +0000
@@ -46,7 +46,7 @@
     public static final String DATAELEMENT_DIM_ID = "de";
     public static final String PERIOD_DIM_ID = "pe";
     public static final String ORGUNIT_DIM_ID = "ou";
-    
+        
     private List<String> indicators = new ArrayList<String>();
     
     private List<String> dataElements = new ArrayList<String>();
@@ -82,11 +82,11 @@
     
     public DataQueryParams( DataQueryParams params )
     {
-        this.indicators = new ArrayList<String>( params.getIndicators() );
-        this.dataElements = new ArrayList<String>( params.getDataElements() );
-        this.periods = new ArrayList<String>( params.getPeriods() );
-        this.organisationUnits = new ArrayList<String>( params.getOrganisationUnits() );
-        this.dimensions = new HashMap<String, List<String>>( params.getDimensions() );
+        this.indicators = params.getIndicators();
+        this.dataElements = params.getDataElements();
+        this.periods = params.getPeriods();
+        this.organisationUnits = params.getOrganisationUnits();
+        this.dimensions = params.getDimensions();
         this.categories = params.isCategories();
     }
 
@@ -100,13 +100,16 @@
         
         // TODO convert indicators to data elements
         
-        map.put( DATAELEMENT_DIM_ID, new ArrayList<String>( dataElements ) );
-        map.put( ORGUNIT_DIM_ID, new ArrayList<String>( organisationUnits ) );
-        map.put( PERIOD_DIM_ID, new ArrayList<String>( periods ) );
+        map.put( DATAELEMENT_DIM_ID, dataElements );
+        map.put( ORGUNIT_DIM_ID, organisationUnits );
+        map.put( PERIOD_DIM_ID, periods );
         
-        for ( String dimension : dimensions.keySet() )
+        if ( dimensions != null )
         {
-            map.put( dimension, dimensions.get( dimension ) );
+            for ( String dimension : dimensions.keySet() )
+            {
+                map.put( dimension, dimensions.get( dimension ) );
+            }
         }
         
         return map;
@@ -146,7 +149,7 @@
         {
             return organisationUnits;
         }
-        else if ( dimensions.containsKey( dimension ) )
+        else if ( dimensions != null && dimensions.containsKey( dimension ) )
         {
             return dimensions.get( dimension );
         }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2012-12-11 20:46:36 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2012-12-12 15:47:03 +0000
@@ -86,6 +86,7 @@
     // Implementation
     // -------------------------------------------------------------------------
   
+    //TODO use uid instead of id
     //TODO average aggregation operator data, pre-aggregate in time dimension, not in org unit dimension
     
     public void createTable( String tableName )