Search in sources :

Example 21 with SqlView

use of org.hisp.dhis.sqlview.SqlView in project dhis2-core by dhis2.

the class SqlViewController method getViewPdf.

@GetMapping("/{uid}/data.pdf")
public void getViewPdf(@PathVariable("uid") String uid, @RequestParam(required = false) Set<String> criteria, @RequestParam(required = false) Set<String> var, HttpServletResponse response) throws Exception {
    SqlView sqlView = validateView(uid);
    List<String> filters = Lists.newArrayList(contextService.getParameterValues("filter"));
    List<String> fields = Lists.newArrayList(contextService.getParameterValues("fields"));
    Grid grid = sqlViewService.getSqlViewGrid(sqlView, SqlView.getCriteria(criteria), SqlView.getCriteria(var), filters, fields);
    contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_PDF, sqlView.getCacheStrategy());
    GridUtils.toPdf(grid, response.getOutputStream());
}
Also used : SqlView(org.hisp.dhis.sqlview.SqlView) Grid(org.hisp.dhis.common.Grid) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

SqlView (org.hisp.dhis.sqlview.SqlView)21 Grid (org.hisp.dhis.common.Grid)7 GetMapping (org.springframework.web.bind.annotation.GetMapping)7 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 IllegalQueryException (org.hisp.dhis.common.IllegalQueryException)3 ArrayList (java.util.ArrayList)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)1