← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10219: Analytics, fixed bug

 

------------------------------------------------------------
revno: 10219
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-14 14:07:10 +0100
message:
  Analytics, fixed bug
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/data/DefaultAnalyticsService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java
  dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html


--
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	2013-03-12 17:07:05 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2013-03-14 13:07:10 +0000
@@ -159,7 +159,7 @@
      */
     public boolean filterSpansMultiplePartitions()
     {
-        return tableNamePeriodMap != null && !tableNamePeriodMap.isEmpty();
+        return tableNamePeriodMap != null && tableNamePeriodMap.size() > 1;
     }
     
     /**

=== 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-03-12 17:07:05 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2013-03-14 13:07:10 +0000
@@ -339,16 +339,22 @@
     
     public Map<String, Double> getAggregatedDataValueMap( DataQueryParams params )
     {
+        queryPlanner.validate( params );
+        
         return getAggregatedValueMap( params, ANALYTICS_TABLE_NAME );
     }
     
     public Map<String, Double> getAggregatedCompletenessValueMap( DataQueryParams params )
     {
+        queryPlanner.validate( params );
+        
         return getAggregatedValueMap( params, COMPLETENESS_TABLE_NAME );
     }
 
     private Map<String, Double> getAggregatedCompletenessTargetMap( DataQueryParams params )
     {
+        queryPlanner.validate( params );
+        
         return getAggregatedValueMap( params, COMPLETENESS_TARGET_TABLE_NAME );
     }
     
@@ -359,8 +365,6 @@
      */
     private Map<String, Double> getAggregatedValueMap( DataQueryParams params, String tableName )        
     {
-        queryPlanner.validate( params );
-        
         Timer t = new Timer().start();
 
         int optimalQueries = MathUtils.getWithin( SystemUtils.getCpuCores(), 1, MAX_QUERIES );

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java	2013-03-11 08:24:17 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java	2013-03-14 13:07:10 +0000
@@ -269,7 +269,8 @@
     /**
      * Groups the given query into sub queries based on its periods and which 
      * partition it should be executed against. Sets the partition table name on
-     * each query. Queries are grouped based on both dimensions and filters.
+     * each query. Queries are grouped based on periods if appearing as a 
+     * dimension.
      */
     private List<DataQueryParams> groupByPartition( DataQueryParams params, String tableName )
     {
@@ -297,7 +298,8 @@
             ListMap<String, IdentifiableObject> tableNamePeriodMap = PartitionUtils.getTableNamePeriodMap( params.getFilterPeriods(), tableName );
             
             DataQueryParams query = new DataQueryParams( params );
-            query.setTableNamePeriodMap( tableNamePeriodMap );
+            query.setTableNamePeriodMap( tableNamePeriodMap );            
+            query.setTableName( tableNamePeriodMap.keySet().iterator().next() );
             queries.add( query );
         }
         else

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java	2013-03-10 16:13:56 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/PartitionUtils.java	2013-03-14 13:07:10 +0000
@@ -29,16 +29,15 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Date;
 import java.util.List;
 
 import org.hisp.dhis.analytics.AnalyticsTableManager;
 import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.period.YearlyPeriodType;
-import org.hisp.dhis.common.ListMap;
 
 public class PartitionUtils
 {
@@ -80,7 +79,7 @@
         
         return tableName + SEP + year.getIsoDate();
     }
-    
+
     public static Period getPeriod( String tableName )
     {
         if ( tableName == null || tableName.indexOf( SEP ) == -1 )
@@ -94,7 +93,7 @@
         return PeriodType.getPeriodFromIsoString( isoPeriod );
     }
     
-    public static ListMap<String, IdentifiableObject> getTableNamePeriodMap( Collection<IdentifiableObject> periods, String tableName )
+    public static ListMap<String, IdentifiableObject> getTableNamePeriodMap( List<IdentifiableObject> periods, String tableName )
     {
         ListMap<String, IdentifiableObject> map = new ListMap<String, IdentifiableObject>();
         

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html'
--- dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html	2013-02-02 19:22:58 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/resources/html-report-template.html	2013-03-14 13:07:10 +0000
@@ -49,7 +49,7 @@
 var orgUnit = dhis2.report.organisationUnit; // An object<br><br>
 
 var id = orgUnit.id;
-var name = orgUnit.name;<br>
+var name = orgUnit.name;<br><br>
 var code = orgUnit.code;<br><br>
 
 var orgUnitHierarchy = dhis2.report.organisationUnitHierarchy; // An array with org unit objects for the hierarchy (current org unit first)<br><br>