← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13150: Event analytics, CSV download

 

------------------------------------------------------------
revno: 13150
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-12-05 11:29:15 +0100
message:
  Event analytics, CSV download
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.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/EventAnalyticsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java	2013-10-16 16:11:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java	2013-12-05 10:29:15 +0000
@@ -133,7 +133,7 @@
         
         contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.csv", true );
         Grid grid = analyticsService.getAggregatedEventData( params );
-        GridUtils.toXls( grid, response.getOutputStream() );
+        GridUtils.toCsv( grid, response.getOutputStream() );
     }
     
     // -------------------------------------------------------------------------
@@ -191,6 +191,31 @@
         Grid grid = analyticsService.getEvents( params );
         GridUtils.toXls( grid, response.getOutputStream() );
     }
+
+    @RequestMapping( value = RESOURCE_PATH + "/query/{program}.csv", method = RequestMethod.GET )
+    public void getQueryCsv(
+        @PathVariable String program,
+        @RequestParam(required=false) String stage,
+        @RequestParam(required=false) String startDate,
+        @RequestParam(required=false) String endDate,
+        @RequestParam Set<String> dimension,
+        @RequestParam(required=false) Set<String> filter,
+        @RequestParam(required=false) String ouMode,
+        @RequestParam(required=false) Set<String> asc,
+        @RequestParam(required=false) Set<String> desc,
+        @RequestParam(required=false) boolean hierarchyMeta,
+        @RequestParam(required=false) Integer page,
+        @RequestParam(required=false) Integer pageSize,
+        Model model,
+        HttpServletResponse response ) throws Exception
+    {
+        EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, dimension, filter, 
+            ouMode, asc, desc, hierarchyMeta, page, pageSize, i18nManager.getI18nFormat() );
+        
+        contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.csv", true );
+        Grid grid = analyticsService.getEvents( params );
+        GridUtils.toCsv( grid, response.getOutputStream() );
+    }
     
     // -------------------------------------------------------------------------
     // Exception handling