← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18785: Using AggregationType enum for report table. Added persistent aggregationType field for chart.

 

------------------------------------------------------------
revno: 18785
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-03-31 16:49:05 +0200
message:
  Using AggregationType enum for report table. Added persistent aggregationType field for chart.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/analytics/AggregationType.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/EventAnalyticalObject.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/reporttable/ReportTable.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml
  dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml


--
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/analytics/AggregationType.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/analytics/AggregationType.java	2015-02-17 16:50:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/analytics/AggregationType.java	2015-03-31 14:49:05 +0000
@@ -45,7 +45,8 @@
     VARIANCE( "variance" ),
     MIN( "min" ),
     MAX( "max" ),
-    NONE( "none" );
+    NONE( "none" ),
+    DEFAULT( "default" );
 
     private final String value;
 

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java	2015-03-26 08:36:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseAnalyticalObject.java	2015-03-31 14:49:05 +0000
@@ -55,6 +55,7 @@
 import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
+import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.common.annotation.Scanned;
 import org.hisp.dhis.common.view.DetailedView;
 import org.hisp.dhis.common.view.DimensionalView;
@@ -140,6 +141,8 @@
 
     protected int topLimit;
 
+    protected AggregationType aggregationType;
+    
     // -------------------------------------------------------------------------
     // Analytical properties
     // -------------------------------------------------------------------------
@@ -785,10 +788,12 @@
             if ( strategy.isReplace() )
             {
                 relatives = object.getRelatives();
+                aggregationType = object.getAggregationType();
             }
             else if ( strategy.isMerge() )
             {
                 relatives = object.getRelatives() == null ? relatives : object.getRelatives();
+                aggregationType = object.getAggregationType() == null ? aggregationType : object.getAggregationType();
             }
 
             indicators.addAll( object.getIndicators() );
@@ -980,6 +985,19 @@
         this.topLimit = topLimit;
     }
 
+    @JsonProperty
+    @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
+    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
+    public AggregationType getAggregationType()
+    {
+        return aggregationType;
+    }
+
+    public void setAggregationType( AggregationType aggregationType )
+    {
+        this.aggregationType = aggregationType;
+    }
+
     // -------------------------------------------------------------------------
     // Transient properties
     // -------------------------------------------------------------------------

=== 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-05 16:29:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/EventAnalyticalObject.java	2015-03-31 14:49:05 +0000
@@ -30,7 +30,6 @@
 
 import java.util.Date;
 
-import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.analytics.EventOutputType;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.program.Program;
@@ -51,8 +50,6 @@
     
     Date getEndDate();
     
-    AggregationType getAggregationType();
-    
     EventOutputType getOutputType();
     
     NameableObject getValue();

=== 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-03-05 16:31:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventchart/EventChart.java	2015-03-31 14:49:05 +0000
@@ -32,7 +32,6 @@
 import java.util.Date;
 import java.util.List;
 
-import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.analytics.EventOutputType;
 import org.hisp.dhis.chart.BaseChart;
 import org.hisp.dhis.common.AnalyticsType;
@@ -104,11 +103,6 @@
     private TrackedEntityAttribute attributeValueDimension;
 
     /**
-     * Aggregation type.
-     */
-    private AggregationType aggregationType;
-    
-    /**
      * Dimensions to crosstabulate / use as columns.
      */
     private List<String> columnDimensions = new ArrayList<>();
@@ -307,19 +301,6 @@
     }
 
     @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public AggregationType getAggregationType()
-    {
-        return aggregationType;
-    }
-
-    public void setAggregationType( AggregationType aggregationType )
-    {
-        this.aggregationType = aggregationType;
-    }
-
-    @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class } )
     @JacksonXmlElementWrapper( localName = "columnDimensions", namespace = DxfNamespaces.DXF_2_0 )
     @JacksonXmlProperty( localName = "columnDimension", namespace = DxfNamespaces.DXF_2_0 )
@@ -409,7 +390,6 @@
             {
                 dataElementValueDimension = chart.getDataElementValueDimension();
                 attributeValueDimension = chart.getAttributeValueDimension();
-                aggregationType = chart.getAggregationType();
                 program = chart.getProgram();
                 programStage = chart.getProgramStage();
                 startDate = chart.getStartDate();
@@ -420,7 +400,6 @@
             {
                 dataElementValueDimension = chart.getDataElementValueDimension() == null ? dataElementValueDimension : chart.getDataElementValueDimension();
                 attributeValueDimension = chart.getAttributeValueDimension() == null ? attributeValueDimension : chart.getAttributeValueDimension();
-                aggregationType = chart.getAggregationType() == null ? aggregationType : chart.getAggregationType();
                 program = chart.getProgram() == null ? program : chart.getProgram();
                 programStage = chart.getProgramStage() == null ? programStage : chart.getProgramStage();
                 startDate = chart.getStartDate() == null ? startDate : chart.getStartDate();

=== 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-03-05 16:29:11 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/eventreport/EventReport.java	2015-03-31 14:49:05 +0000
@@ -32,7 +32,6 @@
 import java.util.Date;
 import java.util.List;
 
-import org.hisp.dhis.analytics.AggregationType;
 import org.hisp.dhis.analytics.EventOutputType;
 import org.hisp.dhis.common.BaseAnalyticalObject;
 import org.hisp.dhis.common.BaseDimensionalObject;
@@ -104,11 +103,6 @@
     private TrackedEntityAttribute attributeValueDimension;
     
     /**
-     * Aggregation type.
-     */
-    private AggregationType aggregationType;
-    
-    /**
      * Type of data, can be aggregated values and individual cases.
      */
     private String dataType;
@@ -330,19 +324,6 @@
     @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public AggregationType getAggregationType()
-    {
-        return aggregationType;
-    }
-
-    public void setAggregationType( AggregationType aggregationType )
-    {
-        this.aggregationType = aggregationType;
-    }
-
-    @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getDataType()
     {
         return dataType;
@@ -582,7 +563,6 @@
             {
                 dataElementValueDimension = report.getDataElementValueDimension();
                 attributeValueDimension = report.getAttributeValueDimension();
-                aggregationType = report.getAggregationType();
                 dataType = report.getDataType();
                 program = report.getProgram();
                 programStage = report.getProgramStage();
@@ -596,7 +576,6 @@
             {
                 dataElementValueDimension = report.getDataElementValueDimension() == null ? dataElementValueDimension : report.getDataElementValueDimension();
                 attributeValueDimension = report.getAttributeValueDimension() == null ? attributeValueDimension : report.getAttributeValueDimension();
-                aggregationType = report.getAggregationType() == null ? aggregationType : report.getAggregationType();
                 dataType = report.getDataType() == null ? dataType : report.getDataType();
                 program = report.getProgram() == null ? program : report.getProgram();
                 programStage = report.getProgramStage() == null ? programStage : report.getProgramStage();

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2015-02-26 15:21:29 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2015-03-31 14:49:05 +0000
@@ -197,11 +197,6 @@
     private boolean showHierarchy;
 
     /**
-     * Indicates the aggregation type.
-     */
-    private String aggregationType;
-
-    /**
      * Indicates showing organisation unit hierarchy names.
      */
     private boolean showDimensionLabels;
@@ -957,19 +952,6 @@
     @JsonProperty
     @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
     @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
-    public String getAggregationType()
-    {
-        return aggregationType;
-    }
-
-    public void setAggregationType( String aggregationType )
-    {
-        this.aggregationType = aggregationType;
-    }
-
-    @JsonProperty
-    @JsonView( { DetailedView.class, ExportView.class, DimensionalView.class } )
-    @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
     public String getDisplayDensity()
     {
         return displayDensity;
@@ -1107,7 +1089,6 @@
             if ( strategy.isReplace() )
             {
                 reportParams = reportTable.getReportParams();
-                aggregationType = reportTable.getAggregationType();
                 displayDensity = reportTable.getDisplayDensity();
                 fontSize = reportTable.getFontSize();
                 legendSet = reportTable.getLegendSet();
@@ -1115,7 +1096,6 @@
             else if ( strategy.isMerge() )
             {
                 reportParams = reportTable.getReportParams() == null ? reportParams : reportTable.getReportParams();
-                aggregationType = reportTable.getAggregationType() == null ? aggregationType : reportTable.getAggregationType();
                 displayDensity = reportTable.getDisplayDensity() == null ? displayDensity : reportTable.getDisplayDensity();
                 fontSize = reportTable.getFontSize() == null ? fontSize : reportTable.getFontSize();
                 legendSet = reportTable.getLegendSet() == null ? legendSet : reportTable.getLegendSet();

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2015-03-31 13:49:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2015-03-31 14:49:05 +0000
@@ -814,9 +814,22 @@
         upgradeTranslations();
 
         updateOptions();
+        
+        upgradeAggregationType( "reporttable" );
 
         log.info( "Tables updated" );
     }
+    
+    private void upgradeAggregationType( String table )
+    {
+        executeSql( "update " + table + " set aggregationtype='SUM' where aggregationtype='sum'" );
+        executeSql( "update " + table + " set aggregationtype='COUNT' where aggregationtype='count'" );
+        executeSql( "update " + table + " set aggregationtype='STDDEV' where aggregationtype='stddev'" );
+        executeSql( "update " + table + " set aggregationtype='VARIANCE' where aggregationtype='variance'" );
+        executeSql( "update " + table + " set aggregationtype='MIN' where aggregationtype='min'" );
+        executeSql( "update " + table + " set aggregationtype='MAX' where aggregationtype='max'" );
+        executeSql( "update " + table + " set aggregationtype='DEFAULT' where aggregationtype='default'" );
+    }
 
     private void upgradeDataValuesWithAttributeOptionCombo()
     {

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2015-03-31 13:49:41 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/chart/hibernate/Chart.hbm.xml	2015-03-31 14:49:05 +0000
@@ -156,6 +156,13 @@
 
     <property name="userOrganisationUnitGrandChildren" />
 
+    <property name="aggregationType" length="40">
+		<type name="org.hibernate.type.EnumType">
+			<param name="enumClass">org.hisp.dhis.analytics.AggregationType</param>
+			<param name="type">12</param>
+		</type> 
+	</property>
+	
     <property name="showData" />
 
     <property name="hideEmptyRows" />

=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2015-02-24 13:16:58 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/org/hisp/dhis/reporttable/hibernate/ReportTable.hbm.xml	2015-03-31 14:49:05 +0000
@@ -161,7 +161,12 @@
 
     <property name="hideEmptyRows" />
 
-    <property name="aggregationType" />
+    <property name="aggregationType" length="40">
+		<type name="org.hibernate.type.EnumType">
+			<param name="enumClass">org.hisp.dhis.analytics.AggregationType</param>
+			<param name="type">12</param>
+		</type> 
+	</property>
 
     <property name="digitGroupSeparator" />