← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10036: Using attachment for xls and csv download of analytics

 

------------------------------------------------------------
revno: 10036
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-03-07 11:31:15 +0100
message:
  Using attachment for xls and csv download of analytics
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.java	2013-03-04 10:30:59 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/AnalyticsController.java	2013-03-07 10:31:15 +0000
@@ -100,23 +100,7 @@
         Grid grid = analyticsService.getAggregatedDataValues( params );
         GridUtils.toXml( grid, response.getOutputStream() );
     }
-    
-    @RequestMapping( value = RESOURCE_PATH + ".csv", method = RequestMethod.GET )
-    public void getCsv( 
-        @RequestParam Set<String> dimension,
-        @RequestParam(required = false) Set<String> filter,
-        @RequestParam(required = false) AggregationType aggregationType,
-        @RequestParam(required = false) String measureCriteria,
-        Model model,
-        HttpServletResponse response ) throws Exception
-    {
-        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, i18nManager.getI18nFormat() );
 
-        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING );
-        Grid grid = analyticsService.getAggregatedDataValues( params );
-        GridUtils.toCsv( grid.substituteMetaData(), response.getOutputStream() );
-    }
-    
     @RequestMapping( value = RESOURCE_PATH + ".html", method = RequestMethod.GET )
     public void getHtml( 
         @RequestParam Set<String> dimension,
@@ -133,6 +117,22 @@
         GridUtils.toHtml( grid.substituteMetaData(), response.getWriter() );
     }
 
+    @RequestMapping( value = RESOURCE_PATH + ".csv", method = RequestMethod.GET )
+    public void getCsv( 
+        @RequestParam Set<String> dimension,
+        @RequestParam(required = false) Set<String> filter,
+        @RequestParam(required = false) AggregationType aggregationType,
+        @RequestParam(required = false) String measureCriteria,
+        Model model,
+        HttpServletResponse response ) throws Exception
+    {
+        DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, i18nManager.getI18nFormat() );
+
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "data.csv", true );
+        Grid grid = analyticsService.getAggregatedDataValues( params );
+        GridUtils.toCsv( grid.substituteMetaData(), response.getOutputStream() );
+    }
+    
     @RequestMapping( value = RESOURCE_PATH + ".xls", method = RequestMethod.GET )
     public void getXls( 
         @RequestParam Set<String> dimension,
@@ -144,7 +144,7 @@
     {
         DataQueryParams params = analyticsService.getFromUrl( dimension, filter, aggregationType, measureCriteria, i18nManager.getI18nFormat() );
 
-        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING );
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "data.xls", true );
         Grid grid = analyticsService.getAggregatedDataValues( params );
         GridUtils.toXls( grid.substituteMetaData(), response.getOutputStream() );
     }