=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/UploadExcelFileAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/UploadExcelFileAction.java 2009-09-15 04:00:03 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/UploadExcelFileAction.java 2009-09-25 07:57:43 +0000 @@ -28,11 +28,10 @@ */ import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; -import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.reportexcel.ReportLocationManager; @@ -45,7 +44,7 @@ extends org.hisp.dhis.reportexcel.action.ActionSupport { // ------------------------------------------- - // Dependencies + // Dependency // ------------------------------------------- private ReportLocationManager reportLocationManager; @@ -55,15 +54,15 @@ this.reportLocationManager = reportLocationManager; } - private OrganisationUnitSelectionManager organisationUnitSelectionManager; - - public void setOrganisationUnitSelectionManager( OrganisationUnitSelectionManager organisationUnitSelectionManager ) - { - this.organisationUnitSelectionManager = organisationUnitSelectionManager; - } +// private OrganisationUnitSelectionManager organisationUnitSelectionManager; +// +// public void setOrganisationUnitSelectionManager( OrganisationUnitSelectionManager organisationUnitSelectionManager ) +// { +// this.organisationUnitSelectionManager = organisationUnitSelectionManager; +// } // ------------------------------------------------------------------------- - // Getter & Setter + // Getters & Setters // ------------------------------------------------------------------------- private String fileName; @@ -99,41 +98,43 @@ public String execute() throws Exception { - OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); - - if ( organisationUnit == null ) - return SUCCESS; - - File directory = reportLocationManager.getOrganisationDirectory( organisationUnit ); - +// OrganisationUnit organisationUnit = organisationUnitSelectionManager.getSelectedOrganisationUnit(); + +// if ( organisationUnit == null ) +// return SUCCESS; + + File directory = reportLocationManager.getReportExcelTempDirectory( ); + if ( upload != null ) { try { - FileReader in = new FileReader( upload ); - + FileInputStream fin = new FileInputStream( upload ); + + byte[] data = new byte[8192]; + int byteReads = fin.read( data ); + fileExcel = new File( directory, fileName ); - FileWriter out = new FileWriter( fileExcel ); - - int c; - - while ( (c = in.read()) != -1 ) + FileOutputStream fout = new FileOutputStream( fileExcel ); + + while ( byteReads != -1 ) { - out.write( c ); + fout.write( data, 0, byteReads ); + fout.flush(); + byteReads = fin.read( data ); } - - in.close(); - - out.close(); + fin.close(); + + fout.close(); return SUCCESS; } catch ( IOException e ) { e.printStackTrace(); - return NONE; + return ERROR; } } === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataAction.java 2009-09-21 07:40:48 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/importing/action/ViewDataAction.java 2009-09-25 07:57:43 +0000 @@ -31,15 +31,16 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import java.util.Locale; import jxl.Sheet; import jxl.Workbook; -import jxl.WorkbookSettings; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; import org.hisp.dhis.reportexcel.ReportExcel; import org.hisp.dhis.reportexcel.ReportExcelItem; import org.hisp.dhis.reportexcel.ReportExcelService; +import org.hisp.dhis.reportexcel.ReportLocationManager; import org.hisp.dhis.reportexcel.importing.ReportExcelItemValue; import org.hisp.dhis.reportexcel.utils.ExcelUtils; @@ -54,7 +55,7 @@ implements Action { // -------------------------------------------------------------------- - // Dependency + // Dependencies // -------------------------------------------------------------------- private ReportExcelService reportExcelService; @@ -64,8 +65,15 @@ this.reportExcelService = reportExcelService; } + private ReportLocationManager reportLocationManager; + + public void setReportLocationManager( ReportLocationManager reportLocationManager ) + { + this.reportLocationManager = reportLocationManager; + } + // -------------------------------------------------------------------- - // Getter and Setter + // Getters and Setters // -------------------------------------------------------------------- private Integer reportId; @@ -95,18 +103,17 @@ public String execute() { - try - { + { + File upload = new File( reportLocationManager.getReportExcelTempDirectory() + File.separator + + uploadFileName ); + + Workbook templateWorkbook = Workbook.getWorkbook( upload ); + + Sheet sheet = templateWorkbook.getSheet( 0 ); + ReportExcel report = reportExcelService.getReportExcel( reportId ); - File upload = new File( uploadFileName ); - WorkbookSettings ws = new WorkbookSettings(); - ws.setLocale( new Locale( "en", "EN" ) ); - Workbook templateWorkbook = Workbook.getWorkbook( upload, ws ); - Collection reportItems = report.getReportExcelItems(); - System.out.println( "reportItems : " + reportItems.size() ); - Sheet sheet = templateWorkbook.getSheet( 0 ); reportItemValues = new ArrayList(); @@ -125,7 +132,7 @@ reportItemValues.add( reportItemvalue ); } - + } return SUCCESS; === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2009-09-25 06:10:21 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2009-09-25 07:57:43 +0000 @@ -276,8 +276,7 @@ - @@ -298,14 +297,16 @@ scope="prototype"> - - - + + + + === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2009-09-25 06:10:21 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2009-09-25 07:57:43 +0000 @@ -557,6 +557,5 @@ -