=== modified file 'dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/hibernate/HibernateReportExcelStore.java' --- dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/hibernate/HibernateReportExcelStore.java 2010-02-24 08:56:35 +0000 +++ dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/hibernate/HibernateReportExcelStore.java 2010-02-25 04:22:49 +0000 @@ -46,6 +46,7 @@ import org.hisp.dhis.reportexcel.ReportExcelItem; import org.hisp.dhis.reportexcel.ReportExcelStore; import org.hisp.dhis.reportexcel.status.DataEntryStatus; +import org.springframework.transaction.annotation.Transactional; /** * @author Tran Thanh Tri @@ -369,18 +370,19 @@ Session session = sessionFactory.getCurrentSession(); session.update( periodColumn ); } - - @Override + + @Transactional public void updateReportWithExcelTemplate( String curTemplateName, String newTemplateName ) { Session session = sessionFactory.getCurrentSession(); - String sql = "update reportexcels set exceltemplate = " + newTemplateName + " where exceltemplate LIKE '" - + curTemplateName + "'"; - - SQLQuery query = session.createSQLQuery( sql ); + + String hqlQuery = "update reportexcels set exceltemplate = :newName where exceltemplate = :curName"; + + SQLQuery query = session.createSQLQuery( hqlQuery ); + + query.setString( "newName", newTemplateName ).setString( "curName", curTemplateName ); query.executeUpdate(); } - } === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ExcelTemplateListAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ExcelTemplateListAction.java 2010-02-24 08:56:35 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ExcelTemplateListAction.java 2010-02-25 04:22:49 +0000 @@ -54,7 +54,7 @@ public class ExcelTemplateListAction extends ActionSupport { - // ------------------------------------------- + // ------------------------------------------- // Dependency // ------------------------------------------- @@ -80,6 +80,11 @@ } // ------------------------------------------- + // Input + // ------------------------------------------- + private String mode; + + // ------------------------------------------- // Output // ------------------------------------------- @@ -101,11 +106,16 @@ return newFileUploadedOrRenamed; } + public void setMode( String mode ) + { + this.mode = mode; + } + public void setMessage( String message ) { this.message = message; } - + public String getMessage() { return message; @@ -130,28 +140,29 @@ { return SUCCESS; } - + + String newUploadOrRenamePath = null; + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Get the path of newly uploaded file // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - String newUploadOrRenamePath = selectionManager.getUploadFilePath(); + if ( !StringUtils.isNullOREmpty( mode ) ) + { + if ( mode.equalsIgnoreCase( "edit" ) ) + { + newUploadOrRenamePath = selectionManager.getRenameFilePath(); + } + else + { + newUploadOrRenamePath = selectionManager.getUploadFilePath(); + } + } if ( !StringUtils.isNullOREmpty( newUploadOrRenamePath ) ) { newFileUploadedOrRenamed = new File( newUploadOrRenamePath ).getName(); } - else - { - newUploadOrRenamePath = selectionManager.getRenameFilePath(); - - if ( !StringUtils.isNullOREmpty( newUploadOrRenamePath ) ) - { - newFileUploadedOrRenamed = new File( newUploadOrRenamePath ).getName(); - } - } - - System.out.println("\nnewFileUploadedOrRenamed = " + newFileUploadedOrRenamed); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Get the list of files @@ -159,7 +170,7 @@ List templateFiles = FileUtils.getListFile( templateDirectory, new ExcelFileFilter() ); - Collections.sort( templateFiles, new FileNameComparator() ); + Collections.sort( templateFiles, new FileNameComparator() ); Collection reportExcelTemplates = reportService.getALLReportExcelTemplates(); === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/UploadExcelTemplateAction.java' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/UploadExcelTemplateAction.java 2010-02-24 07:28:03 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/UploadExcelTemplateAction.java 2010-02-25 04:22:49 +0000 @@ -62,25 +62,46 @@ } // ------------------------------------------- - // Input & Output + // Input // ------------------------------------------- private String fileName; + private File upload; + + // ------------------------------------------- + // Output + // ------------------------------------------- + + private String mode; + + // ------------------------------------------- + // Getter && Setter + // ------------------------------------------- + public void setUploadFileName( String fileName ) { this.fileName = fileName; } - private File upload; - public void setUpload( File upload ) { this.upload = upload; } + public String getMode() + { + return mode; + } + + // ------------------------------------------- + // Action implementation + // ------------------------------------------- + public String execute() { + mode = "upload"; + File templateDirectoryConfig = reportLocationManager.getReportExcelTemplateDirectory(); File output = new File( templateDirectoryConfig, fileName ); === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2010-02-24 08:56:35 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2010-02-25 04:22:49 +0000 @@ -184,8 +184,8 @@ excel_template_management = Excel Template Management file_exists = File is existing confirm_override = Do you sure want to override this file? -upload_successful = Uploading is successful ! -override_successful = Overriding is successful ! +upload_successful = Uploading is success ! +override_successful = Overriding is success ! cannot_write_file_being_used = Unable to write to this file as being used by another program filename_wellformed = How to get a well-formed name of file? length_filename_min5_max30 = Length of file's name is at least 5 and at most 30 === modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm' --- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm 2010-02-25 02:41:20 +0000 +++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm 2010-02-25 04:22:49 +0000 @@ -9,17 +9,20 @@ - - - $i18n.getString( "filter_by_name" ): - - - - - + + + + + +
+ $i18n.getString( "filter_by_name" ): + + +
+ @@ -45,7 +48,7 @@
@@ -59,7 +62,7 @@