dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24076
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11751: Analytics events, added Excel / xls support
------------------------------------------------------------
revno: 11751
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-08-22 18:10:18 +0200
message:
Analytics events, added Excel / xls support
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-08-22 16:03:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/EventAnalyticsController.java 2013-08-22 16:10:18 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.api.utils.ContextUtils;
import org.hisp.dhis.api.utils.ContextUtils.CacheStrategy;
import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.system.grid.GridUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
@@ -84,6 +85,29 @@
model.addAttribute( "viewClass", "detailed" );
return "grid";
}
+
+ @RequestMapping( value = RESOURCE_PATH + "/{program}.xls", method = RequestMethod.GET )
+ public void getXls(
+ @PathVariable String program,
+ @RequestParam(required=false) String stage,
+ @RequestParam String startDate,
+ @RequestParam String endDate,
+ @RequestParam(required=false) String ou,
+ @RequestParam Set<String> item,
+ @RequestParam(required=false) Set<String> asc,
+ @RequestParam(required=false) Set<String> desc,
+ @RequestParam(required=false) Integer page,
+ @RequestParam(required=false) Integer pageSize,
+ Model model,
+ HttpServletResponse response ) throws Exception
+ {
+ EventQueryParams params = analyticsService.getFromUrl( program, stage, startDate, endDate, ou, item, asc, desc, page, pageSize );
+
+ contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.xls", true );
+ Grid grid = analyticsService.getEvents( params );
+ GridUtils.toXls( grid, response.getOutputStream() );
+ }
+
// -------------------------------------------------------------------------
// Exception handling
// -------------------------------------------------------------------------