dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38376
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19542: Reimpl GridUtils.toCsv using CsvWriter. Moved CsvUtils from support-system to import-export.
------------------------------------------------------------
revno: 19542
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-07-04 18:43:29 +0200
message:
Reimpl GridUtils.toCsv using CsvWriter. Moved CsvUtils from support-system to import-export.
renamed:
dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/CsvUtils.java => dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/CsvUtils.java
modified:
dhis-2/dhis-services/dhis-service-dxf2/pom.xml
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueDailyConverter.java
dhis-2/dhis-support/dhis-support-system/pom.xml
dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AnalyticsController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java
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/dataelement/DataElementOperandController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/AbstractGridView.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/CsvGridView.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/ExcelGridView.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/PdfGridView.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java
dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/CsvUtils.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-services/dhis-service-dxf2/pom.xml'
--- dhis-2/dhis-services/dhis-service-dxf2/pom.xml 2015-06-23 15:59:19 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/pom.xml 2015-07-04 16:43:29 +0000
@@ -22,7 +22,7 @@
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-core</artifactId>
</dependency>
-
+
<dependency>
<groupId>net.sourceforge.javacsv</groupId>
<artifactId>javacsv</artifactId>
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java 2015-07-04 16:18:23 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/adx/DefaultADXDataService.java 2015-07-04 16:43:29 +0000
@@ -81,7 +81,6 @@
import org.apache.xerces.util.XMLChar;
/**
- *
* @author bobj
*/
public class DefaultADXDataService
=== renamed file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/CsvUtils.java' => 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/CsvUtils.java'
--- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/commons/util/CsvUtils.java 2015-06-16 17:57:23 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/util/CsvUtils.java 2015-07-04 16:43:29 +0000
@@ -1,4 +1,4 @@
-package org.hisp.dhis.commons.util;
+package org.hisp.dhis.importexport.dhis14.util;
/*
* Copyright (c) 2004-2015, University of Oslo
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueConverter.java 2015-07-04 16:43:29 +0000
@@ -28,11 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.commons.util.CsvUtils.NEWLINE;
-import static org.hisp.dhis.commons.util.CsvUtils.SEPARATOR_B;
-import static org.hisp.dhis.commons.util.CsvUtils.csvEncode;
-import static org.hisp.dhis.commons.util.CsvUtils.getCsvEndValue;
-import static org.hisp.dhis.commons.util.CsvUtils.getCsvValue;
+import static org.hisp.dhis.importexport.dhis14.util.CsvUtils.*;
import java.io.BufferedReader;
import java.io.IOException;
=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueDailyConverter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueDailyConverter.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dhis14/xml/converter/DataValueDailyConverter.java 2015-07-04 16:43:29 +0000
@@ -28,11 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.commons.util.CsvUtils.NEWLINE;
-import static org.hisp.dhis.commons.util.CsvUtils.SEPARATOR_B;
-import static org.hisp.dhis.commons.util.CsvUtils.csvEncode;
-import static org.hisp.dhis.commons.util.CsvUtils.getCsvEndValue;
-import static org.hisp.dhis.commons.util.CsvUtils.getCsvValue;
+import static org.hisp.dhis.importexport.dhis14.util.CsvUtils.*;
import java.io.BufferedReader;
import java.io.IOException;
=== modified file 'dhis-2/dhis-support/dhis-support-system/pom.xml'
--- dhis-2/dhis-support/dhis-support-system/pom.xml 2015-06-04 22:08:39 +0000
+++ dhis-2/dhis-support/dhis-support-system/pom.xml 2015-07-04 16:43:29 +0000
@@ -197,6 +197,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>net.sourceforge.javacsv</groupId>
+ <artifactId>javacsv</artifactId>
+ </dependency>
</dependencies>
<properties>
<rootDir>../../</rootDir>
=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java 2015-06-18 06:57:14 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/grid/GridUtils.java 2015-07-04 16:43:29 +0000
@@ -29,9 +29,6 @@
*/
import static org.hisp.dhis.common.DimensionalObject.DIMENSION_SEP;
-import static org.hisp.dhis.commons.util.CsvUtils.NEWLINE;
-import static org.hisp.dhis.commons.util.CsvUtils.SEPARATOR_B;
-import static org.hisp.dhis.commons.util.CsvUtils.csvEncode;
import static org.hisp.dhis.system.util.PDFUtils.addTableToDocument;
import static org.hisp.dhis.system.util.PDFUtils.closeDocument;
import static org.hisp.dhis.system.util.PDFUtils.getEmptyCell;
@@ -93,6 +90,7 @@
import org.htmlparser.tags.TableTag;
import org.springframework.jdbc.support.rowset.SqlRowSet;
+import com.csvreader.CsvWriter;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PdfPTable;
@@ -104,6 +102,7 @@
private static final Log log = LogFactory.getLog( GridUtils.class );
private static final String EMPTY = "";
+ private static final char CSV_DELIMITER = ',';
private static final String XLS_SHEET_PREFIX = "Sheet ";
private static final int JXL_MAX_COLS = 256;
@@ -334,7 +333,7 @@
/**
* Writes a CSV representation of the given Grid to the given OutputStream.
*/
- public static void toCsv( Grid grid, OutputStream out )
+ public static void toCsv( Grid grid, Writer writer )
throws Exception
{
if ( grid == null )
@@ -342,19 +341,19 @@
return;
}
+ CsvWriter csvWriter = new CsvWriter( writer, CSV_DELIMITER );
+
Iterator<GridHeader> headers = grid.getHeaders().iterator();
- while ( headers.hasNext() )
+ if ( !grid.getHeaders().isEmpty() )
{
- out.write( csvEncode( headers.next().getColumn() ).getBytes() );
-
- if ( headers.hasNext() )
+ while ( headers.hasNext() )
{
- out.write( SEPARATOR_B );
+ csvWriter.write( headers.next().getColumn() );
}
+
+ csvWriter.endRecord();
}
-
- out.write( NEWLINE );
for ( List<Object> row : grid.getRows() )
{
@@ -362,15 +361,12 @@
while ( columns.hasNext() )
{
- out.write( csvEncode( columns.next() ).getBytes() );
+ Object value = columns.next();
- if ( columns.hasNext() )
- {
- out.write( SEPARATOR_B );
- }
+ csvWriter.write( value != null ? String.valueOf( value ) : StringUtils.EMPTY );
}
- out.write( NEWLINE );
+ csvWriter.endRecord();
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AnalyticsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AnalyticsController.java 2015-06-14 15:30:53 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AnalyticsController.java 2015-07-04 16:43:29 +0000
@@ -230,7 +230,7 @@
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "data.csv", true );
Grid grid = analyticsService.getAggregatedDataValues( params, tableLayout, getDimensionsFromParam( columns ), getDimensionsFromParam( rows ) );
- GridUtils.toCsv( grid, response.getOutputStream() );
+ GridUtils.toCsv( grid, response.getWriter() );
}
@RequestMapping( value = RESOURCE_PATH + ".xls", method = RequestMethod.GET )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java 2015-06-13 21:26:59 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/EventAnalyticsController.java 2015-07-04 16:43:29 +0000
@@ -204,7 +204,7 @@
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.csv", true );
Grid grid = analyticsService.getAggregatedEventData( params );
- GridUtils.toCsv( substituteMetaData( grid ), response.getOutputStream() );
+ GridUtils.toCsv( substituteMetaData( grid ), response.getWriter() );
}
@RequestMapping( value = RESOURCE_PATH + "/aggregate/{program}.html", method = RequestMethod.GET )
@@ -354,7 +354,7 @@
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, "events.csv", true );
Grid grid = analyticsService.getEvents( params );
- GridUtils.toCsv( substituteMetaData( grid ), response.getOutputStream() );
+ GridUtils.toCsv( substituteMetaData( grid ), response.getWriter() );
}
@RequestMapping( value = RESOURCE_PATH + "/query/{program}.html", method = RequestMethod.GET )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/ReportTableController.java 2015-07-04 16:43:29 +0000
@@ -243,7 +243,7 @@
String filename = filenameEncode( grid.getTitle() ) + ".csv";
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, true );
- GridUtils.toCsv( grid, response.getOutputStream() );
+ GridUtils.toCsv( grid, response.getWriter() );
}
private Grid getReportTableGrid( String uid, String organisationUnitUid, Date date )
=== 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-06-15 13:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SqlViewController.java 2015-07-04 16:43:29 +0000
@@ -124,7 +124,7 @@
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, true );
- GridUtils.toCsv( grid, response.getOutputStream() );
+ GridUtils.toCsv( grid, response.getWriter() );
}
@RequestMapping( value = "/{uid}/data.xls", method = RequestMethod.GET )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java 2015-07-03 07:47:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/dataelement/DataElementOperandController.java 2015-07-04 16:43:29 +0000
@@ -32,8 +32,6 @@
import java.util.Iterator;
import java.util.List;
-import org.hisp.dhis.common.Pager;
-import org.hisp.dhis.common.PagerUtils;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementGroup;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java 2015-07-03 07:33:54 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/event/TrackedEntityInstanceController.java 2015-07-04 16:43:29 +0000
@@ -281,7 +281,7 @@
contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, CacheStrategy.NO_CACHE );
Grid grid = instanceService.getTrackedEntityInstancesGrid( params );
- GridUtils.toCsv( grid, response.getOutputStream() );
+ GridUtils.toCsv( grid, response.getWriter() );
}
@RequestMapping( value = "/{id}", method = RequestMethod.GET )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java 2015-07-02 07:05:55 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java 2015-07-04 16:43:29 +0000
@@ -48,7 +48,6 @@
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageDataElement;
import org.hisp.dhis.program.ProgramStageSection;
-import org.hisp.dhis.program.ProgramType;
import org.hisp.dhis.webapi.webdomain.form.Field;
import org.hisp.dhis.webapi.webdomain.form.Form;
import org.hisp.dhis.webapi.webdomain.form.Group;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/AbstractGridView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/AbstractGridView.java 2015-05-30 13:36:07 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/AbstractGridView.java 2015-07-04 16:43:29 +0000
@@ -28,7 +28,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.webapi.webdomain.WebMetaData;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.GridHeader;
import org.hisp.dhis.common.IdentifiableObject;
@@ -36,23 +44,15 @@
import org.hisp.dhis.system.grid.ListGrid;
import org.hisp.dhis.system.util.PredicateUtils;
import org.hisp.dhis.system.util.ReflectionUtils;
+import org.hisp.dhis.webapi.webdomain.WebMetaData;
import org.springframework.web.servlet.view.AbstractView;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.OutputStream;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
public abstract class AbstractGridView extends AbstractView
{
- protected abstract void renderGrids( List<Grid> grids, OutputStream outputStream ) throws Exception;
+ protected abstract void renderGrids( List<Grid> grids, HttpServletResponse response ) throws Exception;
@Override
protected void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response ) throws Exception
@@ -130,6 +130,6 @@
grids.add( grid );
}
- renderGrids( grids, response.getOutputStream() );
+ renderGrids( grids, response );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/CsvGridView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/CsvGridView.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/CsvGridView.java 2015-07-04 16:43:29 +0000
@@ -28,12 +28,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.webapi.utils.ContextUtils;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.system.grid.GridUtils;
-
-import java.io.OutputStream;
-import java.util.List;
+import org.hisp.dhis.webapi.utils.ContextUtils;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -46,11 +47,11 @@
}
@Override
- protected void renderGrids( List<Grid> grids, OutputStream outputStream ) throws Exception
+ protected void renderGrids( List<Grid> grids, HttpServletResponse response ) throws Exception
{
if ( !grids.isEmpty() )
{
- GridUtils.toCsv( grids.get( 0 ), outputStream );
+ GridUtils.toCsv( grids.get( 0 ), response.getWriter() );
}
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/ExcelGridView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/ExcelGridView.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/ExcelGridView.java 2015-07-04 16:43:29 +0000
@@ -28,12 +28,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.webapi.utils.ContextUtils;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.system.grid.GridUtils;
-
-import java.io.OutputStream;
-import java.util.List;
+import org.hisp.dhis.webapi.utils.ContextUtils;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -46,8 +47,8 @@
}
@Override
- protected void renderGrids( List<Grid> grids, OutputStream outputStream ) throws Exception
+ protected void renderGrids( List<Grid> grids, HttpServletResponse response ) throws Exception
{
- GridUtils.toXls( grids, outputStream );
+ GridUtils.toXls( grids, response.getOutputStream() );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/PdfGridView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/PdfGridView.java 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/view/PdfGridView.java 2015-07-04 16:43:29 +0000
@@ -28,12 +28,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import org.hisp.dhis.webapi.utils.ContextUtils;
+import java.util.List;
+
+import javax.servlet.http.HttpServletResponse;
+
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.system.grid.GridUtils;
-
-import java.io.OutputStream;
-import java.util.List;
+import org.hisp.dhis.webapi.utils.ContextUtils;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -46,8 +47,8 @@
}
@Override
- protected void renderGrids( List<Grid> grids, OutputStream outputStream )
+ protected void renderGrids( List<Grid> grids, HttpServletResponse response ) throws Exception
{
- GridUtils.toPdf( grids, outputStream );
+ GridUtils.toPdf( grids, response.getOutputStream() );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java 2015-06-15 13:44:20 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/result/GridCsvResult.java 2015-07-04 16:43:29 +0000
@@ -28,15 +28,13 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.OutputStream;
-
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.struts2.ServletActionContext;
import org.hisp.dhis.common.Grid;
+import org.hisp.dhis.commons.util.CodecUtils;
import org.hisp.dhis.system.grid.GridUtils;
-import org.hisp.dhis.commons.util.CodecUtils;
import org.hisp.dhis.util.ContextUtils;
import com.opensymphony.xwork2.ActionInvocation;
@@ -88,8 +86,6 @@
HttpServletResponse response = ServletActionContext.getResponse();
- OutputStream out = response.getOutputStream();
-
String filename = CodecUtils.filenameEncode( StringUtils.defaultIfEmpty( grid.getTitle(), DEFAULT_FILENAME ) ) + ".csv";
ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_CSV, true, filename, true );
@@ -98,6 +94,6 @@
// Write CSV to output stream
// ---------------------------------------------------------------------
- GridUtils.toCsv( grid, out );
+ GridUtils.toCsv( grid, response.getWriter() );
}
}