← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19396: Analyics/event analytics, making sure that data dx/dy dimensions are always returned as the first...

 

------------------------------------------------------------
revno: 19396
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2015-06-14 16:37:29 +0200
message:
  Analyics/event analytics, making sure that data dx/dy dimensions are always returned as the first column in reponse
modified:
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java
  dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2015-05-28 15:04:54 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2015-06-14 14:37:29 +0000
@@ -1037,6 +1037,33 @@
         return map;
     }
     
+    /**
+     * Adds the given dimension to the dimensions of this query. If the dimension
+     * is a data dimensions it will be added to the beginning of the list of dimensions.
+     */
+    public void addDimensions( List<DimensionalObject> dimension )
+    {
+        for ( DimensionalObject dim : dimension )
+        {
+            if ( DATA_DIMS.contains( dim.getDimension() ) )
+            {
+                dimensions.add( 0, dim );
+            }
+            else
+            {
+                dimensions.add( dim );
+            }
+        }
+    }
+    
+    /**
+     * Adds the given filters to the filters of this query.
+     */
+    public void addFilters( List<DimensionalObject> filters )
+    {
+        this.filters.addAll( filters );
+    }
+    
     // -------------------------------------------------------------------------
     // Supportive methods
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2015-06-14 14:18:36 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2015-06-14 14:37:29 +0000
@@ -823,12 +823,12 @@
 
         if ( dimensionParams != null && !dimensionParams.isEmpty() )
         {
-            params.getDimensions().addAll( getDimensionalObjects( dimensionParams, format ) );
+            params.addDimensions( getDimensionalObjects( dimensionParams, format ) );
         }
 
         if ( filterParams != null && !filterParams.isEmpty() )
         {
-            params.getFilters().addAll( getDimensionalObjects( filterParams, format ) );
+            params.addFilters( getDimensionalObjects( filterParams, format ) );
         }
 
         if ( measureCriteria != null && !measureCriteria.isEmpty() )
@@ -861,17 +861,17 @@
 
             for ( DimensionalObject column : object.getColumns() )
             {
-                params.getDimensions().addAll( getDimension( toDimension( column.getDimension() ), getUids( column.getItems() ), date, format, false ) );
+                params.addDimensions( getDimension( toDimension( column.getDimension() ), getUids( column.getItems() ), date, format, false ) );
             }
 
             for ( DimensionalObject row : object.getRows() )
             {
-                params.getDimensions().addAll( getDimension( toDimension( row.getDimension() ), getUids( row.getItems() ), date, format, false ) );
+                params.addDimensions( getDimension( toDimension( row.getDimension() ), getUids( row.getItems() ), date, format, false ) );
             }
 
             for ( DimensionalObject filter : object.getFilters() )
             {
-                params.getFilters().addAll( getDimension( toDimension( filter.getDimension() ), getUids( filter.getItems() ), date, format, false ) );
+                params.addFilters( getDimension( toDimension( filter.getDimension() ), getUids( filter.getItems() ), date, format, false ) );
             }
         }
 

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-06-13 21:26:59 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java	2015-06-14 14:37:29 +0000
@@ -178,11 +178,6 @@
         // Headers
         // ---------------------------------------------------------------------
 
-        for ( DimensionalObject dimension : params.getDimensions() )
-        {
-            grid.addHeader( new GridHeader( dimension.getDimension(), dimension.getDisplayName(), String.class.getName(), false, true ) );
-        }
-
         if ( params.isCollapseDataDimensions() || params.isAggregateData() )
         {
             grid.addHeader( new GridHeader( DimensionalObject.DATA_COLLAPSED_DIM_ID, DataQueryParams.DISPLAY_NAME_DATA_X, String.class.getName(), false, true ) );
@@ -199,6 +194,11 @@
             }
         }
 
+        for ( DimensionalObject dimension : params.getDimensions() )
+        {
+            grid.addHeader( new GridHeader( dimension.getDimension(), dimension.getDisplayName(), String.class.getName(), false, true ) );
+        }
+
         grid.addHeader( new GridHeader( "value", "Value", Double.class.getName(), false, false ) );
 
         // ---------------------------------------------------------------------

=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2015-06-13 21:26:59 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java	2015-06-14 14:37:29 +0000
@@ -158,6 +158,20 @@
         while ( rowSet.next() )
         {            
             grid.addRow();
+
+            if ( params.isAggregateData() )
+            {
+                grid.addValue( params.getValue().getUid() );
+            }
+            else
+            {
+                for ( QueryItem queryItem : params.getItems() )
+                {
+                    String itemValue = rowSet.getString( queryItem.getItemName() );
+                    String gridValue = params.isCollapseDataDimensions() ? getCollapsedDataItemValue( params, queryItem, itemValue ) : itemValue;
+                    grid.addValue( gridValue );
+                }
+            }
             
             for ( DimensionalObject dimension : params.getDimensions() )
             {
@@ -165,18 +179,6 @@
                 grid.addValue( dimensionValue );
             }
             
-            for ( QueryItem queryItem : params.getItems() )
-            {
-                String itemValue = rowSet.getString( queryItem.getItemName() );
-                String gridValue = params.isCollapseDataDimensions() ? getCollapsedDataItemValue( params, queryItem, itemValue ) : itemValue;
-                grid.addValue( gridValue );
-            }
-            
-            if ( params.isAggregateData() )
-            {
-                grid.addValue( params.getValue().getUid() );
-            }
-            
             if ( params.hasValueDimension() )
             {
                 double value = rowSet.getDouble( "value" );