← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16162: Analytics, error logging

 

------------------------------------------------------------
revno: 16162
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-07-17 17:12:35 +0200
message:
  Analytics, error logging
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.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/data/JdbcAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java	2014-07-15 18:31:16 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/JdbcAnalyticsManager.java	2014-07-17 15:12:35 +0000
@@ -70,6 +70,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.system.util.DebugUtils;
 import org.hisp.dhis.system.util.MathUtils;
 import org.hisp.dhis.system.util.SqlHelper;
 import org.hisp.dhis.system.util.TextUtils;
@@ -111,41 +112,50 @@
     @Async
     public Future<Map<String, Double>> getAggregatedDataValues( DataQueryParams params )
     {
-        ListMap<NameableObject, NameableObject> dataPeriodAggregationPeriodMap = params.getDataPeriodAggregationPeriodMap();
-        
-        params.replaceAggregationPeriodsWithDataPeriods( dataPeriodAggregationPeriodMap );
-        
-        String sql = getSelectClause( params );
-        
-        if ( params.spansMultiplePartitions() )
-        {
-            sql += getFromWhereClauseMultiplePartitionFilters( params );
-        }
-        else
-        {
-            sql += getFromWhereClause( params, params.getPartitions().getSinglePartition() );
-        }
-        
-        sql += getGroupByClause( params );
-    
-        log.debug( sql );
-
-        Map<String, Double> map = null;
-        
         try
         {
-            map = getKeyValueMap( params, sql );
+            ListMap<NameableObject, NameableObject> dataPeriodAggregationPeriodMap = params.getDataPeriodAggregationPeriodMap();
+            
+            params.replaceAggregationPeriodsWithDataPeriods( dataPeriodAggregationPeriodMap );
+            
+            String sql = getSelectClause( params );
+            
+            if ( params.spansMultiplePartitions() )
+            {
+                sql += getFromWhereClauseMultiplePartitionFilters( params );
+            }
+            else
+            {
+                sql += getFromWhereClause( params, params.getPartitions().getSinglePartition() );
+            }
+            
+            sql += getGroupByClause( params );
+        
+            log.debug( sql );
+    
+            Map<String, Double> map = null;
+            
+            try
+            {
+                map = getKeyValueMap( params, sql );
+            }
+            catch ( BadSqlGrammarException ex )
+            {
+                log.info( "Query failed, likely because the requested analytics table does not exist", ex );
+                
+                return new AsyncResult<Map<String, Double>>( new HashMap<String, Double>() );
+            }
+            
+            replaceDataPeriodsWithAggregationPeriods( map, params, dataPeriodAggregationPeriodMap );
+            
+            return new AsyncResult<Map<String, Double>>( map );
         }
-        catch ( BadSqlGrammarException ex )
+        catch ( Exception ex )
         {
-            log.info( "Query failed, likely because the requested analytics table does not exist", ex );
+            log.error( DebugUtils.getStackTrace( ex ) );
             
-            return new AsyncResult<Map<String, Double>>( new HashMap<String, Double>() );
+            throw ex;
         }
-        
-        replaceDataPeriodsWithAggregationPeriods( map, params, dataPeriodAggregationPeriodMap );
-        
-        return new AsyncResult<Map<String, Double>>( map );   
     }
     
     public void replaceDataPeriodsWithAggregationPeriods( Map<String, Double> dataValueMap, DataQueryParams params, ListMap<NameableObject, NameableObject> dataPeriodAggregationPeriodMap )