dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37293
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19092: SQL view, using name as filename for download
------------------------------------------------------------
revno: 19092
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-05-05 10:45:49 +0200
message:
SQL view, using name as filename for download
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SqlViewController.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/webapi/controller/SqlViewController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SqlViewController.java 2015-04-04 07:29:07 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SqlViewController.java 2015-05-05 08:45:49 +0000
@@ -33,6 +33,7 @@
import org.hisp.dhis.sqlview.SqlView;
import org.hisp.dhis.sqlview.SqlViewService;
import org.hisp.dhis.system.grid.GridUtils;
+import org.hisp.dhis.system.util.CodecUtils;
import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
import org.springframework.beans.factory.annotation.Autowired;
@@ -44,6 +45,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
+
import java.util.Set;
/**
@@ -117,8 +119,10 @@
}
Grid grid = sqlViewService.getSqlViewGrid( sqlView, SqlView.getCriteria( criteria ), SqlView.getCriteria( var ) );
-
- contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "sqlview.csv", true );
+
+ String filename = CodecUtils.filenameEncode( grid.getTitle() ) + ".csv";
+
+ contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, true );
GridUtils.toCsv( grid, response.getOutputStream() );
}
@@ -138,7 +142,9 @@
Grid grid = sqlViewService.getSqlViewGrid( sqlView, SqlView.getCriteria( criteria ), SqlView.getCriteria( var ) );
- contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, "sqlview.xls", true );
+ String filename = CodecUtils.filenameEncode( grid.getTitle() ) + ".xls";
+
+ contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_EXCEL, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, true );
GridUtils.toXls( grid, response.getOutputStream() );
}