← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12302: Event analytics, supporting fixed and relative periods

 

------------------------------------------------------------
revno: 12302
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2013-09-29 19:20:53 +0200
message:
  Event analytics, supporting fixed and relative periods
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/QueryPlanner.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/event/data/DefaultEventQueryPlanner.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/QueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/QueryPlanner.java	2013-09-29 16:26:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/QueryPlanner.java	2013-09-29 17:20:53 +0000
@@ -92,4 +92,13 @@
      * names and filter names respectively.
      */
     List<DataQueryParams> groupByOrgUnitLevel( DataQueryParams params );
+
+    /**
+     * If periods appear as dimensions in the given query; groups the query into 
+     * sub queries based on the period type of the periods. Sets the period type 
+     * name on each query. If periods appear as filters; replaces the period filter
+     * with one filter for each period type. Sets the dimension names and filter
+     * names respectively.
+     */
+    List<DataQueryParams> groupByPeriodType( DataQueryParams params );
 }

=== 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-09-29 16:26:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultQueryPlanner.java	2013-09-29 17:20:53 +0000
@@ -386,7 +386,7 @@
      * with one filter for each period type. Sets the dimension names and filter
      * names respectively.
      */
-    private List<DataQueryParams> groupByPeriodType( DataQueryParams params )
+    public List<DataQueryParams> groupByPeriodType( DataQueryParams params )
     {
         List<DataQueryParams> queries = new ArrayList<DataQueryParams>();
 
@@ -423,7 +423,8 @@
         }
         else
         {
-            throw new IllegalQueryException( "Query does not contain any period dimension items" );
+            queries.add( params.instance() );
+            return queries;
         }
 
         if ( queries.size() > 1 )

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java	2013-09-29 16:26:26 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventQueryPlanner.java	2013-09-29 17:20:53 +0000
@@ -101,7 +101,12 @@
         
         for ( EventQueryParams byPartition : groupedByPartition )
         {
-            queries.addAll( convert( queryPlanner.groupByOrgUnitLevel( byPartition ) ) );
+            List<EventQueryParams> groupedByOrgUnitLevel = convert( queryPlanner.groupByOrgUnitLevel( byPartition ) );
+            
+            for ( EventQueryParams byOrgUnitLevel : groupedByOrgUnitLevel )
+            {
+                queries.addAll( convert( queryPlanner.groupByPeriodType( byOrgUnitLevel ) ) );
+            }
         }
         
         return queries;