← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6984: Report table data as csv in web api

 

------------------------------------------------------------
revno: 6984
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-05-18 12:27:53 +0200
message:
  Report table data as csv in web api
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.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/ReportTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java	2012-05-16 21:22:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java	2012-05-18 10:27:53 +0000
@@ -268,6 +268,27 @@
         GridUtils.toXls( grid, response.getOutputStream() );
     }
 
+    @RequestMapping( value = "/data.csv", method = RequestMethod.GET )
+    public void getReportTableDynamicDataCsv( @RequestParam(required=false, value="in") List<String> indicators,
+                                             @RequestParam(required=false, value="de") List<String> dataElements,
+                                             @RequestParam(required=false, value="ds") List<String> dataSets,
+                                             @RequestParam(value="ou") List<String> orgUnits,
+                                             @RequestParam(required=false, value="crosstab") List<String> crossTab,
+                                             @RequestParam(required=false) boolean orgUnitIsParent,
+                                             @RequestParam(required=false) boolean minimal,
+                                             RelativePeriods relatives,
+                                             Model model, 
+                                             HttpServletResponse response ) throws Exception
+    {
+        Grid grid = getReportTableDynamicGrid( indicators, dataElements, dataSets, 
+            orgUnits, crossTab, orgUnitIsParent, minimal, relatives, response );
+        
+        String filename = DATA_NAME + ".csv";
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, true );
+
+        GridUtils.toCsv( grid, response.getOutputStream() );
+    }
+
     private Grid getReportTableDynamicGrid( List<String> indicators, List<String> dataElements, List<String> dataSets, 
         List<String> orgUnits, List<String> crossTab, boolean orgUnitIsParent, boolean minimal, RelativePeriods relatives, HttpServletResponse response )  throws Exception
     {