← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19697: Event aggregation analytics. Respecting aggregation operator of data element.

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 19697 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-08-02 17:25:03 +0200
message:
  Event aggregation analytics. Respecting aggregation operator of data element.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/EventAnalyticalObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventchart/EventChart.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java
  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
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.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-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java	2015-07-15 13:33:44 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseDimensionalObject.java	2015-08-02 14:59:59 +0000
@@ -37,6 +37,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.google.common.base.MoreObjects;
 
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.DimensionalView;
 import org.hisp.dhis.common.view.ExportView;
@@ -78,6 +79,11 @@
     protected LegendSet legendSet;
     
     /**
+     * The aggregation type for this dimension.
+     */
+    protected AggregationType aggregationType;
+    
+    /**
      * Filter. Applicable for events. Contains operator and filter on this format:
      * <operator>:<filter>;<operator>:<filter>
      * Operator and filter pairs can be repeated any number of times.
@@ -135,6 +141,8 @@
         this.legendSet = legendSet;
         this.filter = filter;
     }
+    
+    // TODO aggregationType in constructors
 
     // -------------------------------------------------------------------------
     // Logic
@@ -261,7 +269,6 @@
         this.allItems = allItems;
     }
 
-
     @Override
     @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
@@ -279,6 +286,20 @@
 
     @Override
     @JsonProperty
+    @JsonView( { DimensionalView.class, DetailedView.class, ExportView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public AggregationType getAggregationType()
+    {
+        return aggregationType;
+    }
+
+    public void setAggregationType( AggregationType aggregationType )
+    {
+        this.aggregationType = aggregationType;
+    }
+
+    @Override
+    @JsonProperty
     @JsonView( { DimensionalView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getFilter()
@@ -325,6 +346,7 @@
                 dimensionType = dimensionalObject.getDimensionType();
                 dimensionName = dimensionalObject.getDimensionName();
                 legendSet = dimensionalObject.getLegendSet();
+                aggregationType = dimensionalObject.getAggregationType();
                 filter = dimensionalObject.getFilter();
             }
             else if ( strategy.isMerge() )
@@ -332,6 +354,7 @@
                 dimensionType = dimensionalObject.getDimensionType() == null ? dimensionType : dimensionalObject.getDimensionType();
                 dimensionName = dimensionalObject.getDimensionName() == null ? dimensionName : dimensionalObject.getDimensionName();
                 legendSet = dimensionalObject.getLegendSet() == null ? legendSet : dimensionalObject.getLegendSet();
+                aggregationType = dimensionalObject.getAggregationType() == null ? aggregationType : dimensionalObject.getAggregationType();
                 filter = dimensionalObject.getFilter() == null ? filter : dimensionalObject.getFilter();
             }
 
@@ -351,6 +374,7 @@
             .add( "items", items )
             .add( "all items", allItems )
             .add( "legend set", legendSet )
+            .add( "aggregation type", aggregationType )
             .add( "filter", filter ).toString();
     }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java	2015-07-15 06:49:50 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DimensionalObject.java	2015-08-02 14:59:59 +0000
@@ -32,6 +32,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.dataelement.CategoryOptionGroup;
 import org.hisp.dhis.dataelement.CategoryOptionGroupSet;
 import org.hisp.dhis.dataelement.DataElement;
@@ -136,6 +137,11 @@
     boolean hasLegendSet();
     
     /**
+     * Gets the aggregation type.
+     */
+    AggregationType getAggregationType();
+    
+    /**
      * Gets the filter. Contains operator and filter. Applicable for events.
      */
     String getFilter();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/EventAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/EventAnalyticalObject.java	2015-03-31 14:49:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/EventAnalyticalObject.java	2015-08-02 14:59:59 +0000
@@ -52,7 +52,7 @@
     
     EventOutputType getOutputType();
     
-    NameableObject getValue();
+    DimensionalObject getValue();
     
     boolean isCollapseDataDimensions();
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java	2015-05-11 11:58:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java	2015-08-02 14:59:59 +0000
@@ -32,6 +32,7 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.legend.LegendSet;
 import org.hisp.dhis.option.OptionSet;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
@@ -45,7 +46,7 @@
  */
 public class QueryItem
 {
-    private NameableObject item;
+    private DimensionalObject item;
     
     private LegendSet legendSet;
 
@@ -53,29 +54,33 @@
     
     private String valueType;
     
+    private AggregationType aggregationType;
+    
     private OptionSet optionSet;
 
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
 
-    public QueryItem( NameableObject item )
+    public QueryItem( DimensionalObject item )
     {
         this.item = item;
     }
 
-    public QueryItem( NameableObject item, LegendSet legendSet, String valueType, OptionSet optionSet )
+    public QueryItem( DimensionalObject item, LegendSet legendSet, String valueType, AggregationType aggregationType, OptionSet optionSet )
     {
         this.item = item;
         this.legendSet = legendSet;
         this.valueType = valueType;
+        this.aggregationType = aggregationType;
         this.optionSet = optionSet;
     }
     
-    public QueryItem( NameableObject item, QueryOperator operator, String filter, String valueType, OptionSet optionSet )
+    public QueryItem( DimensionalObject item, QueryOperator operator, String filter, String valueType, AggregationType aggregationType, OptionSet optionSet )
     {
         this.item = item;
         this.valueType = valueType;
+        this.aggregationType = aggregationType;
         this.optionSet = optionSet;
         
         if ( operator != null && filter != null )
@@ -146,7 +151,7 @@
         
         for ( TrackedEntityAttribute attribute : attributes )
         {
-            queryItems.add( new QueryItem( attribute, attribute.getLegendSet(), attribute.getValueType(), attribute.hasOptionSet() ? attribute.getOptionSet() : null ) );
+            queryItems.add( new QueryItem( attribute, attribute.getLegendSet(), attribute.getValueType(), attribute.getAggregationType(), attribute.hasOptionSet() ? attribute.getOptionSet() : null ) );
         }
         
         return queryItems;
@@ -195,12 +200,12 @@
     // Getters and setters
     // -------------------------------------------------------------------------
 
-    public NameableObject getItem()
+    public DimensionalObject getItem()
     {
         return item;
     }
 
-    public void setItem( NameableObject item )
+    public void setItem( DimensionalObject item )
     {
         this.item = item;
     }
@@ -235,6 +240,16 @@
         this.valueType = valueType;
     }
 
+    public AggregationType getAggregationType()
+    {
+        return aggregationType;
+    }
+
+    public void setAggregationType( AggregationType aggregationType )
+    {
+        this.aggregationType = aggregationType;
+    }
+
     public OptionSet getOptionSet()
     {
         return optionSet;

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2015-08-02 13:30:47 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2015-08-02 14:59:59 +0000
@@ -36,6 +36,7 @@
 import java.util.List;
 import java.util.Set;
 
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.attribute.AttributeValue;
 import org.hisp.dhis.common.BaseDimensionalObject;
 import org.hisp.dhis.common.BaseIdentifiableObject;
@@ -517,6 +518,12 @@
         return legendSet != null;
     }
 
+    @Override
+    public AggregationType getAggregationType()
+    {
+        return aggregationOperator != null ? AggregationType.fromValue( aggregationOperator ) : null;
+    }
+    
     // -------------------------------------------------------------------------
     // Helper getters
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventchart/EventChart.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventchart/EventChart.java	2015-07-15 09:45:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventchart/EventChart.java	2015-08-02 14:59:59 +0000
@@ -134,7 +134,7 @@
     /**
      * Value dimension.
      */
-    private transient NameableObject value;
+    private transient DimensionalObject value;
 
     // -------------------------------------------------------------------------
     // Constructors
@@ -388,12 +388,12 @@
     @JsonSerialize( as = BaseDimensionalObject.class )
     @JsonView( { DimensionalView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public NameableObject getValue()
+    public DimensionalObject getValue()
     {
         return value;
     }
 
-    public void setValue( NameableObject value )
+    public void setValue( DimensionalObject value )
     {
         this.value = value;
     }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java	2015-07-15 09:45:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java	2015-08-02 14:59:59 +0000
@@ -36,11 +36,11 @@
 import org.hisp.dhis.common.BaseAnalyticalObject;
 import org.hisp.dhis.common.BaseDimensionalObject;
 import org.hisp.dhis.common.BaseIdentifiableObject;
+import org.hisp.dhis.common.DimensionalObject;
 import org.hisp.dhis.common.DxfNamespaces;
 import org.hisp.dhis.common.EventAnalyticalObject;
 import org.hisp.dhis.common.IdentifiableObject;
 import org.hisp.dhis.common.MergeStrategy;
-import org.hisp.dhis.common.NameableObject;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.DimensionalView;
 import org.hisp.dhis.common.view.ExportView;
@@ -189,7 +189,7 @@
     /**
      * Value dimension.
      */
-    private transient NameableObject value;
+    private transient DimensionalObject value;
 
     // -------------------------------------------------------------------------
     // Constructors
@@ -553,12 +553,12 @@
     @JsonSerialize( as = BaseDimensionalObject.class )
     @JsonView( { DimensionalView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public NameableObject getValue()
+    public DimensionalObject getValue()
     {
         return value;
     }
 
-    public void setValue( NameableObject value )
+    public void setValue( DimensionalObject value )
     {
         this.value = value;
     }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java	2015-08-02 12:27:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityAttribute.java	2015-08-02 14:59:59 +0000
@@ -28,14 +28,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import java.util.HashSet;
+import java.util.Set;
 
-import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.attribute.AttributeValue;
 import org.hisp.dhis.common.BaseDimensionalObject;
 import org.hisp.dhis.common.BaseIdentifiableObject;
@@ -48,8 +43,12 @@
 import org.hisp.dhis.option.OptionSet;
 import org.hisp.dhis.schema.annotation.PropertyRange;
 
-import java.util.HashSet;
-import java.util.Set;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonView;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 
 /**
  * @author Abyot Asalefew
@@ -74,8 +73,6 @@
 
     private String valueType;
     
-    private AggregationType aggregationType;
-
     private Boolean inherit = false;
 
     private TrackedEntityAttributeGroup attributeGroup;
@@ -233,19 +230,6 @@
         this.valueType = valueType;
     }
 
-    @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public AggregationType getAggregationType()
-    {
-        return aggregationType;
-    }
-
-    public void setAggregationType( AggregationType aggregationType )
-    {
-        this.aggregationType = aggregationType;
-    }
-
     @JsonProperty( "trackedEntityAttributeGroup" )
     @JsonView( { DetailedView.class } )
     @JsonSerialize( as = BaseIdentifiableObject.class )

=== 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-07-15 09:06:53 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/EventQueryParams.java	2015-08-02 14:59:59 +0000
@@ -37,6 +37,7 @@
 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;
 import org.hisp.dhis.analytics.Partitions;
@@ -69,7 +70,7 @@
     
     private String filter;
     
-    private NameableObject value;
+    private DimensionalObject value;
     
     private List<String> asc = new ArrayList<>();
     
@@ -152,28 +153,28 @@
         for ( NameableObject object : dataQueryParams.getProgramDataElements() )
         {
             DataElement element = (DataElement) object;            
-            QueryItem item = new QueryItem( element, element.getLegendSet(), element.getType(), element.getOptionSet() );
+            QueryItem item = new QueryItem( element, element.getLegendSet(), element.getType(), element.getAggregationType(), element.getOptionSet() );
             params.getItems().add( item );
         }
 
         for ( NameableObject object : dataQueryParams.getProgramAttributes() )
         {
             TrackedEntityAttribute element = (TrackedEntityAttribute) object;            
-            QueryItem item = new QueryItem( element, element.getLegendSet(), element.getValueType(), element.getOptionSet() );
+            QueryItem item = new QueryItem( element, element.getLegendSet(), element.getValueType(), element.getAggregationType(), element.getOptionSet() );
             params.getItems().add( item );
         }
 
         for ( NameableObject object : dataQueryParams.getFilterProgramDataElements() )
         {
             DataElement element = (DataElement) object;            
-            QueryItem item = new QueryItem( element, element.getLegendSet(), element.getType(), element.getOptionSet() );            
+            QueryItem item = new QueryItem( element, element.getLegendSet(), element.getType(), element.getAggregationType(), element.getOptionSet() );            
             params.getItemFilters().add( item );
         }
 
         for ( NameableObject object : dataQueryParams.getFilterProgramAttributes() )
         {
             TrackedEntityAttribute element = (TrackedEntityAttribute) object;            
-            QueryItem item = new QueryItem( element, element.getLegendSet(), element.getValueType(), element.getOptionSet() );            
+            QueryItem item = new QueryItem( element, element.getLegendSet(), element.getValueType(), element.getAggregationType(), element.getOptionSet() );            
             params.getItemFilters().add( item );
         }
 
@@ -285,12 +286,45 @@
         
         return optionSets;
     }
+
+    /**
+     * 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.
+     */
+    public AggregationType getAggregationTypeFallback()
+    {
+        if ( hasAggregationType() )
+        {
+            return aggregationType;
+        }
+        else if ( hasValueDimension() )
+        {
+            return value.getAggregationType();
+        }
+        
+        return null;
+    }
+
+    /**
+     * Indicates whether this object is of the given aggregation type. Based on
+     * {@link getAggregationTypeFallback}.
+     */
+    @Override
+    public boolean isAggregationType( AggregationType aggregationType )
+    {
+        AggregationType type = getAggregationTypeFallback();
+        return type != null && type.equals( aggregationType );
+    }    
     
+    /**
+     * Indicates whether this query is of the given organisation unit mode.
+     */
     public boolean isOrganisationUnitMode( String mode )
     {
         return organisationUnitMode != null && organisationUnitMode.equalsIgnoreCase( mode );
     }
-    
+
     /**
      * Indicates whether any items or item filters are present.
      */
@@ -299,6 +333,9 @@
         return !items.isEmpty() || !itemFilters.isEmpty();
     }
 
+    /**
+     * Indicates whether this query has a start and end date.
+     */
     public boolean hasStartEndDate()
     {
         return startDate != null && endDate != null;
@@ -445,12 +482,12 @@
         this.filter = filter;
     }
 
-    public NameableObject getValue()
+    public DimensionalObject getValue()
     {
         return value;
     }
 
-    public void setValue( NameableObject value )
+    public void setValue( DimensionalObject value )
     {
         this.value = value;
     }

=== 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-06-23 22:22:09 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-08-02 14:59:59 +0000
@@ -684,20 +684,20 @@
 
         if ( de != null ) //TODO check if part of program
         {
-            return new QueryItem( de, legendSet, de.getType(), de.getOptionSet() );
+            return new QueryItem( de, legendSet, de.getType(), de.getAggregationType(), de.getOptionSet() );
         }
 
         TrackedEntityAttribute at = attributeService.getTrackedEntityAttribute( item );
 
         if ( at != null )
         {
-            return new QueryItem( at, legendSet, at.getValueType(), at.getOptionSet() );
+            return new QueryItem( at, legendSet, at.getValueType(), at.getAggregationType(), at.getOptionSet() );
         }
 
         throw new IllegalQueryException( "Item identifier does not reference any data element or attribute part of the program: " + item );
     }
     
-    private NameableObject getValueDimension( String value )
+    private DimensionalObject getValueDimension( String value )
     {
         if ( value == null )
         {

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2015-07-08 03:38:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2015-08-02 14:29:38 +0000
@@ -541,7 +541,7 @@
             throw new IllegalQueryException( "Attribute does not exist: " + item );
         }
 
-        return new QueryItem( at, null, at.getValueType(), at.getOptionSet() );
+        return new QueryItem( at, null, at.getValueType(), at.getAggregationType(), at.getOptionSet() );
     }
 
     /**

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java	2015-07-08 04:57:33 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java	2015-08-02 14:29:38 +0000
@@ -514,7 +514,7 @@
 
         TrackedEntityInstanceQueryParams params = new TrackedEntityInstanceQueryParams();
 
-        QueryItem queryItem = new QueryItem( attribute, QueryOperator.EQ, value, attribute.getValueType(), null );
+        QueryItem queryItem = new QueryItem( attribute, QueryOperator.EQ, value, attribute.getValueType(), attribute.getAggregationType(), null );
         params.addAttribute( queryItem );
 
         if ( attribute.getOrgunitScope() && attribute.getProgramScope() )

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java	2015-07-16 05:20:56 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java	2015-08-02 14:29:38 +0000
@@ -429,7 +429,7 @@
 
         TrackedEntityInstanceQueryParams params = new TrackedEntityInstanceQueryParams();
 
-        QueryItem queryItem = new QueryItem( attribute, QueryOperator.EQ, value, attribute.getValueType(), null );
+        QueryItem queryItem = new QueryItem( attribute, QueryOperator.EQ, value, attribute.getValueType(), attribute.getAggregationType(), attribute.getOptionSet() );
         params.addAttribute( queryItem );
 
         if ( attribute.getOrgunitScope() )

=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java'
--- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2015-07-03 07:33:54 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/ActivityReportingServiceImpl.java	2015-08-02 14:29:38 +0000
@@ -1740,7 +1740,7 @@
             else
             {
                 TrackedEntityAttribute at = attributeService.getTrackedEntityAttributeByName( split[0] );
-                QueryItem queryItem = new QueryItem( at, null, at.getValueType(), null );
+                QueryItem queryItem = new QueryItem( at, at.getLegendSet(), at.getValueType(), at.getAggregationType(), at.getOptionSet() );
                 QueryOperator operator = QueryOperator.fromString( split[1] );
                 queryItem.getFilters().add( new QueryFilter( operator, split[2] ) );
                 param.getFilters().add( queryItem );