=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelItem.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelItem.java 2009-09-15 13:18:11 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelItem.java 2009-10-01 08:28:21 +0000 @@ -184,7 +184,7 @@ public static class TYPE { - public static final String DATAELEMENT = "dataelement"; + public static final String DATAELEMENT = "dataelement"; public static final String ORGANISATION = "organisation"; public static final String INDICATOR = "indicator"; public static final String CALCULATION = "calculation"; === added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/DowloadExcelAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/DowloadExcelAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/DowloadExcelAction.java 2009-10-01 08:28:21 +0000 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2004-2007, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.hisp.dhis.reportexcel.export.action; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +import com.opensymphony.xwork2.Action; + +/** + * @author Tran Thanh Tri + * @version $Id$ + */ +public class DowloadExcelAction + implements Action +{ + + private SelectionManager selectionManager; + + private String outputXLS; + + private InputStream inputStream; + + public String getOutputXLS() + { + return outputXLS; + } + + public InputStream getInputStream() + { + return inputStream; + } + + public void setSelectionManager( SelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + public String execute() + throws Exception + { + File outputReportFile = new File(selectionManager.getReportExcelOutput()); + + outputXLS = outputReportFile.getName(); + + inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); + + return SUCCESS; + } + +} === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelCategoryAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelCategoryAction.java 2009-09-18 04:37:50 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelCategoryAction.java 2009-10-01 08:28:21 +0000 @@ -26,8 +26,6 @@ */ package org.hisp.dhis.reportexcel.export.action; -import java.io.BufferedInputStream; -import java.io.FileInputStream; import java.util.Collection; import jxl.write.WritableSheet; @@ -75,16 +73,8 @@ this.generateOutPutFile( organisationUnit, reportExcelItems, reportExcel, sheet ); } - - outputReportWorkbook.write(); - - outputReportWorkbook.close(); - - outputXLS = outputReportFile.getName(); - - inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); - - outputReportFile.delete(); + + this.complete(); statementManager.destroy(); === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelNormalAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelNormalAction.java 2009-09-17 07:12:56 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelNormalAction.java 2009-10-01 08:28:21 +0000 @@ -26,8 +26,6 @@ */ package org.hisp.dhis.reportexcel.export.action; -import java.io.BufferedInputStream; -import java.io.FileInputStream; import java.util.Collection; import jxl.write.WritableSheet; @@ -71,19 +69,9 @@ this.generateOutPutFile( organisationUnit, reportExcelItems, sheet ); - } - - outputReportWorkbook.write(); - - outputReportWorkbook.close(); - - outputXLS = outputReportFile.getName(); - - inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); - - outputReportFile.delete(); - - statementManager.destroy(); + } + + this.complete(); return SUCCESS; } @@ -109,7 +97,7 @@ ExcelUtils.writeValue( reportItem.getRow(), reportItem.getColumn(), String.valueOf( value ), ExcelUtils.NUMBER, sheet, number ); } - } + } } } === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelOrganizationGroupListingAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelOrganizationGroupListingAction.java 2009-09-18 02:04:21 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelOrganizationGroupListingAction.java 2009-10-01 08:28:21 +0000 @@ -26,8 +26,6 @@ */ package org.hisp.dhis.reportexcel.export.action; -import java.io.BufferedInputStream; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -75,18 +73,10 @@ this.generateOutPutFile( reportExcel, reportExcelItems, organisationUnit, sheet ); - } - - outputReportWorkbook.write(); - - outputReportWorkbook.close(); - - outputXLS = outputReportFile.getName(); - - inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); - - outputReportFile.delete(); - + } + + this.complete(); + statementManager.destroy(); return SUCCESS; @@ -119,9 +109,10 @@ ExcelUtils.TEXT, sheet, this.textChapterLeft ); } else if ( reportItem.getItemType().equalsIgnoreCase( ReportExcelItem.TYPE.SERIAL ) - && (!organisationUnits.isEmpty()) ){ - ExcelUtils.writeValue( rowBegin, reportItem.getColumn(), chappter[chapperNo], - ExcelUtils.TEXT, sheet, this.textChapterLeft ); + && (!organisationUnits.isEmpty()) ) + { + ExcelUtils.writeValue( rowBegin, reportItem.getColumn(), chappter[chapperNo], ExcelUtils.TEXT, + sheet, this.textChapterLeft ); } chapperNo++; rowBegin++; === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelPeriodColumnListingAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelPeriodColumnListingAction.java 2009-09-18 07:09:19 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelPeriodColumnListingAction.java 2009-10-01 08:28:21 +0000 @@ -27,8 +27,6 @@ package org.hisp.dhis.reportexcel.export.action; -import java.io.BufferedInputStream; -import java.io.FileInputStream; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; @@ -93,15 +91,7 @@ } - outputReportWorkbook.write(); - - outputReportWorkbook.close(); - - outputXLS = outputReportFile.getName(); - - inputStream = new BufferedInputStream( new FileInputStream( outputReportFile ) ); - - outputReportFile.delete(); + this.complete(); statementManager.destroy(); === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelSupport.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelSupport.java 2009-09-18 07:09:19 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/GenerateReportExcelSupport.java 2009-10-01 08:28:21 +0000 @@ -73,7 +73,6 @@ import org.hisp.dhis.system.util.MathUtils; import org.hisp.dhis.user.CurrentUserService; - import com.opensymphony.xwork2.Action; /** @@ -85,10 +84,10 @@ { private static final String NULL_REPLACEMENT = "0"; - - protected static final String[] chappter = {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", - "X","XI","XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX", "XXI", "XXII", - "XXIII", "XXIV", "XXV","XXVI", "XXVII", "XXVIII", "XXIX", "XXX"}; + + protected static final String[] chappter = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", + "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX", "XXI", "XXII", "XXIII", "XXIV", "XXV", "XXVI", + "XXVII", "XXVIII", "XXIX", "XXX" }; // ------------------------------------------- // Dependency @@ -408,6 +407,16 @@ } + public void complete() + throws IOException, WriteException + { + outputReportWorkbook.write(); + + outputReportWorkbook.close(); + + selectionManager.setReportExcelOutput( outputReportFile.getPath() ); + } + protected String generateIndicatorExpression( ReportExcelItem reportItem, Date startDate, Date endDate, OrganisationUnit organisationUnit ) { === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/SelectionManager.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/SelectionManager.java 2009-09-17 07:12:56 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/export/action/SelectionManager.java 2009-10-01 08:28:21 +0000 @@ -43,38 +43,40 @@ private static final String SELETED_PERIOD = "SELETED_PERIOD"; - private static final String SELETED_REPORT_EXCEL = "SELETED_REPORT_EXCEL"; - - private static final String SELECTED_REPORT_EXCEL_ID = "SELECTED_REPORT_EXCEL_ID"; + private static final String SELETED_REPORT_EXCEL = "SELETED_REPORT_EXCEL"; + + private static final String SELECTED_REPORT_EXCEL_ID = "SELECTED_REPORT_EXCEL_ID"; + + private static final String REPORTEXCEL_OUTPUT = "REPORTEXCEL_OUTPUT"; public Period getSelectedPeriod() { return (Period) getSession().get( SELETED_PERIOD ); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public void setSelectedPeriod( Period period ) { getSession().put( SELETED_PERIOD, period ); } - + public ReportExcel getSelectedReportExcel() { return (ReportExcel) getSession().get( SELETED_REPORT_EXCEL ); } - @SuppressWarnings("unchecked") + @SuppressWarnings( "unchecked" ) public void setSelectedReportExcel( ReportExcel reportExcel ) { getSession().put( SELETED_REPORT_EXCEL, reportExcel ); } - - @SuppressWarnings("unchecked") + + @SuppressWarnings( "unchecked" ) public void setSelectedReportExcelId( Integer id ) { getSession().put( SELECTED_REPORT_EXCEL_ID, id ); } - + public Integer getSelectedReportExcelId() { return (Integer) getSession().get( SELECTED_REPORT_EXCEL_ID ); @@ -97,4 +99,15 @@ return ActionContext.getContext().getSession(); } + @SuppressWarnings( "unchecked" ) + public void setReportExcelOutput( String path ) + { + getSession().put( REPORTEXCEL_OUTPUT, path ); + } + + public String getReportExcelOutput() + { + return (String) getSession().get( REPORTEXCEL_OUTPUT ); + } + } === 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-30 07:03:26 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2009-10-01 08:28:21 +0000 @@ -329,6 +329,13 @@ + + + + - + administration.action F_EXCEL_REPORT_ADMINISTRATION - + @@ -44,7 +44,7 @@ /dhis-web-excel-reporting/viewAdministrator.vm /dhis-web-excel-reporting/menu.vm F_EXCEL_REPORT_ADMINISTRATION - + @@ -398,52 +398,52 @@ class="org.hisp.dhis.reportexcel.export.action.GetMonthlyPeriodsAction"> /dhis-web-excel-reporting/responsePeriods.vm - + + + - generateReportExcelCategory + + generateReportExcelCategoryAjax - generateReportExcelNormal + + generateReportExcelNormalAjax - generateReportExcelOrganizationGroupListing + generateReportExcelOrganizationGroupListingAjax + - generateReportExcelPeriodColumnListing + generateReportExcelPeriodColumnListingAjax + - - - application/vnd.ms-excel - inputStream - filename="${outputXLS}" - 1024 - + + /dhis-web-excel-reporting/responseSuccess.vm - - - application/vnd.ms-excel - inputStream - filename="${outputXLS}" - 1024 - + + /dhis-web-excel-reporting/responseSuccess.vm - - - application/vnd.ms-excel - inputStream - filename="${outputXLS}" - 1024 - + + /dhis-web-excel-reporting/responseSuccess.vm - + + /dhis-web-excel-reporting/responseSuccess.vm + + + application/vnd.ms-excel inputStream @@ -452,7 +452,6 @@ - - + @@ -566,16 +565,17 @@ /dhis-web-excel-reporting/responseError.vm - + /popup.vm - /dhis-web-excel-reporting/responseError.vm + + /dhis-web-excel-reporting/responseError.vm /dhis-web-excel-reporting/viewReportPreview.vm style/previewStyle.css javascript/preview.js - + @@ -594,31 +594,37 @@ - exportXMLChain + exportXMLChain + - exportXMLChain + exportXMLChain + - exportXMLChain + exportXMLChain + - exportXMLChain + exportXMLChain + - - - /dhis-web-excel-reporting/responseReportPreview.vm - /dhis-web-excel-reporting/responseError.vm + + /dhis-web-excel-reporting/responseReportPreview.vm + + /dhis-web-excel-reporting/responseError.vm style/previewStyle.css javascript/preview.js - + === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js 2009-09-30 07:03:26 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/export.js 2009-10-01 08:28:21 +0000 @@ -49,11 +49,16 @@ } function generateReportExcel() { - - var reportId = $('#report').val(); - var periodId = $('#period').val(); - window.location = "generateReportExcel.action?reportId=" + reportId + "&periodId=" + periodId + "&reportType=category"; + $("#loading").showAtCenter( true ); + $.post("generateReportExcelAjax.action",{ + reportId:$('#report').val(), + periodId:$('#period').val() + },function(data){ + window.location = "downloadExcelOutput.action"; + deleteDivEffect(); + $("#loading").hide(); + },'xml'); } === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/listDataElementGroup.vm' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/listDataElementGroup.vm 2009-09-25 06:10:21 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/listDataElementGroup.vm 2009-10-01 08:28:21 +0000 @@ -40,7 +40,7 @@
-