← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19977: Event analytics, removing program indicators as items for aggregate

 

------------------------------------------------------------
revno: 19977
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-09-03 18:53:01 +0200
message:
  Event analytics, removing program indicators as items for aggregate
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.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/event/EventQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java	2015-09-03 08:15:09 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java	2015-09-03 16:53:01 +0000
@@ -28,6 +28,15 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.common.DimensionalObject.DATA_X_DIM_ID;
+import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.analytics.DataQueryParams;
 import org.hisp.dhis.analytics.EventOutputType;
@@ -38,6 +47,8 @@
 import org.hisp.dhis.common.NameableObjectUtils;
 import org.hisp.dhis.common.QueryItem;
 import org.hisp.dhis.commons.collection.ListUtils;
+import org.hisp.dhis.commons.filter.Filter;
+import org.hisp.dhis.commons.filter.FilterUtils;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.legend.Legend;
 import org.hisp.dhis.option.OptionSet;
@@ -46,15 +57,6 @@
 import org.hisp.dhis.program.ProgramIndicator;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.hisp.dhis.common.DimensionalObject.DATA_X_DIM_ID;
-import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID;
-
 /**
  * @author Lars Helge Overland
  */
@@ -147,7 +149,6 @@
 
     public static EventQueryParams fromDataQueryParams( DataQueryParams dataQueryParams )
     {
-        //TODO indicator filter
         EventQueryParams params = new EventQueryParams();
 
         dataQueryParams.copyTo( params );
@@ -296,6 +297,22 @@
     }
 
     /**
+     * Removes items and item filters of type program indicators.
+     */
+    public EventQueryParams removeProgramIndicatorItems()
+    {
+        FilterUtils.filter( items, new Filter<QueryItem>()
+        {
+            public boolean retain( QueryItem object )
+            {
+                return !object.isProgramIndicator();
+            }
+        } );
+        
+        return this;
+    }
+
+    /**
      * Returns the aggregation type for this query, first by looking at the
      * aggregation type of the query, second by looking at the aggregation type
      * of the value dimension, third by returning AVERAGE;

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-09-03 15:30:38 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-09-03 16:53:01 +0000
@@ -176,6 +176,8 @@
         
         queryPlanner.validate( params );
         
+        params.removeProgramIndicatorItems(); // Not supported as items for aggregate
+        
         Grid grid = new ListGrid();
 
         int maxLimit = queryPlanner.getMaxLimit();