← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20159: replace aggregationOperator with AggregationType, wip

 

------------------------------------------------------------
revno: 20159
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-09-15 16:54:24 +0700
message:
  replace aggregationOperator with AggregationType, wip
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java
  dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java
  dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java
  dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementStoreTest.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/minmax/MinMaxDataElementStoreTest.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/typehandler/AggregationOperatorTypeHandler.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ExpressionConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataElementImporter.java
  dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandler.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ReflectionUtilsTest.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ValidationUtilsTest.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElement.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlDataElement.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlDataElements.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js


--
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/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2015-09-15 05:08:23 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2015-09-15 09:54:24 +0000
@@ -35,7 +35,6 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import com.google.common.collect.Sets;
-import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.attribute.AttributeValue;
 import org.hisp.dhis.common.BaseDimensionalObject;
 import org.hisp.dhis.common.BaseIdentifiableObject;
@@ -93,12 +92,6 @@
      */
     private static final long serialVersionUID = -7131541880444446669L;
 
-    public static final String AGGREGATION_OPERATOR_SUM = "sum";
-    public static final String AGGREGATION_OPERATOR_AVERAGE_SUM = "avg_sum_org_unit"; // Sum in organisation unit
-    public static final String AGGREGATION_OPERATOR_AVERAGE = "avg";
-    public static final String AGGREGATION_OPERATOR_COUNT = "count";
-    public static final String AGGREGATION_OPERATOR_NONE = "none";
-
     /**
      * Data element value type (int, boolean, etc)
      */
@@ -121,12 +114,6 @@
     private DataElementDomain domainType;
 
     /**
-     * The aggregation operator of this DataElement; e.g. DataElement.SUM og
-     * DataElement.AVERAGE.
-     */
-    private String aggregationOperator;
-
-    /**
      * A combination of categories to capture data.
      */
     private DataElementCategoryCombo categoryCombo;
@@ -503,12 +490,6 @@
         return legendSet != null;
     }
 
-    @Override
-    public AggregationType getAggregationType()
-    {
-        return aggregationOperator != null ? AggregationType.fromValue( aggregationOperator ) : null;
-    }
-
     // -------------------------------------------------------------------------
     // DimensionalObject
     // -------------------------------------------------------------------------
@@ -578,19 +559,6 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public String getAggregationOperator()
-    {
-        return aggregationOperator;
-    }
-
-    public void setAggregationOperator( String aggregationOperator )
-    {
-        this.aggregationOperator = aggregationOperator;
-    }
-
-    @JsonProperty
     @JsonSerialize( as = BaseIdentifiableObject.class )
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
@@ -730,7 +698,6 @@
                 formName = dataElement.getFormName();
                 domainType = dataElement.getDomainType();
                 valueType = dataElement.getValueType();
-                aggregationOperator = dataElement.getAggregationOperator();
                 categoryCombo = dataElement.getCategoryCombo();
                 url = dataElement.getUrl();
                 optionSet = dataElement.getOptionSet();
@@ -741,7 +708,6 @@
                 formName = dataElement.getFormName() == null ? formName : dataElement.getFormName();
                 domainType = dataElement.getDomainType() == null ? domainType : dataElement.getDomainType();
                 valueType = dataElement.getValueType() == null ? valueType : dataElement.getValueType();
-                aggregationOperator = dataElement.getAggregationOperator() == null ? aggregationOperator : dataElement.getAggregationOperator();
                 categoryCombo = dataElement.getCategoryCombo() == null ? categoryCombo : dataElement.getCategoryCombo();
                 url = dataElement.getUrl() == null ? url : dataElement.getUrl();
                 optionSet = dataElement.getOptionSet() == null ? optionSet : dataElement.getOptionSet();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java	2015-09-04 14:25:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementOperand.java	2015-09-15 09:54:24 +0000
@@ -35,6 +35,7 @@
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
 import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
 import org.apache.commons.lang3.StringUtils;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.BaseNameableObject;
 import org.hisp.dhis.common.DxfNamespaces;
@@ -93,7 +94,7 @@
 
     private String operandName;
 
-    private String aggregationOperator;
+    private AggregationType aggregationType;
 
     private List<Integer> aggregationLevels = new ArrayList<>();
 
@@ -133,13 +134,13 @@
     }
 
     public DataElementOperand( String dataElementId, String optionComboId, String operandName,
-        String aggregationOperator, List<Integer> aggregationLevels, int frequencyOrder )
+        AggregationType aggregationType, List<Integer> aggregationLevels, int frequencyOrder )
     {
         this.dataElementId = dataElementId;
         this.optionComboId = optionComboId;
         this.operandId = dataElementId + SEPARATOR + optionComboId;
         this.operandName = operandName;
-        this.aggregationOperator = aggregationOperator;
+        this.aggregationType = aggregationType;
         this.aggregationLevels = aggregationLevels;
         this.frequencyOrder = frequencyOrder;
     }
@@ -308,10 +309,10 @@
     {
         return COLUMN_PREFIX + dataElementId + COLUMN_SEPARATOR + optionComboId;
     }
-    
+
     /**
      * Returns an identifier on the format <data element uid>.<category option combo uid>.
-     * 
+     *
      * @return an identifier.
      */
     public String getAnalyticsId()
@@ -374,7 +375,7 @@
         this.optionComboId = categoryOptionCombo.getUid();
         this.operandId = dataElementId + SEPARATOR + optionComboId;
         this.operandName = getPrettyName( dataElement, categoryOptionCombo );
-        this.aggregationOperator = dataElement.getAggregationOperator();
+        this.aggregationType = dataElement.getAggregationType();
         this.frequencyOrder = dataElement.getFrequencyOrder();
         this.aggregationLevels = new ArrayList<>( dataElement.getAggregationLevels() );
 
@@ -392,7 +393,7 @@
         this.dataElementId = dataElement.getUid();
         this.operandId = String.valueOf( dataElementId );
         this.operandName = getPrettyName( dataElement, null );
-        this.aggregationOperator = dataElement.getAggregationOperator();
+        this.aggregationType = dataElement.getAggregationType();
         this.frequencyOrder = dataElement.getFrequencyOrder();
         this.aggregationLevels = new ArrayList<>( dataElement.getAggregationLevels() );
 
@@ -508,14 +509,14 @@
     @JsonProperty
     @JsonView( { DetailedView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public String getAggregationOperator()
+    public AggregationType getAggregationType()
     {
-        return aggregationOperator;
+        return aggregationType;
     }
 
-    public void setAggregationOperator( String aggregationOperator )
+    public void setAggregationType( AggregationType aggregationType )
     {
-        this.aggregationOperator = aggregationOperator;
+        this.aggregationType = aggregationType;
     }
 
     @JsonProperty
@@ -587,7 +588,7 @@
             ", optionComboId=" + optionComboId +
             ", operandId='" + operandId + '\'' +
             ", operandName='" + operandName + '\'' +
-            ", aggregationOperator='" + aggregationOperator + '\'' +
+            ", aggregationType='" + aggregationType + '\'' +
             ", aggregationLevels=" + aggregationLevels +
             ", frequencyOrder=" + frequencyOrder +
             ", operandType='" + operandType + '\'' +

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2015-09-03 04:31:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java	2015-09-15 09:54:24 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.dataset.DataSet;
@@ -164,13 +165,13 @@
     /**
      * Returns all DataElements with a given aggregation operator.
      *
-     * @param aggregationOperator the aggregation operator of the DataElements
-     *                            to return.
+     * @param aggregationType the aggregation type of the DataElements
+     *                        to return.
      * @return a list of all DataElements with the given aggregation
      * operator, or an empty collection if no DataElements have the
      * aggregation operator.
      */
-    List<DataElement> getDataElementsByAggregationOperator( String aggregationOperator );
+    List<DataElement> getDataElementsByAggregationType( AggregationType aggregationType );
 
     /**
      * Returns all DataElements with the given domain type.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java	2015-09-03 04:31:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java	2015-09-15 09:54:24 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.GenericDimensionalObjectStore;
 import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.common.ValueType;
@@ -70,13 +71,13 @@
     /**
      * Returns all DataElements with a given aggregation operator.
      *
-     * @param aggregationOperator the aggregation operator of the DataElements
+     * @param aggregationType the aggregation operator of the DataElements
      *                            to return.
      * @return a collection of all DataElements with the given aggregation
      * operator, or an empty collection if no DataElements have the
      * aggregation operator.
      */
-    List<DataElement> getDataElementsByAggregationOperator( String aggregationOperator );
+    List<DataElement> getDataElementsByAggregationType( AggregationType aggregationType );
 
     /**
      * Returns all DataElements with the given domain type.

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2015-09-15 05:52:21 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/table/JdbcAnalyticsTableManager.java	2015-09-15 09:54:24 +0000
@@ -28,20 +28,9 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.hisp.dhis.commons.util.TextUtils.getQuotedCommaDelimitedString;
-import static org.hisp.dhis.dataapproval.DataApprovalLevelService.APPROVAL_LEVEL_UNAPPROVED;
-import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE;
-import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.concurrent.Future;
-
+import com.google.common.collect.Lists;
 import org.apache.commons.lang.StringUtils;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.analytics.AnalyticsTable;
 import org.hisp.dhis.analytics.DataQueryParams;
 import org.hisp.dhis.common.ValueType;
@@ -57,22 +46,31 @@
 import org.hisp.dhis.util.ObjectUtils;
 import org.springframework.scheduling.annotation.Async;
 
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.Future;
+
+import static org.hisp.dhis.commons.util.TextUtils.getQuotedCommaDelimitedString;
+import static org.hisp.dhis.dataapproval.DataApprovalLevelService.APPROVAL_LEVEL_UNAPPROVED;
 
 /**
  * This class manages the analytics table. The analytics table is a denormalized
  * table designed for analysis which contains raw data values. It has columns for
  * each organisation unit group set and organisation unit level. Also, columns
  * for dataelementid, periodid, organisationunitid, categoryoptioncomboid, value.
- * 
- * The analytics table is horizontally partitioned. The partition key is the start 
- * date of the  period of the data record. The table is partitioned according to 
+ * <p>
+ * The analytics table is horizontally partitioned. The partition key is the start
+ * date of the  period of the data record. The table is partitioned according to
  * time span with one partition per calendar quarter.
- * 
+ * <p>
  * The data records in this table are not aggregated. Typically, queries will
  * aggregate in organisation unit hierarchy dimension, in the period/time dimension,
  * and the category dimensions, as well as organisation unit group set dimensions.
- * 
+ *
  * @author Lars Helge Overland
  */
 public class JdbcAnalyticsTableManager
@@ -81,29 +79,29 @@
     // -------------------------------------------------------------------------
     // Implementation
     // -------------------------------------------------------------------------
-    
+
     @Override
     public String validState()
     {
         boolean hasData = jdbcTemplate.queryForRowSet( "select dataelementid from datavalue limit 1" ).next();
-        
+
         if ( !hasData )
         {
             return "No data values exist, not updating aggregate analytics tables";
         }
-        
+
         int orgUnitLevels = organisationUnitService.getMaxOfOrganisationUnitLevels();
-        
+
         if ( orgUnitLevels == 0 )
         {
             return "No organisation unit levels exist, not updating aggregate analytics tables";
         }
 
         log.info( "Approval enabled: " + isApprovalEnabled() );
-        
+
         return null;
     }
-    
+
     @Override
     public String getTableName()
     {
@@ -116,88 +114,89 @@
         if ( isApprovalEnabled() )
         {
             resourceTableService.generateDataApprovalMinLevelTable();
-        }        
+        }
     }
-    
+
     @Override
     public void createTable( AnalyticsTable table )
     {
         final String tableName = table.getTempTableName();
-        
+
         final String dbl = statementBuilder.getDoubleColumnType();
-        
+
         final String sqlDrop = "drop table " + tableName;
-        
+
         executeSilently( sqlDrop );
-        
+
         String sqlCreate = "create table " + tableName + " (";
 
         List<String[]> columns = getDimensionColumns( table );
-        
+
         validateDimensionColumns( columns );
 
         for ( String[] col : columns )
         {
             sqlCreate += col[0] + " " + col[1] + ",";
         }
-        
+
         sqlCreate += "daysxvalue " + dbl + ", daysno integer not null, value " + dbl + ", textvalue varchar(50000)) ";
-        
+
         sqlCreate += statementBuilder.getTableOptions( false );
-        
+
         log.info( "Creating table: " + tableName + ", columns: " + columns.size() );
-        
+
         log.debug( "Create SQL: " + sqlCreate );
-        
+
         executeSilently( sqlCreate );
     }
-    
+
     @Override
     @Async
     public Future<?> populateTableAsync( ConcurrentLinkedQueue<AnalyticsTable> tables )
     {
         final String dbl = statementBuilder.getDoubleColumnType();
-        
+
         final String approvalClause = getApprovalJoinClause();
-        
-        taskLoop : while ( true )
+
+        taskLoop:
+        while ( true )
         {
             AnalyticsTable table = tables.poll();
-                
+
             if ( table == null )
             {
                 break taskLoop;
             }
-            
-            String intClause = 
+
+            String intClause =
                 "dv.value " + statementBuilder.getRegexpMatch() + " '" + MathUtils.NUMERIC_LENIENT_REGEXP + "' " +
-                "and ( dv.value != '0' or de.aggregationtype in ('" + AGGREGATION_OPERATOR_AVERAGE + ',' + AGGREGATION_OPERATOR_AVERAGE_SUM + "') " +
-                "or de.zeroissignificant = true ) ";
-            
+                    "and ( dv.value != '0' or de.aggregationtype in ('" + AggregationType.AVERAGE + ',' + AggregationType.AVERAGE_SUM_ORG_UNIT + "') " +
+                    "or de.zeroissignificant = true ) ";
+
             populateTable( table, "cast(dv.value as " + dbl + ")", "null", ValueType.NUMERIC_TYPES, intClause, approvalClause );
-            
+
             populateTable( table, "1", "null", Lists.newArrayList( ValueType.BOOLEAN ), "dv.value = 'true'", approvalClause );
-    
+
             populateTable( table, "0", "null", Lists.newArrayList( ValueType.BOOLEAN ), "dv.value = 'false'", approvalClause );
-            
+
             populateTable( table, "1", "null", Lists.newArrayList( ValueType.TRUE_ONLY ), "dv.value = 'true'", approvalClause );
-            
+
             populateTable( table, "null", "dv.value", ValueType.TEXT_TYPES, null, approvalClause );
         }
-    
+
         return null;
     }
-    
+
     /**
      * Populates the given analytics table.
-     * 
-     * @param table analytics table to populate.
-     * @param valueExpression numeric value expression.
+     *
+     * @param table               analytics table to populate.
+     * @param valueExpression     numeric value expression.
      * @param textValueExpression textual value expression.
-     * @param valueTypes data element value types to include data for.
-     * @param whereClause where clause to constrain data query.
+     * @param valueTypes          data element value types to include data for.
+     * @param whereClause         where clause to constrain data query.
      */
-    private void populateTable( AnalyticsTable table, String valueExpression, 
+    private void populateTable( AnalyticsTable table, String valueExpression,
         String textValueExpression, List<ValueType> valueTypes, String whereClause, String approvalClause )
     {
         final String start = DateUtils.getMediumDateString( table.getPeriod().getStartDate() );
@@ -208,49 +207,49 @@
         String sql = "insert into " + table.getTempTableName() + " (";
 
         List<String[]> columns = getDimensionColumns( table );
-        
+
         validateDimensionColumns( columns );
 
         for ( String[] col : columns )
         {
             sql += col[0] + ",";
         }
-        
+
         sql += "daysxvalue, daysno, value, textvalue) select ";
-        
+
         for ( String[] col : columns )
         {
             sql += col[2] + ",";
         }
-        
-        sql += 
+
+        sql +=
             valueExpression + " * ps.daysno as daysxvalue, " +
-            "ps.daysno as daysno, " +
-            valueExpression + " as value, " +
-            textValueExpression + " as textvalue " +
-            "from datavalue dv " +
-            "left join _dataelementgroupsetstructure degs on dv.dataelementid=degs.dataelementid " +
-            "left join _organisationunitgroupsetstructure ougs on dv.sourceid=ougs.organisationunitid " +
-            "left join _categoryoptiongroupsetstructure cogs on dv.categoryoptioncomboid=cogs.categoryoptioncomboid " +
-            "left join _categoryoptiongroupsetstructure aogs on dv.attributeoptioncomboid=aogs.categoryoptioncomboid " +
-            "left join _categorystructure dcs on dv.categoryoptioncomboid=dcs.categoryoptioncomboid " +
-            "left join _categorystructure acs on dv.attributeoptioncomboid=acs.categoryoptioncomboid " +
-            "left join _orgunitstructure ous on dv.sourceid=ous.organisationunitid " +
-            "left join _dataelementstructure des on dv.dataelementid = des.dataelementid " +
-            "inner join dataelement de on dv.dataelementid=de.dataelementid " +
-            "inner join categoryoptioncombo co on dv.categoryoptioncomboid=co.categoryoptioncomboid " +
-            "inner join categoryoptioncombo ao on dv.attributeoptioncomboid=ao.categoryoptioncomboid " +
-            "inner join _categoryoptioncomboname aon on dv.attributeoptioncomboid=aon.categoryoptioncomboid " +
-            "inner join period pe on dv.periodid=pe.periodid " +
-            "inner join _periodstructure ps on dv.periodid=ps.periodid " +
-            "inner join organisationunit ou on dv.sourceid=ou.organisationunitid " +
-            approvalClause +
-            "where de.valuetype in (" + valTypes + ") " +
-            "and de.domaintype = 'AGGREGATE' " +
-            "and pe.startdate >= '" + start + "' " +
-            "and pe.startdate <= '" + end + "' " +
-            "and dv.value is not null ";
-        
+                "ps.daysno as daysno, " +
+                valueExpression + " as value, " +
+                textValueExpression + " as textvalue " +
+                "from datavalue dv " +
+                "left join _dataelementgroupsetstructure degs on dv.dataelementid=degs.dataelementid " +
+                "left join _organisationunitgroupsetstructure ougs on dv.sourceid=ougs.organisationunitid " +
+                "left join _categoryoptiongroupsetstructure cogs on dv.categoryoptioncomboid=cogs.categoryoptioncomboid " +
+                "left join _categoryoptiongroupsetstructure aogs on dv.attributeoptioncomboid=aogs.categoryoptioncomboid " +
+                "left join _categorystructure dcs on dv.categoryoptioncomboid=dcs.categoryoptioncomboid " +
+                "left join _categorystructure acs on dv.attributeoptioncomboid=acs.categoryoptioncomboid " +
+                "left join _orgunitstructure ous on dv.sourceid=ous.organisationunitid " +
+                "left join _dataelementstructure des on dv.dataelementid = des.dataelementid " +
+                "inner join dataelement de on dv.dataelementid=de.dataelementid " +
+                "inner join categoryoptioncombo co on dv.categoryoptioncomboid=co.categoryoptioncomboid " +
+                "inner join categoryoptioncombo ao on dv.attributeoptioncomboid=ao.categoryoptioncomboid " +
+                "inner join _categoryoptioncomboname aon on dv.attributeoptioncomboid=aon.categoryoptioncomboid " +
+                "inner join period pe on dv.periodid=pe.periodid " +
+                "inner join _periodstructure ps on dv.periodid=ps.periodid " +
+                "inner join organisationunit ou on dv.sourceid=ou.organisationunitid " +
+                approvalClause +
+                "where de.valuetype in (" + valTypes + ") " +
+                "and de.domaintype = 'AGGREGATE' " +
+                "and pe.startdate >= '" + start + "' " +
+                "and pe.startdate <= '" + end + "' " +
+                "and dv.value is not null ";
+
         if ( whereClause != null )
         {
             sql += "and " + whereClause;
@@ -270,19 +269,19 @@
         {
             String sql =
                 "left join _dataapprovalminlevel da " +
-                "on des.datasetid=da.datasetid and da.periodid=dv.periodid and da.attributeoptioncomboid=dv.attributeoptioncomboid " +
-                "and (";
+                    "on des.datasetid=da.datasetid and da.periodid=dv.periodid and da.attributeoptioncomboid=dv.attributeoptioncomboid " +
+                    "and (";
 
             Set<OrganisationUnitLevel> levels = dataApprovalLevelService.getOrganisationUnitApprovalLevels();
-            
+
             for ( OrganisationUnitLevel level : levels )
             {
                 sql += "ous.idlevel" + level.getLevel() + " = da.organisationunitid or ";
             }
-            
+
             return TextUtils.removeLastOr( sql ) + ") ";
         }
-        
+
         return StringUtils.EMPTY;
     }
 
@@ -293,31 +292,31 @@
 
         List<DataElementGroupSet> dataElementGroupSets =
             idObjectManager.getDataDimensionsNoAcl( DataElementGroupSet.class );
-        
-        List<OrganisationUnitGroupSet> orgUnitGroupSets = 
+
+        List<OrganisationUnitGroupSet> orgUnitGroupSets =
             idObjectManager.getDataDimensionsNoAcl( OrganisationUnitGroupSet.class );
-        
+
         List<CategoryOptionGroupSet> disaggregationCategoryOptionGroupSets =
             categoryService.getDisaggregationCategoryOptionGroupSetsNoAcl();
-        
+
         List<CategoryOptionGroupSet> attributeCategoryOptionGroupSets =
             categoryService.getAttributeCategoryOptionGroupSetsNoAcl();
-        
+
         List<DataElementCategory> disaggregationCategories =
             categoryService.getDisaggregationDataDimensionCategoriesNoAcl();
-        
+
         List<DataElementCategory> attributeCategories =
             categoryService.getAttributeDataDimensionCategoriesNoAcl();
 
         List<OrganisationUnitLevel> levels =
             organisationUnitService.getOrganisationUnitLevels();
-        
+
         for ( DataElementGroupSet groupSet : dataElementGroupSets )
         {
             String[] col = { quote( groupSet.getUid() ), "character(11)", "degs." + quote( groupSet.getUid() ) };
             columns.add( col );
         }
-        
+
         for ( OrganisationUnitGroupSet groupSet : orgUnitGroupSets )
         {
             String[] col = { quote( groupSet.getUid() ), "character(11)", "ougs." + quote( groupSet.getUid() ) };
@@ -335,102 +334,103 @@
             String[] col = { quote( groupSet.getUid() ), "character(11)", "aogs." + quote( groupSet.getUid() ) };
             columns.add( col );
         }
-        
+
         for ( DataElementCategory category : disaggregationCategories )
         {
             String[] col = { quote( category.getUid() ), "character(11)", "dcs." + quote( category.getUid() ) };
             columns.add( col );
         }
-        
+
         for ( DataElementCategory category : attributeCategories )
         {
             String[] col = { quote( category.getUid() ), "character(11)", "acs." + quote( category.getUid() ) };
             columns.add( col );
         }
-        
+
         for ( OrganisationUnitLevel level : levels )
         {
             String column = quote( PREFIX_ORGUNITLEVEL + level.getLevel() );
             String[] col = { column, "character(11)", "ous." + column };
             columns.add( col );
         }
-        
+
         List<PeriodType> periodTypes = PeriodType.getAvailablePeriodTypes();
-        
+
         for ( PeriodType periodType : periodTypes )
         {
             String column = quote( periodType.getName().toLowerCase() );
             String[] col = { column, "character varying(15)", "ps." + column };
             columns.add( col );
         }
-        
+
         String[] de = { quote( "dx" ), "character(11) not null", "de.uid" };
         String[] co = { quote( "co" ), "character(11) not null", "co.uid" };
         String[] ao = { quote( "ao" ), "character(11) not null", "ao.uid" };
         String[] ou = { quote( "ou" ), "character(11) not null", "ou.uid" };
         String[] level = { quote( "level" ), "integer", "ous.level" };
-        
+
         columns.addAll( Lists.newArrayList( de, co, ao, ou, level ) );
 
         if ( isApprovalEnabled() )
         {
             String col = "coalesce(des.datasetapprovallevel, aon.approvallevel, da.minlevel, " + APPROVAL_LEVEL_UNAPPROVED + ")";
-            
+
             String[] al = { quote( "approvallevel" ), "integer", col };
             columns.add( al );
         }
-        
+
         return columns;
     }
-    
+
     @Override
     public List<Integer> getDataYears( Date earliest )
     {
-        String sql = 
+        String sql =
             "select distinct(extract(year from pe.startdate)) " +
-            "from datavalue dv " +
-            "inner join period pe on dv.periodid=pe.periodid " +
-            "where pe.startdate is not null ";
-        
+                "from datavalue dv " +
+                "inner join period pe on dv.periodid=pe.periodid " +
+                "where pe.startdate is not null ";
+
         if ( earliest != null )
         {
             sql += "and pe.startdate >= '" + DateUtils.getMediumDateString( earliest ) + "'";
         }
-        
+
         return jdbcTemplate.queryForList( sql, Integer.class );
     }
-    
+
     @Override
     @Async
     public Future<?> applyAggregationLevels( ConcurrentLinkedQueue<AnalyticsTable> tables, Collection<String> dataElements, int aggregationLevel )
     {
-        taskLoop : while ( true )
+        taskLoop:
+        while ( true )
         {
             AnalyticsTable table = tables.poll();
-                
+
             if ( table == null )
             {
                 break taskLoop;
             }
-            
+
             StringBuilder sql = new StringBuilder( "update " + table.getTempTableName() + " set " );
-            
+
             for ( int i = 0; i < aggregationLevel; i++ )
             {
                 int level = i + 1;
-                
+
                 String column = quote( DataQueryParams.LEVEL_PREFIX + level );
-                
+
                 sql.append( column + " = null," );
             }
-            
+
             sql.deleteCharAt( sql.length() - ",".length() );
-            
+
             sql.append( " where level > " + aggregationLevel );
             sql.append( " and dx in (" + getQuotedCommaDelimitedString( dataElements ) + ")" );
-            
+
             log.debug( "Aggregation level SQL: " + sql.toString() );
-            
+
             jdbcTemplate.execute( sql.toString() );
         }
 
@@ -441,22 +441,23 @@
     @Async
     public Future<?> vacuumTablesAsync( ConcurrentLinkedQueue<AnalyticsTable> tables )
     {
-        taskLoop : while ( true )
+        taskLoop:
+        while ( true )
         {
             AnalyticsTable table = tables.poll();
-            
+
             if ( table == null )
             {
                 break taskLoop;
             }
-            
+
             final String sql = statementBuilder.getVacuum( table.getTempTableName() );
-            
+
             log.debug( "Vacuum SQL: " + sql );
-            
+
             jdbcTemplate.execute( sql );
         }
-        
+
         return null;
     }
 
@@ -468,7 +469,7 @@
     {
         boolean setting = systemSettingManager.hideUnapprovedDataInAnalytics();
         boolean levels = !dataApprovalLevelService.getAllDataApprovalLevels().isEmpty();
-        
+
         return setting && levels;
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java	2015-09-04 13:51:59 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/DataQueryGroupsTest.java	2015-09-15 09:54:24 +0000
@@ -39,8 +39,6 @@
 import java.util.List;
 
 import static org.hisp.dhis.common.NameableObjectUtils.getList;
-import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM;
-import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_SUM;
 import static org.junit.Assert.*;
 
 /**
@@ -74,13 +72,13 @@
     @Before
     public void before()
     {
-        deA = createDataElement( 'A', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
-        deB = createDataElement( 'B', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
-        deC = createDataElement( 'C', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
-        deD = createDataElement( 'D', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
-        deE = createDataElement( 'E', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
-        deF = createDataElement( 'F', ValueType.INTEGER, AGGREGATION_OPERATOR_AVERAGE_SUM );
-        deG = createDataElement( 'G', ValueType.INTEGER, AGGREGATION_OPERATOR_AVERAGE_SUM );
+        deA = createDataElement( 'A', ValueType.INTEGER, AggregationType.SUM );
+        deB = createDataElement( 'B', ValueType.INTEGER, AggregationType.SUM );
+        deC = createDataElement( 'C', ValueType.INTEGER, AggregationType.SUM );
+        deD = createDataElement( 'D', ValueType.INTEGER, AggregationType.SUM );
+        deE = createDataElement( 'E', ValueType.INTEGER, AggregationType.SUM );
+        deF = createDataElement( 'F', ValueType.INTEGER, AggregationType.AVERAGE_SUM_ORG_UNIT );
+        deG = createDataElement( 'G', ValueType.INTEGER, AggregationType.AVERAGE_SUM_ORG_UNIT );
 
         ouA = createOrganisationUnit( 'A' );
         ouB = createOrganisationUnit( 'B' );

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java	2015-09-04 10:49:08 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/data/QueryPlannerTest.java	2015-09-15 09:54:24 +0000
@@ -29,6 +29,7 @@
  */
 
 import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.analytics.DataQueryGroups;
 import org.hisp.dhis.analytics.DataQueryParams;
 import org.hisp.dhis.analytics.DimensionItem;
@@ -67,11 +68,8 @@
 import java.util.Map;
 
 import static org.hisp.dhis.analytics.AnalyticsTableManager.ANALYTICS_TABLE_NAME;
-import static org.hisp.dhis.common.DimensionalObject.DIMENSION_SEP;
-import static org.hisp.dhis.common.DimensionalObject.ORGUNIT_DIM_ID;
-import static org.hisp.dhis.common.DimensionalObject.PERIOD_DIM_ID;
+import static org.hisp.dhis.common.DimensionalObject.*;
 import static org.hisp.dhis.common.NameableObjectUtils.getList;
-import static org.hisp.dhis.dataelement.DataElement.*;
 import static org.junit.Assert.*;
 
 /**
@@ -142,14 +140,14 @@
 
         indicatorService.addIndicator( inA );
 
-        deA = createDataElement( 'A', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
-        deB = createDataElement( 'B', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
-        deC = createDataElement( 'C', ValueType.INTEGER, AGGREGATION_OPERATOR_AVERAGE_SUM );
-        deD = createDataElement( 'D', ValueType.INTEGER, AGGREGATION_OPERATOR_AVERAGE_SUM );
-        deE = createDataElement( 'E', ValueType.TEXT, AGGREGATION_OPERATOR_NONE );
-        deF = createDataElement( 'F', ValueType.TEXT, AGGREGATION_OPERATOR_NONE );
-        deG = createDataElement( 'G', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
-        deH = createDataElement( 'H', ValueType.INTEGER, AGGREGATION_OPERATOR_SUM );
+        deA = createDataElement( 'A', ValueType.INTEGER, AggregationType.SUM );
+        deB = createDataElement( 'B', ValueType.INTEGER, AggregationType.SUM );
+        deC = createDataElement( 'C', ValueType.INTEGER, AggregationType.AVERAGE_SUM_ORG_UNIT );
+        deD = createDataElement( 'D', ValueType.INTEGER, AggregationType.AVERAGE_SUM_ORG_UNIT );
+        deE = createDataElement( 'E', ValueType.TEXT, AggregationType.NONE );
+        deF = createDataElement( 'F', ValueType.TEXT, AggregationType.NONE );
+        deG = createDataElement( 'G', ValueType.INTEGER, AggregationType.SUM );
+        deH = createDataElement( 'H', ValueType.INTEGER, AggregationType.SUM );
 
         dataElementService.addDataElement( deA );
         dataElementService.addDataElement( deB );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2015-09-03 04:31:39 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java	2015-09-15 09:54:24 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.GenericDimensionalObjectStore;
 import org.hisp.dhis.common.GenericNameableObjectStore;
 import org.hisp.dhis.common.ListMap;
@@ -204,9 +205,9 @@
     }
 
     @Override
-    public List<DataElement> getDataElementsByAggregationOperator( String aggregationOperator )
+    public List<DataElement> getDataElementsByAggregationType( AggregationType aggregationType )
     {
-        return i18n( i18nService, dataElementStore.getDataElementsByAggregationOperator( aggregationOperator ) );
+        return i18n( i18nService, dataElementStore.getDataElementsByAggregationType( aggregationType ) );
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java	2015-09-04 05:55:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java	2015-09-15 09:54:24 +0000
@@ -34,6 +34,7 @@
 import org.hibernate.Query;
 import org.hibernate.criterion.Order;
 import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.ListMap;
 import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
@@ -86,9 +87,9 @@
 
     @Override
     @SuppressWarnings( "unchecked" )
-    public List<DataElement> getDataElementsByAggregationOperator( String aggregationOperator )
+    public List<DataElement> getDataElementsByAggregationType( AggregationType aggregationType )
     {
-        return getCriteria( Restrictions.eq( "aggregationOperator", aggregationOperator ) ).list();
+        return getCriteria( Restrictions.eq( "aggregationType", aggregationType ) ).list();
     }
 
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java	2015-09-14 11:56:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/InitTableAlteror.java	2015-09-15 09:54:24 +0000
@@ -66,11 +66,12 @@
         executeSql( "UPDATE programstageinstance SET status='ACTIVE' WHERE status='0';" );
         executeSql( "UPDATE programstageinstance SET status='COMPLETED' WHERE status='1';" );
         executeSql( "UPDATE programstageinstance SET status='SKIPPED' WHERE status='5';" );
-        
+
         executeSql( "ALTER TABLE program DROP COLUMN displayonallorgunit" );
-        
+
         upgradeProgramStageDataElements();
         updateValueTypes();
+        updateAggregationTypes();
 
         executeSql( "ALTER TABLE program ALTER COLUMN \"type\" TYPE varchar(255);" );
         executeSql( "update program set \"type\"='WITH_REGISTRATION' where type='1' or type='2'" );
@@ -81,6 +82,23 @@
     // Supportive methods
     // -------------------------------------------------------------------------
 
+    private void updateAggregationTypes()
+    {
+        executeSql( "alter table dataelement alter column aggregationtype type varchar(50)" );
+
+        executeSql( "update dataelement set aggregationtype='SUM' where aggregationtype='sum'" );
+        executeSql( "update dataelement set aggregationtype='AVERAGE' where aggregationtype='avg'" );
+        executeSql( "update dataelement set aggregationtype='AVERAGE_SUM_ORG_UNIT' where aggregationtype='avg_sum_org_unit'" );
+        executeSql( "update dataelement set aggregationtype='COUNT' where aggregationtype='count'" );
+        executeSql( "update dataelement set aggregationtype='STDDEV' where aggregationtype='stddev'" );
+        executeSql( "update dataelement set aggregationtype='VARIANCE' where aggregationtype='variance'" );
+        executeSql( "update dataelement set aggregationtype='MIN' where aggregationtype='min'" );
+        executeSql( "update dataelement set aggregationtype='MAX' where aggregationtype='max'" );
+        executeSql( "update dataelement set aggregationtype='NONE' where aggregationtype='none'" );
+        executeSql( "update dataelement set aggregationtype='DEFAULT' where aggregationtype='default'" );
+        executeSql( "update dataelement set aggregationtype='CUSTOM' where aggregationtype='custom'" );
+    }
+
     private void updateValueTypes()
     {
         executeSql( "alter table dataelement alter column valuetype type varchar(50)" );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml	2015-09-04 11:23:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml	2015-09-15 09:54:24 +0000
@@ -32,7 +32,13 @@
 
     <property name="domainType" column="domainType" type="org.hisp.dhis.dataelement.DataElementDomainUserType" not-null="true" />
 
-    <property name="aggregationOperator" not-null="true" column="aggregationtype" length="16" />
+    <property name="aggregationType" length="50" column="aggregationtype">
+      <type name="org.hibernate.type.EnumType">
+        <param name="enumClass">org.hisp.dhis.analytics.AggregationType</param>
+        <param name="useNamed">true</param>
+        <param name="type">12</param>
+      </type>
+    </property>
 
     <many-to-one name="categoryCombo" class="org.hisp.dhis.dataelement.DataElementCategoryCombo"
       column="categorycomboid" foreign-key="fk_dataelement_categorycomboid" />

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java	2015-09-04 09:29:23 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java	2015-09-15 09:54:24 +0000
@@ -29,6 +29,7 @@
  */
 
 import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.ValueType;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -279,27 +280,27 @@
     }
 
     @Test
-    public void testGetDataElementsByAggregationOperator()
+    public void testGetDataElementsByAggregationType()
     {
-        assertEquals( 0, dataElementService.getDataElementsByAggregationOperator( DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM ).size() );
-        assertEquals( 0, dataElementService.getDataElementsByAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM ).size() );
+        assertEquals( 0, dataElementService.getDataElementsByAggregationType( AggregationType.AVERAGE_SUM_ORG_UNIT ).size() );
+        assertEquals( 0, dataElementService.getDataElementsByAggregationType( AggregationType.SUM ).size() );
 
         DataElement dataElementA = createDataElement( 'A' );
-        dataElementA.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM );
+        dataElementA.setAggregationType( AggregationType.AVERAGE_SUM_ORG_UNIT );
         DataElement dataElementB = createDataElement( 'B' );
-        dataElementB.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElementB.setAggregationType( AggregationType.SUM );
         DataElement dataElementC = createDataElement( 'C' );
-        dataElementC.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElementC.setAggregationType( AggregationType.SUM );
         DataElement dataElementD = createDataElement( 'D' );
-        dataElementD.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElementD.setAggregationType( AggregationType.SUM );
 
         dataElementService.addDataElement( dataElementA );
         dataElementService.addDataElement( dataElementB );
         dataElementService.addDataElement( dataElementC );
         dataElementService.addDataElement( dataElementD );
 
-        assertEquals( 1, dataElementService.getDataElementsByAggregationOperator( DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM ).size() );
-        assertEquals( 3, dataElementService.getDataElementsByAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM ).size() );
+        assertEquals( 1, dataElementService.getDataElementsByAggregationType( AggregationType.AVERAGE_SUM_ORG_UNIT ).size() );
+        assertEquals( 3, dataElementService.getDataElementsByAggregationType( AggregationType.SUM ).size() );
     }
 
     @Test

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementStoreTest.java	2015-09-13 17:45:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementStoreTest.java	2015-09-15 09:54:24 +0000
@@ -29,6 +29,7 @@
  */
 
 import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.dataset.DataSet;
 import org.hisp.dhis.dataset.DataSetService;
@@ -252,27 +253,27 @@
     }
 
     @Test
-    public void testGetDataElementsByAggregationOperator()
+    public void testGetDataElementsByAggregationType()
     {
-        assertEquals( 0, dataElementStore.getDataElementsByAggregationOperator( DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM ).size() );
-        assertEquals( 0, dataElementStore.getDataElementsByAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM ).size() );
+        assertEquals( 0, dataElementStore.getDataElementsByAggregationType( AggregationType.AVERAGE_SUM_ORG_UNIT ).size() );
+        assertEquals( 0, dataElementStore.getDataElementsByAggregationType( AggregationType.SUM ).size() );
 
         DataElement dataElementA = createDataElement( 'A' );
-        dataElementA.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM );
+        dataElementA.setAggregationType( AggregationType.AVERAGE_SUM_ORG_UNIT );
         DataElement dataElementB = createDataElement( 'B' );
-        dataElementB.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElementB.setAggregationType( AggregationType.SUM );
         DataElement dataElementC = createDataElement( 'C' );
-        dataElementC.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElementC.setAggregationType( AggregationType.SUM );
         DataElement dataElementD = createDataElement( 'D' );
-        dataElementD.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElementD.setAggregationType( AggregationType.SUM );
 
         dataElementStore.save( dataElementA );
         dataElementStore.save( dataElementB );
         dataElementStore.save( dataElementC );
         dataElementStore.save( dataElementD );
 
-        assertEquals( 1, dataElementStore.getDataElementsByAggregationOperator( DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM ).size() );
-        assertEquals( 3, dataElementStore.getDataElementsByAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM ).size() );
+        assertEquals( 1, dataElementStore.getDataElementsByAggregationType( AggregationType.AVERAGE_SUM_ORG_UNIT ).size() );
+        assertEquals( 3, dataElementStore.getDataElementsByAggregationType( AggregationType.SUM ).size() );
     }
 
     @Test

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/minmax/MinMaxDataElementStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/minmax/MinMaxDataElementStoreTest.java	2015-09-13 17:45:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/minmax/MinMaxDataElementStoreTest.java	2015-09-15 09:54:24 +0000
@@ -29,6 +29,7 @@
  */
 
 import org.hisp.dhis.DhisSpringTest;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -76,28 +77,28 @@
         DataElement dataElement1 = new DataElement();
         dataElement1.setName( "DE1name" );
         dataElement1.setShortName( "DE1sname" );
-        dataElement1.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElement1.setAggregationType( AggregationType.SUM );
         dataElement1.setValueType( ValueType.INTEGER );
         dataElement1.setDomainType( DataElementDomain.AGGREGATE );
 
         DataElement dataElement2 = new DataElement();
         dataElement2.setName( "DE2name" );
         dataElement2.setShortName( "DE2sname" );
-        dataElement2.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElement2.setAggregationType( AggregationType.SUM );
         dataElement2.setValueType( ValueType.INTEGER );
         dataElement2.setDomainType( DataElementDomain.AGGREGATE );
 
         DataElement dataElement3 = new DataElement();
         dataElement3.setName( "DE3name" );
         dataElement3.setShortName( "DE3sname" );
-        dataElement3.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElement3.setAggregationType( AggregationType.SUM );
         dataElement3.setValueType( ValueType.INTEGER );
         dataElement3.setDomainType( DataElementDomain.AGGREGATE );
 
         DataElement dataElement4 = new DataElement();
         dataElement4.setName( "DE4name" );
         dataElement4.setShortName( "DE4sname" );
-        dataElement4.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElement4.setAggregationType( AggregationType.SUM );
         dataElement4.setValueType( ValueType.INTEGER );
         dataElement4.setDomainType( DataElementDomain.AGGREGATE );
 

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java	2015-09-14 10:23:17 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/csv/DefaultCsvImportService.java	2015-09-15 09:54:24 +0000
@@ -30,6 +30,7 @@
 
 import com.csvreader.CsvReader;
 import org.apache.commons.lang3.StringUtils;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.BaseIdentifiableObject;
 import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.common.IdentifiableObject;
@@ -195,7 +196,7 @@
                 object.setDomainType( DataElementDomain.fromValue( domainType ) );
                 object.setValueType( ValueType.valueOf( getSafe( values, 7, ValueType.TEXT.toString(), 50 ) ) );
 
-                object.setAggregationOperator( getSafe( values, 8, DataElement.AGGREGATION_OPERATOR_SUM, 16 ) );
+                object.setAggregationType( AggregationType.valueOf( getSafe( values, 8, AggregationType.SUM.toString(), 50 ) ) );
                 String categoryComboUid = getSafe( values, 9, null, 11 );
                 object.setUrl( getSafe( values, 10, null, 255 ) );
                 object.setZeroIsSignificant( Boolean.valueOf( getSafe( values, 11, "false", null ) ) );

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/typehandler/AggregationOperatorTypeHandler.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/typehandler/AggregationOperatorTypeHandler.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/file/typehandler/AggregationOperatorTypeHandler.java	2015-09-15 09:54:24 +0000
@@ -28,15 +28,14 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.sql.SQLException;
-
+import com.ibatis.sqlmap.client.extensions.ParameterSetter;
+import com.ibatis.sqlmap.client.extensions.ResultGetter;
+import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.dataelement.DataElement;
 
-import com.ibatis.sqlmap.client.extensions.ParameterSetter;
-import com.ibatis.sqlmap.client.extensions.ResultGetter;
-import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;
+import java.sql.SQLException;
 
 /**
  * @author Lars Helge Overland
@@ -48,11 +47,11 @@
     private static final String JDBC_SUM = "Sum";
     private static final String JDBC_AVERAGE = "Avg";
     private static final String JDBC_COUNT = "Count";
-    
+
     private static final Integer NON_EXISTING = -1;
-    
+
     private static final Log log = LogFactory.getLog( AggregationOperatorTypeHandler.class );
-    
+
     // -------------------------------------------------------------------------
     // TypeHandlerCallback implementation
     // -------------------------------------------------------------------------
@@ -60,9 +59,12 @@
     @Override
     public Object getResult( ResultGetter getter )
         throws SQLException
-    {   
+    {
+        return null;
+
+        /*
         String result = getter.getString();
-        
+
         if ( result != null )
         {
             if ( result.equalsIgnoreCase( JDBC_SUM ) )
@@ -90,22 +92,25 @@
             
             return DataElement.AGGREGATION_OPERATOR_SUM;
         }
+        */
     }
-    
+
     @Override
     public void setParameter( ParameterSetter setter, Object parameter )
         throws SQLException
     {
         // Not in use
     }
-    
+
     @Override
     public Object valueOf( String result )
     {
+        return result;
+        /*
         if ( result == null )
         {
             return NON_EXISTING;
-        }        
+        }
         else if ( result.equalsIgnoreCase( JDBC_SUM ) )
         {
             return DataElement.AGGREGATION_OPERATOR_SUM;
@@ -122,5 +127,6 @@
         {
             throw new RuntimeException( "Illegal aggregation operator: " + result );
         }
+        */
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ExpressionConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ExpressionConverter.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/Dhis14ExpressionConverter.java	2015-09-15 09:54:24 +0000
@@ -154,7 +154,8 @@
                     throw new IllegalArgumentException( "Data element with id: " + dataElementId + " does not exist / have an aggregation operator" );
                 }
                 
-                char type = aggregationOperator.equals( DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM ) ? 'S' : 'R';
+                // char type = aggregationOperator.equals( DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM ) ? 'S' : 'R';
+                char type = 'S';
                 
                 match = "Sum([" + type + dataElementId + "])";
                 

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java	2015-09-15 05:29:37 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataElementConverter.java	2015-09-15 09:54:24 +0000
@@ -250,8 +250,10 @@
 
                 writer.closeElement();
 
+                /*
                 NameMappingUtil.addDataElementAggregationOperatorMapping( object.getId(),
                     object.getAggregationOperator() );
+                    */
             }
         }
     }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java	2015-09-04 07:09:36 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java	2015-09-15 09:54:24 +0000
@@ -133,7 +133,7 @@
                 writer.writeElement( FIELD_DESCRIPTION, element.getDescription() );
                 writer.writeElement( FIELD_VALUE_TYPE, element.getValueType().toString() );
                 writer.writeElement( FIELD_DOMAIN_TYPE, element.getDomainType().getValue() );
-                writer.writeElement( FIELD_AGGREGATION_OPERATOR, element.getAggregationOperator() );
+                // writer.writeElement( FIELD_AGGREGATION_OPERATOR, element.getAggregationOperator() );
                 writer.writeElement( FIELD_CATEGORY_COMBO, String.valueOf( element.getCategoryCombo().getId() ) );
                 writer.writeElement( FIELD_LAST_UPDATED, DateUtils.getMediumDateString( element.getLastUpdated(), EMPTY ) );
 
@@ -174,7 +174,7 @@
             element.setDescription( values.get( FIELD_DESCRIPTION ) );
             element.setValueType( ValueType.valueOf( values.get( FIELD_VALUE_TYPE ) ) );
             element.setDomainType( DataElementDomain.fromValue( values.get( FIELD_DOMAIN_TYPE ) ) );
-            element.setAggregationOperator( values.get( FIELD_AGGREGATION_OPERATOR ) );
+            // element.setAggregationOperator( values.get( FIELD_AGGREGATION_OPERATOR ) );
             element.getCategoryCombo().setId( categoryComboMapping.get( Integer.parseInt( values.get( FIELD_CATEGORY_COMBO ) ) ) );
             element.setLastUpdated( DateUtils.getMediumDate( values.get( FIELD_LAST_UPDATED ) ) );
 

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataElementImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataElementImporter.java	2015-09-04 07:12:38 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/DataElementImporter.java	2015-09-15 09:54:24 +0000
@@ -59,7 +59,7 @@
     public void importObject( DataElement object, ImportParams params )
     {
         NameMappingUtil.addDataElementMapping( object.getId(), object.getName() );
-        NameMappingUtil.addDataElementAggregationOperatorMapping( object.getId(), object.getAggregationOperator() );
+        // NameMappingUtil.addDataElementAggregationOperatorMapping( object.getId(), object.getAggregationOperator() );
 
         read( object, GroupMemberType.NONE, params );
     }
@@ -79,7 +79,7 @@
         match.setDescription( object.getDescription() );
         match.setValueType( object.getValueType() );
         match.setDomainType( object.getDomainType() );
-        match.setAggregationOperator( object.getAggregationOperator() );
+        match.setAggregationType( object.getAggregationType() );
         match.setLastUpdated( object.getLastUpdated() );
 
         dataElementService.updateDataElement( match );
@@ -129,7 +129,7 @@
         {
             return false;
         }
-        if ( !object.getAggregationOperator().equals( existing.getAggregationOperator() ) )
+        if ( !object.getAggregationType().equals( existing.getAggregationType() ) )
         {
             return false;
         }

=== modified file 'dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandler.java'
--- dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandler.java	2015-09-04 09:29:23 +0000
+++ dhis-2/dhis-support/dhis-support-jdbc/src/main/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandler.java	2015-09-15 09:54:24 +0000
@@ -117,7 +117,7 @@
         statementBuilder.setValue( dataElement.getDescription() );
         statementBuilder.setValue( dataElement.getValueType() );
         statementBuilder.setValue( dataElement.getDomainType().name() );
-        statementBuilder.setValue( dataElement.getAggregationOperator() );
+        // statementBuilder.setValue( dataElement.getAggregationOperator() );
         statementBuilder.setValue( dataElement.getCategoryCombo().getId() );
         statementBuilder.setValue( dataElement.isZeroIsSignificant() );
     }

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ReflectionUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ReflectionUtilsTest.java	2015-05-30 13:36:07 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ReflectionUtilsTest.java	2015-09-15 09:54:24 +0000
@@ -28,24 +28,18 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.hisp.dhis.system.util.ReflectionUtils.getClassName;
-import static org.hisp.dhis.system.util.ReflectionUtils.getId;
-import static org.hisp.dhis.system.util.ReflectionUtils.getProperty;
-import static org.hisp.dhis.system.util.ReflectionUtils.isCollection;
-import static org.hisp.dhis.system.util.ReflectionUtils.setProperty;
+import org.hisp.dhis.analytics.AggregationType;
+import org.hisp.dhis.dataelement.DataElement;
+import org.junit.Before;
+import org.junit.Test;
 
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 
-import org.hisp.dhis.dataelement.DataElement;
-import org.junit.Before;
-import org.junit.Test;
+import static org.hisp.dhis.system.util.ReflectionUtils.*;
+import static org.junit.Assert.*;
 
 /**
  * @author Lars Helge Overland
@@ -53,57 +47,56 @@
 public class ReflectionUtilsTest
 {
     private DataElement dataElementA;
-    
+
     @Before
     public void before()
     {
         dataElementA = new DataElement();
         dataElementA.setId( 8 );
         dataElementA.setName( "NameA" );
-        dataElementA.setAggregationOperator( "Sum" );
+        dataElementA.setAggregationType( AggregationType.SUM );
     }
-    
-    
+
     @Test
     public void testGetId()
     {
         assertEquals( 8, getId( dataElementA ) );
     }
-    
+
     @Test
     public void testGetProperty()
     {
         assertEquals( "NameA", getProperty( dataElementA, "name" ) );
         assertNull( getProperty( dataElementA, "color" ) );
     }
-    
+
     @Test
     public void testSetProperty()
     {
         setProperty( dataElementA, "shortName", "ShortNameA" );
-        
+
         assertEquals( "ShortNameA", dataElementA.getShortName() );
     }
-    
-    @Test( expected=UnsupportedOperationException.class )
+
+    @Test( expected = UnsupportedOperationException.class )
     public void testSetPropertyException()
     {
         setProperty( dataElementA, "color", "Blue" );
     }
-    
+
     @Test
     public void testGetClassName()
     {
         assertEquals( "DataElement", getClassName( dataElementA ) );
     }
-    
+
     @Test
     public void testIsCollection()
     {
         List<Object> colA = new ArrayList<>();
         Collection<DataElement> colB = new HashSet<>();
         Collection<DataElement> colC = new ArrayList<>();
-        
+
         assertTrue( isCollection( colA ) );
         assertTrue( isCollection( colB ) );
         assertTrue( isCollection( colC ) );

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ValidationUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ValidationUtilsTest.java	2015-09-03 12:15:43 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/ValidationUtilsTest.java	2015-09-15 09:54:24 +0000
@@ -28,6 +28,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.dataelement.DataElement;
 import org.junit.Test;
@@ -106,12 +107,11 @@
     {
         DataElement de = new DataElement( "DEA" );
         de.setValueType( ValueType.INTEGER );
-        de.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        de.setAggregationType( AggregationType.SUM );
 
         assertTrue( dataValueIsZeroAndInsignificant( "0", de ) );
 
-        de.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_AVERAGE_SUM );
-
+        de.setAggregationType( AggregationType.AVERAGE_SUM_ORG_UNIT );
         assertFalse( dataValueIsZeroAndInsignificant( "0", de ) );
     }
 
@@ -186,13 +186,13 @@
         assertTrue( isValidHexColor( "#4a6" ) );
         assertTrue( isValidHexColor( "abc" ) );
     }
-    
+
     @Test
     public void testExpressionIsValidSQl()
     {
         assertFalse( expressionIsValidSQl( "10 == 10; delete from table" ) );
         assertFalse( expressionIsValidSQl( "select from table" ) );
-        
+
         assertTrue( expressionIsValidSQl( "\"abcdef12345\" < 30" ) );
         assertTrue( expressionIsValidSQl( "\"abcdef12345\" >= \"bcdefg23456\"" ) );
         assertTrue( expressionIsValidSQl( "\"DO0v7fkhUNd\" > -30000 and \"DO0v7fkhUNd\" < 30000" ) );

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2015-09-11 11:54:53 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2015-09-15 09:54:24 +0000
@@ -30,6 +30,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.chart.Chart;
 import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.common.DimensionalObject;
@@ -354,7 +355,7 @@
         dataElement.setDescription( "DataElementDescription" + uniqueCharacter );
         dataElement.setValueType( ValueType.INTEGER );
         dataElement.setDomainType( DataElementDomain.AGGREGATE );
-        dataElement.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElement.setAggregationType( AggregationType.SUM );
 
         return dataElement;
     }
@@ -374,7 +375,7 @@
         dataElement.setDescription( "DataElementDescription" + uniqueCharacter );
         dataElement.setValueType( valueType );
         dataElement.setDomainType( DataElementDomain.AGGREGATE );
-        dataElement.setAggregationOperator( DataElement.AGGREGATION_OPERATOR_SUM );
+        dataElement.setAggregationType( AggregationType.SUM );
 
         return dataElement;
     }
@@ -394,33 +395,33 @@
     }
 
     /**
-     * @param uniqueCharacter     A unique character to identify the object.
-     * @param valueType           The value type.
-     * @param aggregationOperator The aggregation operator.
+     * @param uniqueCharacter A unique character to identify the object.
+     * @param valueType       The value type.
+     * @param aggregationType The aggregation type.
      */
-    public static DataElement createDataElement( char uniqueCharacter, ValueType valueType, String aggregationOperator )
+    public static DataElement createDataElement( char uniqueCharacter, ValueType valueType, AggregationType aggregationType )
     {
         DataElement dataElement = createDataElement( uniqueCharacter );
         dataElement.setValueType( valueType );
         dataElement.setDomainType( DataElementDomain.AGGREGATE );
-        dataElement.setAggregationOperator( aggregationOperator );
+        dataElement.setAggregationType( aggregationType );
 
         return dataElement;
     }
 
     /**
-     * @param uniqueCharacter     A unique character to identify the object.
-     * @param valueType           The value type.
-     * @param aggregationOperator The aggregation operator.
-     * @param categoryCombo       The category combo.
+     * @param uniqueCharacter A unique character to identify the object.
+     * @param valueType       The value type.
+     * @param aggregationType The aggregation type.
+     * @param categoryCombo   The category combo.
      */
-    public static DataElement createDataElement( char uniqueCharacter, ValueType valueType, String aggregationOperator,
+    public static DataElement createDataElement( char uniqueCharacter, ValueType valueType, AggregationType aggregationType,
         DataElementCategoryCombo categoryCombo )
     {
         DataElement dataElement = createDataElement( uniqueCharacter );
         dataElement.setValueType( valueType );
         dataElement.setDomainType( DataElementDomain.AGGREGATE );
-        dataElement.setAggregationOperator( aggregationOperator );
+        dataElement.setAggregationType( aggregationType );
         dataElement.setCategoryCombo( categoryCombo );
 
         return dataElement;
@@ -433,8 +434,7 @@
      *                                      category options.
      * @return DataElementCategoryOptionCombo
      */
-    public static DataElementCategoryCombo createCategoryCombo( char categoryComboUniqueIdentifier,
-        DataElementCategory... categories )
+    public static DataElementCategoryCombo createCategoryCombo( char categoryComboUniqueIdentifier, DataElementCategory... categories )
     {
         DataElementCategoryCombo categoryCombo = new DataElementCategoryCombo( "CategoryCombo" + categoryComboUniqueIdentifier, new ArrayList<>() );
         categoryCombo.setAutoFields();

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElement.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElement.vm	2015-09-07 02:52:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElement.vm	2015-09-15 09:54:24 +0000
@@ -9,7 +9,7 @@
     "description": "$!encoder.jsonEncode( ${dataElement.displayDescription} )",
     "valueType": "$!{dataElement.valueType}",
     "domainType": "${dataElement.getDomainTypeNullSafe()}",
-    "aggregationOperator": "$!{dataElement.aggregationOperator}",
+    "aggregationType": "$!{dataElement.aggregationType}",
     "categoryCombo": "$!encoder.xmlEncode( ${dataElement.categoryCombo.name} )",
     "url": "$!encoder.xmlEncode( ${dataElement.url} )",
     "lastUpdated": "$!format.formatDate( ${dataElement.lastUpdated} )",

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm	2015-09-07 03:11:39 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm	2015-09-15 09:54:24 +0000
@@ -12,7 +12,7 @@
 	"code": "$!encoder.jsonEncode( ${dataElement.code} )",
 	"valueType": "$!{dataElement.valueType}",
 	"optionSet": #if($!dataElement.optionSet) "true"  #else "false" #end,
-	"aggregationOperator": "$!{dataElement.aggregationOperator}",
+	"aggregationType": "$!{dataElement.aggregationType}",
 	"zeroIsSignificant": "$!{dataElement.zeroIsSignificant}",
 	"dataSets": [ #foreach( $dataSet in $dataSets )${dataSet.id}#if( $velocityCount < $dataSets.size() ),#end#end ],
 	"groups": [ #foreach( $group in $groups )${group.id}#if( $velocityCount < $groups.size() ),#end#end ]

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlDataElement.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlDataElement.vm	2015-09-07 03:11:39 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlDataElement.vm	2015-09-15 09:54:24 +0000
@@ -8,7 +8,7 @@
 	<description>$!encoder.xmlEncode( $dataElement.displayDescription )</description>
 	<domainType>$dataElement.getDomainTypeNullSafe()</domainType>
 	<valueType>$dataElement.valueType</valueType>
-	<aggregationOperator>$dataElement.aggregationOperator</aggregationOperator>
+	<aggregationType>$dataElement.aggregationType</aggregationType>
 	<url>$!encoder.xmlEncode( $dataElement.url )</url>
 	<lastUpdated>$!format.formatDate( $dataElement.lastUpdated )</lastUpdated>
 	<categoryCombo>$!encoder.xmlEncode( $dataElement.categoryCombo.name )</categoryCombo>

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlDataElements.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlDataElements.vm	2015-09-07 03:11:39 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/xmlDataElements.vm	2015-09-15 09:54:24 +0000
@@ -10,7 +10,7 @@
 		<description>$!encoder.xmlEncode( $dataElement.displayDescription )</description>
 		<domainType>$dataElement.getDomainTypeNullSafe()</domainType>
 		<valueType>$dataElement.valueType</valueType>
-		<aggregationOperator>$dataElement.aggregationOperator</aggregationOperator>
+		<aggregationType>$dataElement.aggregationType</aggregationType>
 		<categoryCombo>$!encoder.xmlEncode( $dataElement.categoryCombo )</categoryCombo>
 	</dataElement>
 #end

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java	2015-09-04 08:14:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java	2015-09-15 09:54:24 +0000
@@ -30,6 +30,7 @@
 
 import com.opensymphony.xwork2.Action;
 import org.apache.commons.lang3.StringUtils;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.attribute.AttributeService;
 import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.commons.collection.ListUtils;
@@ -129,11 +130,11 @@
         this.valueType = valueType;
     }
 
-    private String aggregationOperator;
+    private String aggregationType;
 
-    public void setAggregationOperator( String aggregationOperator )
+    public void setAggregationType( String aggregationType )
     {
-        this.aggregationOperator = aggregationOperator;
+        this.aggregationType = aggregationType;
     }
 
     private String url;
@@ -220,8 +221,8 @@
         dataElement.setDescription( StringUtils.trimToNull( description ) );
         dataElement.setFormName( StringUtils.trimToNull( formName ) );
         dataElement.setDomainType( DataElementDomain.fromValue( domainType ) );
-        dataElement.setValueType( ValueType.valueOf( valueType) );
-        dataElement.setAggregationOperator( aggregationOperator );
+        dataElement.setValueType( ValueType.valueOf( valueType ) );
+        dataElement.setAggregationType( AggregationType.valueOf( aggregationType ) );
         dataElement.setUrl( url );
         dataElement.setZeroIsSignificant( zeroIsSignificant );
         dataElement.setCategoryCombo( categoryCombo );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java	2015-09-04 08:14:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java	2015-09-15 09:54:24 +0000
@@ -30,6 +30,7 @@
 
 import com.opensymphony.xwork2.Action;
 import org.apache.commons.lang3.StringUtils;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.attribute.AttributeService;
 import org.hisp.dhis.common.ValueType;
 import org.hisp.dhis.commons.collection.ListUtils;
@@ -142,11 +143,11 @@
         this.valueType = valueType;
     }
 
-    private String aggregationOperator;
+    private String aggregationType;
 
-    public void setAggregationOperator( String aggregationOperator )
+    public void setAggregationType( String aggregationType )
     {
-        this.aggregationOperator = aggregationOperator;
+        this.aggregationType = aggregationType;
     }
 
     private String url;
@@ -242,7 +243,7 @@
         dataElement.setFormName( StringUtils.trimToNull( formName ) );
         dataElement.setDomainType( DataElementDomain.fromValue( domainType ) );
         dataElement.setValueType( ValueType.valueOf( valueType ) );
-        dataElement.setAggregationOperator( aggregationOperator );
+        dataElement.setAggregationType( AggregationType.valueOf( aggregationType ) );
         dataElement.setUrl( url );
         dataElement.setZeroIsSignificant( zeroIsSignificant );
         dataElement.setCategoryCombo( categoryCombo );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2015-06-02 03:04:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElement.vm	2015-09-15 09:54:24 +0000
@@ -101,12 +101,12 @@
 				<p><label>$i18n.getString( "description" ):</label><br/><span id="descriptionField"></span></p>
 				<p><label>$i18n.getString( "domain_type" ):</label><br/><span id="domainTypeField"></span></p>
 				<p><label>$i18n.getString( "value_type" ):</label><br/><span id="typeField"></span></p>				
-				<p><label>$i18n.getString( "aggregation_operator" ):</label><br/><span id="aggregationOperatorField"></span></p>                
+				<p><label>$i18n.getString( "aggregation_type" ):</label><br/><span id="aggregationOperatorField"></span></p>
 				<p><label>$i18n.getString( "category_combination" ):</label><br/><span id="categoryComboField"></span></p>
 				<p><label>$i18n.getString( "url" ):</label><br/><span id="urlField"></span></p>
-                <p><label>$i18n.getString( "last_updated" ):</label><br/><span id="lastUpdatedField"></span></p>
-                <p><label>$i18n.getString( "approve_data" ):</label><br/><span id="approveDataField"></span></p>
-                <p><label>$i18n.getString( "data_sets" ):</label><br/><span id="dataSetsField"></span></p>
+				<p><label>$i18n.getString( "last_updated" ):</label><br/><span id="lastUpdatedField"></span></p>
+				<p><label>$i18n.getString( "approve_data" ):</label><br/><span id="approveDataField"></span></p>
+				<p><label>$i18n.getString( "data_sets" ):</label><br/><span id="dataSetsField"></span></p>
 				<p><label>$i18n.getString( "id" ):</label><br/><span id="idField"></span></p>
 			</div>
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm	2015-09-04 08:14:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/dataElementForm.vm	2015-09-15 09:54:24 +0000
@@ -13,7 +13,7 @@
         'beforeValidateHandler': function() {
           setFieldValue('submitCategoryComboId', getFieldValue('selectedCategoryComboId'));
           setFieldValue('submitValueType', getFieldValue('valueType'));
-          enable('aggregationOperatorSelect');
+          enable('aggregationTypeSelect');
 					#tblDynamicAttributesJavascript()
         },
         'rules': getValidationRules("dataElement")
@@ -105,17 +105,17 @@
 		</td>
 	</tr>
 	<tr>
-		<td><label for="aggregationOperatorSelect" id="lblOperator">$i18n.getString( "aggregation_operator" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+		<td><label for="aggregationTypeSelect" id="lblOperator">$i18n.getString( "aggregation_operator" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>
-			<select id="aggregationOperatorSelect" name="aggregationOperator">
-        <option value="sum" #if( $!dataElement.aggregationOperator == 'sum' ) selected="selected" #end>$i18n.getString( "sum" )</option>
-        <option value="avg_sum_org_unit" #if( $!dataElement.aggregationOperator == 'avg_sum_org_unit' ) selected="selected" #end>$i18n.getString( "average_sum_in_org_unit_hierarchy" )</option>
-        <option value="avg" #if( $!dataElement.aggregationOperator == 'avg' ) selected="selected" #end>$i18n.getString( "average" )</option>
-        <option value="count" #if( $!dataElement.aggregationOperator == 'count' ) selected="selected" #end>$i18n.getString( "count" )</option>
-        <option value="stddev" #if( $!dataElement.aggregationOperator == 'stddev' ) selected="selected" #end>$i18n.getString( "stddev" )</option>
-        <option value="variance" #if( $!dataElement.aggregationOperator == 'variance' ) selected="selected" #end>$i18n.getString( "variance" )</option>
-        <option value="min" #if( $!dataElement.aggregationOperator == 'min' ) selected="selected" #end>$i18n.getString( "min" )</option>
-        <option value="max" #if( $!dataElement.aggregationOperator == 'max' ) selected="selected" #end>$i18n.getString( "max" )</option>
+			<select id="aggregationTypeSelect" name="aggregationType">
+        <option value="SUM" #if( $!dataElement.aggregationType == 'SUM' ) selected="selected" #end>$i18n.getString( "sum" )</option>
+        <option value="AVERAGE_SUM_ORG_UNIT" #if( $!dataElement.aggregationType == 'AVERAGE_SUM_ORG_UNIT' ) selected="selected" #end>$i18n.getString( "average_sum_in_org_unit_hierarchy" )</option>
+        <option value="AVERAGE" #if( $!dataElement.aggregationType == 'AVERAGE' ) selected="selected" #end>$i18n.getString( "average" )</option>
+        <option value="COUNT" #if( $!dataElement.aggregationType == 'COUNT' ) selected="selected" #end>$i18n.getString( "count" )</option>
+        <option value="STDDEV" #if( $!dataElement.aggregationType == 'STDDEV' ) selected="selected" #end>$i18n.getString( "stddev" )</option>
+        <option value="VARIANCE" #if( $!dataElement.aggregationType == 'VARIANCE' ) selected="selected" #end>$i18n.getString( "variance" )</option>
+        <option value="MIN" #if( $!dataElement.aggregationType == 'MIN' ) selected="selected" #end>$i18n.getString( "min" )</option>
+        <option value="MAX" #if( $!dataElement.aggregationType == 'MAX' ) selected="selected" #end>$i18n.getString( "max" )</option>
 			</select>
 		</td>
 	</tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js	2015-06-02 03:04:50 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js	2015-09-15 09:54:24 +0000
@@ -1,6 +1,6 @@
 $(function() {
-  $('#aggregationOperatorSelect').change(updateZeroIsSignificant);
-  $('#aggregationOperatorSelect').change();
+  $('#aggregationTypeSelect').change(updateZeroIsSignificant);
+  $('#aggregationTypeSelect').change();
 
   dhis2.contextmenu.makeContextMenu({
     menuId: 'contextMenu',
@@ -9,12 +9,12 @@
 });
 
 function updateZeroIsSignificant() {
-  var $this = $('#aggregationOperatorSelect');
+  var $this = $('#aggregationTypeSelect');
 
-  if( $this.val() == 'sum' ) {
+  if( $this.val() == 'SUM' ) {
     $('#zeroIsSignificant').removeAttr('disabled');
   }
-  else if( $this.val() == 'average' ) {
+  else if( $this.val() == 'AVERAGE' ) {
     $('#zeroIsSignificant').attr('disabled', true);
   }
 }
@@ -99,11 +99,11 @@
       var domainType = json.dataElement.domainType;
       setInnerHTML('domainTypeField', domainTypeMap[domainType]);
 
-      var aggregationOperator = json.dataElement.aggregationOperator;
+      var aggregationOperator = json.dataElement.aggregationType;
       var aggregationOperatorText = i18n_none;
-      if( aggregationOperator == 'sum' ) {
+      if( aggregationOperator == 'SUM' ) {
         aggregationOperatorText = i18n_sum;
-      } else if( aggregationOperator == 'average' ) {
+      } else if( aggregationOperator == 'AVERAGE' ) {
         aggregationOperatorText = i18n_average;
       }
       setInnerHTML('aggregationOperatorField', aggregationOperatorText);