=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java 2012-07-09 09:16:24 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/GenerateExcelReportGeneric.java 2012-07-12 10:18:47 +0000 @@ -26,15 +26,14 @@ */ package org.hisp.dhis.reportsheet.exporting; +import static org.hisp.dhis.reportsheet.utils.DateUtils.getEndQuaterly; +import static org.hisp.dhis.reportsheet.utils.DateUtils.getEndSixMonthly; import static org.hisp.dhis.reportsheet.utils.DateUtils.getFirstDayOfMonth; import static org.hisp.dhis.reportsheet.utils.DateUtils.getFirstDayOfYear; import static org.hisp.dhis.reportsheet.utils.DateUtils.getLastDayOfYear; import static org.hisp.dhis.reportsheet.utils.DateUtils.getStartQuaterly; -import static org.hisp.dhis.reportsheet.utils.DateUtils.getEndQuaterly; import static org.hisp.dhis.reportsheet.utils.DateUtils.getStartSixMonthly; -import static org.hisp.dhis.reportsheet.utils.DateUtils.getEndSixMonthly; import static org.hisp.dhis.reportsheet.utils.DateUtils.getTimeRoll; - import static org.hisp.dhis.reportsheet.utils.ExpressionUtils.generateExpression; import static org.hisp.dhis.reportsheet.utils.ExpressionUtils.generateIndicatorExpression; import static org.hisp.dhis.reportsheet.utils.FileUtils.checkingExtensionExcelFile; @@ -56,7 +55,6 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.DataFormat; import org.apache.poi.ss.usermodel.Font; import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.IndexedColors; @@ -213,8 +211,6 @@ // Excel format // ------------------------------------------------------------------------- - protected DataFormat dFormat; - protected Font csFont; protected Font csFont11Bold; @@ -233,6 +229,8 @@ protected CellStyle csText; + protected CellStyle csTextWithoutBorder; + protected CellStyle csText10Bold; protected CellStyle csText9Bold; @@ -275,13 +273,13 @@ // Supporting methods // ------------------------------------------------------------------------- - public void createWorkbookInstance( ExportReport exportReport ) + private void createWorkbookInstance( String excelTemplateFileName ) throws FileNotFoundException, IOException { this.inputStreamExcelTemplate = new FileInputStream( reportLocationManager.getExportReportTemplateDirectory() - + File.separator + exportReport.getExcelTemplateFile() ); + + File.separator + excelTemplateFileName ); - if ( checkingExtensionExcelFile( exportReport.getExcelTemplateFile() ) ) + if ( checkingExtensionExcelFile( excelTemplateFileName ) ) { this.templateWorkbook = new HSSFWorkbook( this.inputStreamExcelTemplate ); } @@ -291,7 +289,7 @@ } } - public void initExcelFormat() + private void initExcelFormat() throws Exception { sheetPOI = templateWorkbook.getSheetAt( 0 ); @@ -301,10 +299,10 @@ csFont10Bold = templateWorkbook.createFont(); csFont11Bold = templateWorkbook.createFont(); csFont12BoldCenter = templateWorkbook.createFont(); - dFormat = templateWorkbook.createDataFormat(); csNumber = templateWorkbook.createCellStyle(); csFormula = templateWorkbook.createCellStyle(); csText = templateWorkbook.createCellStyle(); + csTextWithoutBorder = templateWorkbook.createCellStyle(); csText8Bold = templateWorkbook.createCellStyle(); csText9Bold = templateWorkbook.createCellStyle(); csText10Bold = templateWorkbook.createCellStyle(); @@ -314,12 +312,14 @@ } @SuppressWarnings( "static-access" ) - public void installDefaultExcelFormat() + private void installDefaultExcelFormat() throws Exception { initPOIStylesManager.initDefaultFont( csFont ); initPOIStylesManager.initDefaultCellStyle( csText, csFont ); + csTextWithoutBorder.setFont( csFont ); + initPOIStylesManager.initFont( csFont8Bold, "Tahoma", (short) 8, Font.BOLDWEIGHT_BOLD, IndexedColors.BLACK .getIndex() ); initPOIStylesManager.initFont( csFont9Bold, "Tahoma", (short) 9, Font.BOLDWEIGHT_BOLD, IndexedColors.BLACK @@ -409,16 +409,17 @@ protected void installReadTemplateFile( ExportReport exportReport, Period period, Object object ) throws Exception { - Calendar calendar = Calendar.getInstance(); - - File reportTempDir = reportLocationManager.getExportReportTemporaryDirectory(); - - this.outputReportFile = new File( reportTempDir, currentUserService.getCurrentUsername() - + this.dateformatter.format( calendar.getTime() ) + exportReport.getExcelTemplateFile() ); + this.outputReportFile = new File + ( + reportLocationManager.getExportReportTemporaryDirectory(), + currentUserService.getCurrentUsername() + + this.dateformatter.format( Calendar.getInstance().getTime() ) + + exportReport.getExcelTemplateFile() + ); this.outputStreamExcelTemplate = new FileOutputStream( outputReportFile ); - this.createWorkbookInstance( exportReport ); + this.createWorkbookInstance( exportReport.getExcelTemplateFile() ); this.initExcelFormat(); @@ -430,25 +431,21 @@ if ( object instanceof OrganisationUnit ) { - OrganisationUnit orgunit = (OrganisationUnit) object; - - value = orgunit.getName(); + value = ((OrganisationUnit) object).getName(); } else { - OrganisationUnitGroup orgunitGroup = (OrganisationUnitGroup) object; - - value = orgunitGroup.getName(); + value = ((OrganisationUnitGroup) object).getName(); } ExcelUtils.writeValueByPOI( exportReport.getOrganisationRow(), exportReport.getOrganisationColumn(), value, - ExcelUtils.TEXT, templateWorkbook.getSheetAt( 0 ), csText ); + ExcelUtils.TEXT, sheetPOI, csTextWithoutBorder ); } if ( exportReport.getPeriodRow() != null && exportReport.getPeriodColumn() != null ) { ExcelUtils.writeValueByPOI( exportReport.getPeriodRow(), exportReport.getPeriodColumn(), format - .formatPeriod( period ), ExcelUtils.TEXT, templateWorkbook.getSheetAt( 0 ), csText ); + .formatPeriod( period ), ExcelUtils.TEXT, sheetPOI, csTextWithoutBorder ); } } @@ -662,7 +659,7 @@ // Formulae methods // ------------------------------------------------------------------------- - public void initFormulaEvaluating() + protected void initFormulaEvaluating() { this.evaluatorFormula = this.templateWorkbook.getCreationHelper().createFormulaEvaluator(); } === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2012-07-10 08:31:36 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/GenerateReportOrgGroupListingAction.java 2012-07-12 10:18:47 +0000 @@ -59,7 +59,7 @@ { private static final String PREFIX_FORMULA_SUM = "SUM("; - private static Map> childrenGroupMap = new HashMap>(); + private Map> childrenGroupMap = new HashMap>(); // ------------------------------------------------------------------------- // Dependency @@ -103,7 +103,7 @@ */ exportReportItems = null; orgUnitGroupAtLevels = null; - childrenGroupMap.clear(); + childrenGroupMap = null; } // ------------------------------------------------------------------------- === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java 2011-11-03 04:26:28 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ImportDataGeneric.java 2012-07-12 10:18:47 +0000 @@ -46,6 +46,7 @@ import org.hisp.dhis.reportsheet.period.generic.PeriodGenericManager; import org.hisp.dhis.reportsheet.state.SelectionManager; import org.hisp.dhis.user.CurrentUserService; +import org.springframework.beans.factory.annotation.Autowired; /** * @author Dang Duy Hieu @@ -59,76 +60,36 @@ // Dependencies // ------------------------------------------------------------------------- + @Autowired protected CurrentUserService currentUserService; - public void setCurrentUserService( CurrentUserService currentUserService ) - { - this.currentUserService = currentUserService; - } - + @Autowired protected DataElementService dataElementService; - public void setDataElementService( DataElementService dataElementService ) - { - this.dataElementService = dataElementService; - } - + @Autowired protected DataElementCategoryService categoryService; - public void setCategoryService( DataElementCategoryService categoryService ) - { - this.categoryService = categoryService; - } - + @Autowired protected DataValueService dataValueService; - public void setDataValueService( DataValueService dataValueService ) - { - this.dataValueService = dataValueService; - } - + @Autowired protected ExpressionService expressionService; - public void setExpressionService( ExpressionService expressionService ) - { - this.expressionService = expressionService; - } - + @Autowired protected ImportReportService importReportService; - public void setImportReportService( ImportReportService importReportService ) - { - this.importReportService = importReportService; - } - + @Autowired protected OrganisationUnitService organisationUnitService; - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - + @Autowired protected OrganisationUnitSelectionManager organisationUnitSelectionManager; - public void setOrganisationUnitSelectionManager( OrganisationUnitSelectionManager organisationUnitSelectionManager ) - { - this.organisationUnitSelectionManager = organisationUnitSelectionManager; - } - + @Autowired protected PeriodGenericManager periodGenericManager; - public void setPeriodGenericManager( PeriodGenericManager periodGenericManager ) - { - this.periodGenericManager = periodGenericManager; - } - + @Autowired protected SelectionManager selectionManager; - public void setSelectionManager( SelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -172,7 +133,7 @@ protected void addDataValue( OrganisationUnit unit, Period period, String expression, String value ) { value = value.replaceAll( "\\.", "" ).replace( ",", "." ); - + DataElementOperand operand = expressionService.getOperandsInExpression( expression ).iterator().next(); DataElement dataElement = dataElementService.getDataElement( operand.getDataElementId() ); === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ViewDataGeneric.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ViewDataGeneric.java 2011-07-28 09:50:39 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/ViewDataGeneric.java 2012-07-12 10:18:47 +0000 @@ -35,6 +35,7 @@ import org.hisp.dhis.reportsheet.importitem.ImportReport; import org.hisp.dhis.reportsheet.importitem.ImportReportService; import org.hisp.dhis.reportsheet.state.SelectionManager; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -50,20 +51,12 @@ // Dependencies // ------------------------------------------------------------------------- + @Autowired protected ImportReportService importReportService; - public void setImportReportService( ImportReportService importReportService ) - { - this.importReportService = importReportService; - } - + @Autowired protected SelectionManager selectionManager; - public void setSelectionManager( SelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - private I18n i18n; public void setI18n( I18n i18n ) === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataFlowAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataFlowAction.java 2011-08-04 08:39:55 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/importing/action/ImportDataFlowAction.java 2012-07-12 10:18:47 +0000 @@ -31,6 +31,7 @@ import org.hisp.dhis.reportsheet.importitem.ImportReportService; import org.hisp.dhis.reportsheet.period.generic.PeriodGenericManager; import org.hisp.dhis.reportsheet.state.SelectionManager; +import org.springframework.beans.factory.annotation.Autowired; import com.opensymphony.xwork2.Action; @@ -45,27 +46,15 @@ // Dependencies // ------------------------------------------------------------------------- + @Autowired private ImportReportService importReportService; - public void setImportReportService( ImportReportService importReportService ) - { - this.importReportService = importReportService; - } - + @Autowired private PeriodGenericManager periodGenericManager; - public void setPeriodGenericManager( PeriodGenericManager periodGenericManager ) - { - this.periodGenericManager = periodGenericManager; - } - + @Autowired private SelectionManager selectionManager; - public void setSelectionManager( SelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - // ------------------------------------------------------------------------- // Input & Output // ------------------------------------------------------------------------- === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseImport.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseImport.java 2012-04-06 06:21:25 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/action/XMLStructureResponseImport.java 2012-07-12 10:18:47 +0000 @@ -34,7 +34,6 @@ import static org.hisp.dhis.reportsheet.utils.NumberUtils.applyPatternDecimalFormat; import static org.hisp.dhis.reportsheet.utils.NumberUtils.resetDecimalFormatByLocale; -import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Collection; @@ -93,7 +92,6 @@ * Constructor * * @param importItems - * @param type The TYPE for importing * * @param w The workbook to interrogate * @param enc The encoding used by the output stream. Null or unrecognized @@ -109,7 +107,7 @@ { this.cleanUpForResponse(); - FileInputStream inputStream = new FileInputStream( new File( pathFileName ) ); + FileInputStream inputStream = new FileInputStream( pathFileName ); if ( getExtension( pathFileName ).equals( "xls" ) ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/manager/DefaultInitializePOIStylesManager.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/manager/DefaultInitializePOIStylesManager.java 2011-08-04 08:39:55 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/preview/manager/DefaultInitializePOIStylesManager.java 2012-07-12 10:18:47 +0000 @@ -111,7 +111,7 @@ // ------------------------------------------------------------------------- // Customized Methods - Using for XLS Extension // ------------------------------------------------------------------------- - + public void initHeader( HSSFHeader poi_header, String center, String left, String right ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-07-06 19:43:15 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2012-07-12 10:18:47 +0000 @@ -1162,130 +1162,32 @@ - - - - + - - - - + - - - - - + - - - - - + class="org.hisp.dhis.reportsheet.importing.action.ImportDataFlowAction" scope="prototype"/> - - - - - - - - - - - + class="org.hisp.dhis.reportsheet.importing.action.ImportDataNormalAction" scope="prototype"/> - - - - - - - - - - - + class="org.hisp.dhis.reportsheet.importing.action.ImportDataCategoryAction" scope="prototype"/> - - - - - - - - - - - + class="org.hisp.dhis.reportsheet.importing.action.ImportDataOrganizationGroupAction" scope="prototype"/>