← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22065: Analytics. Added support for translations in report table download.

 

------------------------------------------------------------
revno: 22065
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2016-02-27 13:02:42 +0100
message:
  Analytics. Added support for translations in report table download.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java
  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


--
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/reporttable/ReportTable.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2016-02-11 09:27:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTable.java	2016-02-27 12:02:42 +0000
@@ -412,7 +412,7 @@
 
         for ( DimensionalItemObject object : objects )
         {
-            builder.append( object != null ? (object.getShortName() + SPACE) : EMPTY );
+            builder.append( object != null ? (object.getDisplayShortName() + SPACE) : EMPTY );
         }
 
         return builder.length() > 0 ? builder.substring( 0, builder.lastIndexOf( SPACE ) ) : TOTAL_COLUMN_PRETTY_NAME;
@@ -593,9 +593,9 @@
             for ( DimensionalItemObject object : row )
             {
                 grid.addValue( object.getUid() );
-                grid.addValue( object.getName() );
+                grid.addValue( object.getDisplayName() );
                 grid.addValue( object.getCode() );
-                grid.addValue( object.getDescription() );
+                grid.addValue( object.getDisplayDescription() );
             }
 
             if ( paramColumns )

=== 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	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java	2016-02-27 12:02:42 +0000
@@ -1497,7 +1497,7 @@
      * dimension is specified, all category option combos for the first data 
      * element is returned. Returns an empty array if the dimension is not present.
      */
-    public DimensionalItemObject[] getDimensionArrayExplodeCoc( String dimension )
+    public List<DimensionalItemObject> getDimensionArrayExplodeCoc( String dimension )
     {
         List<DimensionalItemObject> items = new ArrayList<>();
         
@@ -1520,7 +1520,7 @@
             items.addAll( getDimensionOptions( dimension ) );
         }
         
-        return items.toArray( new DimensionalItemObject[0] );
+        return items;
     }
     
     /**

=== 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	2016-02-27 11:01:21 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/data/DefaultAnalyticsService.java	2016-02-27 12:02:42 +0000
@@ -54,6 +54,7 @@
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Future;
@@ -596,6 +597,8 @@
             return getAggregatedDataValues( params );
         }
         
+        Locale locale = i18nService.getCurrentLocale();
+        
         params.setOutputIdScheme( null );
         
         Grid grid = getAggregatedDataValues( params );
@@ -615,8 +618,12 @@
             for ( String dimension : columns )
             {
                 reportTable.getColumnDimensions().add( dimension );
+                
+                List<DimensionalItemObject> items = params.getDimensionArrayExplodeCoc( dimension );
+                
+                i18nService.internationalise( items, locale );
 
-                tableColumns.add( params.getDimensionArrayExplodeCoc( dimension ) );
+                tableColumns.add( items.toArray( new DimensionalItemObject[0] ) );
             }
         }
 
@@ -625,8 +632,12 @@
             for ( String dimension : rows )
             {
                 reportTable.getRowDimensions().add( dimension );
+                
+                List<DimensionalItemObject> items = params.getDimensionArrayExplodeCoc( dimension );
+                
+                i18nService.internationalise( items, locale );
 
-                tableRows.add( params.getDimensionArrayExplodeCoc( dimension ) );
+                tableRows.add( items.toArray( new DimensionalItemObject[0] ) );
             }
         }