dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04438
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1480: Excel Template Management - Working ...
------------------------------------------------------------
revno: 1480
committer: hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-02-24 15:56:35 +0700
message:
Excel Template Management - Working ...
added:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseNone.vm
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelStore.java
dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportExcelService.java
dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/hibernate/HibernateReportExcelStore.java
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/state/DefaultSelectionManager.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/state/SelectionManager.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java
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/org/hisp/dhis/reportexcel/i18n_module.properties
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml
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/javascript/exceltemplate.js
--
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-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelService.java 2010-02-23 04:26:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelService.java 2010-02-24 08:56:35 +0000
@@ -62,9 +62,13 @@
public Collection<ReportExcel> getReportExcels( User user, boolean superUser, String group );
+ public Collection<ReportExcel> getReportsByGroup( String group );
+
public Collection<String> getReportExcelGroups();
- public Collection<ReportExcel> getReportsByGroup( String group );
+ public Collection<String> getALLReportExcelTemplates();
+
+ public void updateReportExcelSystemByTemplate( String curTemplateName, String newTemplateName );
// --------------------------------------
// Service of Report Item
@@ -80,7 +84,7 @@
public Collection<ReportExcelItem> getALLReportExcelItem();
- public Collection<ReportExcelItem> getReportExcelItem( int sheetNo, Integer reportId );
+ public Collection<ReportExcelItem> getReportExcelItem( int sheetNo, Integer reportId );
public Collection<Integer> getSheets( Integer reportId );
@@ -115,12 +119,12 @@
Collection<DataEntryStatus> getDataEntryStatusDefaultByDataSets( Collection<DataSet> dataSets );
public int countDataValueOfDataSet( DataSet dataSet, OrganisationUnit organisationUnit, Period period );
-
+
// --------------------------------------
// Period Column
// --------------------------------------
-
+
public PeriodColumn getPeriodColumn( Integer id );
-
+
public void updatePeriodColumn( PeriodColumn periodColumn );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelStore.java 2010-02-23 04:26:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reportexcel/ReportExcelStore.java 2010-02-24 08:56:35 +0000
@@ -59,9 +59,11 @@
public Collection<ReportExcel> getALLReportExcel();
+ public Collection<ReportExcel> getReportsByGroup( String group );
+
public Collection<String> getReportExcelGroups();
- public Collection<ReportExcel> getReportsByGroup( String group );
+ public Collection<String> getALLReportExcelTemplates();
// --------------------------------------
// Service of Report Item
@@ -82,6 +84,8 @@
public Collection<Integer> getSheets( Integer reportId );
public void deleteMultiReportExcelItem( Collection<Integer> ids );
+
+ public void updateReportWithExcelTemplate( String curTemplateName, String newTemplateName );
// --------------------------------------
// DataElement Order
=== modified file 'dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportExcelService.java'
--- dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportExcelService.java 2010-02-23 04:26:05 +0000
+++ dhis-2/dhis-services/dhis-service-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/DefaultReportExcelService.java 2010-02-24 08:56:35 +0000
@@ -138,7 +138,11 @@
return reportStore.getReportsByGroup( group );
}
- @Override
+ public Collection<String> getALLReportExcelTemplates()
+ {
+ return reportStore.getALLReportExcelTemplates();
+ }
+
public void deleteMultiReportExcelItem( Collection<Integer> ids )
{
if ( !ids.isEmpty() )
@@ -147,6 +151,13 @@
}
}
+ @Override
+ public void updateReportExcelSystemByTemplate( String curName, String newName )
+ {
+ reportStore.updateReportWithExcelTemplate( curName, newName );
+
+ }
+
// --------------------------------------
// Service of Report Item
// --------------------------------------
@@ -262,5 +273,5 @@
{
reportStore.updatePeriodColumn( periodColumn );
}
-
+
}
=== 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-23 04:26:05 +0000
+++ 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
@@ -154,6 +154,16 @@
return criteria.list();
}
+ @SuppressWarnings( "unchecked" )
+ public Collection<String> getALLReportExcelTemplates()
+ {
+ Session session = sessionFactory.getCurrentSession();
+
+ SQLQuery sqlQuery = session.createSQLQuery( "select DISTINCT(exceltemplate) from reportexcels" );
+
+ return sqlQuery.list();
+ }
+
// --------------------------------------
// Service of Report Item
// --------------------------------------
@@ -222,7 +232,7 @@
{
String sql = "delete ReportExcelItem d where d.id in (:ids)";
- Query query = sessionFactory.getCurrentSession().createQuery( sql );
+ Query query = sessionFactory.getCurrentSession().createQuery( sql );
query.setParameterList( "ids", ids );
query.executeUpdate();
@@ -359,5 +369,18 @@
Session session = sessionFactory.getCurrentSession();
session.update( periodColumn );
}
+
+ @Override
+ 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 );
+
+ 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 07:28:03 +0000
+++ 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
@@ -28,16 +28,20 @@
*/
import java.io.File;
-import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.reportexcel.ReportExcelService;
import org.hisp.dhis.reportexcel.ReportLocationManager;
import org.hisp.dhis.reportexcel.action.ActionSupport;
import org.hisp.dhis.reportexcel.state.SelectionManager;
import org.hisp.dhis.reportexcel.utils.ExcelFileFilter;
import org.hisp.dhis.reportexcel.utils.FileUtils;
+import org.hisp.dhis.reportexcel.utils.StringUtils;
import org.hisp.dhis.system.comparator.FileNameComparator;
/**
@@ -50,7 +54,7 @@
public class ExcelTemplateListAction
extends ActionSupport
{
- // -------------------------------------------
+ // -------------------------------------------
// Dependency
// -------------------------------------------
@@ -68,28 +72,40 @@
this.selectionManager = selectionManager;
}
+ private ReportExcelService reportService;
+
+ public void setReportService( ReportExcelService reportService )
+ {
+ this.reportService = reportService;
+ }
+
// -------------------------------------------
// Output
// -------------------------------------------
- private List<File> templateFiles = new ArrayList<File>();
+ private String newFileUploadedOrRenamed;
+
+ private Map<String, Boolean> mapTemplateFiles = new HashMap<String, Boolean>();
// -------------------------------------------
// Getter && Setter
// -------------------------------------------
- private String newFileUploaded;
-
- public String getNewFileUploaded()
- {
- return newFileUploaded;
- }
-
- public List<File> getTemplateFiles()
- {
- return templateFiles;
- }
-
+ public Map<String, Boolean> getMapTemplateFiles()
+ {
+ return mapTemplateFiles;
+ }
+
+ public String getNewFileUploadedOrRenamed()
+ {
+ return newFileUploadedOrRenamed;
+ }
+
+ public void setMessage( String message )
+ {
+ this.message = message;
+ }
+
public String getMessage()
{
return message;
@@ -108,34 +124,59 @@
public String execute()
throws Exception
{
-
File templateDirectory = reportLocationManager.getReportExcelTemplateDirectory();
if ( !templateDirectory.exists() )
{
return SUCCESS;
}
-
+
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Get the path of newly uploaded file
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- String newUploadedPath = selectionManager.getUploadFilePath();
-
- if ( (newUploadedPath != "") && (newUploadedPath != null) )
- {
- newFileUploaded = new File( newUploadedPath ).getName();
- }
+ String 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
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- templateFiles = FileUtils.getListFile( templateDirectory, new ExcelFileFilter() );
-
- Collections.sort( templateFiles, new FileNameComparator() );
+ List<File> templateFiles = FileUtils.getListFile( templateDirectory, new ExcelFileFilter() );
+
+ Collections.sort( templateFiles, new FileNameComparator() );
+
+ Collection<String> reportExcelTemplates = reportService.getALLReportExcelTemplates();
+
+ Collections.sort( templateFiles );
+
+ for ( File file : templateFiles )
+ {
+ if ( reportExcelTemplates.contains( file.getName() ) )
+ {
+ mapTemplateFiles.put( file.getName(), true );
+ }
+ else
+ {
+ mapTemplateFiles.put( file.getName(), false );
+ }
+ }
return SUCCESS;
}
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/state/DefaultSelectionManager.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/state/DefaultSelectionManager.java 2009-11-13 10:28:52 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/state/DefaultSelectionManager.java 2010-02-24 08:56:35 +0000
@@ -41,6 +41,8 @@
private static final String SESSION_KEY_FILE_DOWNLOAD = "SESSION_KEY_FILE_DOWNLOAD";
private static final String SESSION_KEY_FILE_UPLOAD = "SESSION_KEY_FILE_UPLOAD";
+
+ private static final String SESSION_KEY_FILE_RENAME = "SESSION_KEY_FILE_RENAME";
private static final String SESSION_KEY_SELECTED_REPORT_ID = "SESSION_KEY_SELECTED_REPORT_ID";
@@ -89,4 +91,17 @@
getSession().put( SESSION_KEY_SELECTED_REPORT_ID, id );
}
+ @Override
+ public String getRenameFilePath()
+ {
+ return (String) getSession().get( SESSION_KEY_FILE_RENAME );
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void setRenameFilePath( String path )
+ {
+ getSession().put( SESSION_KEY_FILE_RENAME, path );
+ }
+
}
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/state/SelectionManager.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/state/SelectionManager.java 2009-11-13 10:28:52 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/state/SelectionManager.java 2010-02-24 08:56:35 +0000
@@ -43,5 +43,9 @@
public void setSelectedReportId( Integer id );
public Integer getSelectedReportId();
+
+ public String getRenameFilePath();
+
+ public void setRenameFilePath( String path );
}
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java 2010-02-24 07:28:03 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/FileUtils.java 2010-02-24 08:56:35 +0000
@@ -140,7 +140,18 @@
}
catch ( FileNotFoundException e )
{
- // TODO Auto-generated catch block
+ return false;
+ }
+ }
+
+ public static boolean rename( File curFile, File newFile )
+ {
+ try
+ {
+ return curFile.renameTo( newFile );
+ }
+ catch ( Exception e )
+ {
return false;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java 2009-12-17 02:15:50 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/utils/StringUtils.java 2010-02-24 08:56:35 +0000
@@ -168,4 +168,9 @@
return path;
}
+
+ public static boolean isNullOREmpty( String input )
+ {
+ return (((input == "") || (input == null)) ? true : false);
+ }
}
=== 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 2010-02-24 07:28:03 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-02-24 08:56:35 +0000
@@ -1259,6 +1259,8 @@
id="org.hisp.dhis.reportexcel.filemanager.action.ExcelTemplateListAction"
class="org.hisp.dhis.reportexcel.filemanager.action.ExcelTemplateListAction"
scope="prototype">
+ <property name="reportService"
+ ref="org.hisp.dhis.reportexcel.ReportExcelService" />
<property name="reportLocationManager"
ref="org.hisp.dhis.reportexcel.ReportLocationManager" />
<property name="selectionManager"
@@ -1283,6 +1285,21 @@
<property name="selectionManager"
ref="org.hisp.dhis.reportexcel.state.SelectionManager" />
</bean>
+
+ <bean
+ id="org.hisp.dhis.reportexcel.filemanager.action.RenameExcelTemplateAction"
+ class="org.hisp.dhis.reportexcel.filemanager.action.RenameExcelTemplateAction"
+ scope="prototype">
+ <property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager" />
+ <property name="selectionManager" ref="org.hisp.dhis.reportexcel.state.SelectionManager" />
+ </bean>
+
+ <bean
+ id="org.hisp.dhis.reportexcel.filemanager.action.UpdateReportExcelByTemplateAction"
+ class="org.hisp.dhis.reportexcel.filemanager.action.UpdateReportExcelByTemplateAction"
+ scope="prototype">
+ <property name="reportService" ref="org.hisp.dhis.reportexcel.ReportExcelService" />
+ </bean>
<bean
id="org.hisp.dhis.reportexcel.filemanager.action.DownloadExcelTemplateFileAction"
=== 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 07:28:03 +0000
+++ 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
@@ -184,11 +184,21 @@
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 successful !
+override_successful = Overriding is successful !
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
use_only_letters_numbers_dot_only = Please enter Letters, Numbers for file's name and Dot for extension only
-cell_exist = Exist one cell same sheet, row and column with this.
-download = Download
\ No newline at end of file
+rename = Rename
+file_used_system = This file is being used in the system
+confirm_rename = Do you really want to rename it?
+rename_successful = File name changed
+confirm_update_system = Would you like to update reporting system?
+rename_failed = Rename failed
+template_status = Template status
+use_only_letters_numbers_dot_only = Please enter Letters, Numbers for file's name and Dot for extension only
+cell_exist = Exist one cell same sheet, row and column with this.
+update_successful = Updating is success !
+cell_exist = Exist one cell same sheet, row and column with this.
+download = Download
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2010-02-24 07:28:03 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2010-02-24 08:56:35 +0000
@@ -184,12 +184,21 @@
choose_report = Ch\u01b0a ch\u1ecdn b\u00e1o c\u00e1o
excel_template_management = Qu\u1ea3n l\u00fd c\u00e1c t\u1eadp tin excel m\u1eabu
confirm_override = B\u1ea1n c\u00f3 mu\u1ed1n ghi \u0111\u00e8 l\u00ean t\u1eadp tin \u0111\u00e3 c\u00f3?
-file_exists = T\u1eadp tin excel n\u00e0y \u0111ang t\u1ed3n t\u1ea1i!
+file_exists = T\u1eadp tin excel n\u00e0y \u0111ang t\u1ed3n t\u1ea1i !
upload_successful = T\u1ea3i t\u1eadp tin th\u00e0nh c\u00f4ng!
override_successful = T\u1eadp tin n\u00e0y \u0111\u00e3 \u0111\u01b0\u1ee3c ghi \u0111\u00e8!
cannot_write_file_being_used = Kh\u00f4ng th\u1ec3 ghi l\u00ean t\u1eadp tin n\u00e0y v\u00ec \u0111ang \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng b\u1edfi m\u1ed9t ch\u01b0\u01a1ng tr\u00ecnh kh\u00e1c
filename_wellformed = L\u00e0m c\u00e1ch n\u00e0o \u0111\u1ec3 c\u00f3 t\u00ean t\u1eadp tin h\u1ee3p l\u1ec7?
+length_filename_min5_max30 = \u0110\u1ed9 d\u00e0i c\u1ee7a t\u00ean t\u1eadp tin t\u1ed1i thi\u1ec3u l\u00e0 5 v\u00e0 t\u1ed1i \u0111a l\u00e0 30
+use_only_letters_numbers_dot_only = Ch\u1ec9 nh\u1eadp K\u00fd t\u1ef1, S\u1ed1 cho t\u00ean t\u1eadp tin v\u00e0 D\u1ea5u ch\u1ea5m(.) cho ph\u1ea7n \u0111u\u00f4i m\u1edf r\u1ed9ng
+file_used_system = T\u1eadp tin n\u00e0y \u0111ang \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng trong H\u1ec7 th\u1ed1ng
+confirm_rename = B\u1ea1n c\u00f3 mu\u1ed1n \u0111\u1ed5i t\u00ean n\u00f3 kh\u00f4ng?
+rename_successful = T\u00ean t\u1eadp tin \u0111\u00e3 \u0111\u1ed5i
+confirm_update_system = B\u1ea1n c\u00f3 mu\u1ed1n c\u1eadp nh\u1eadt l\u1ea1i H\u1ec7 th\u1ed1ng b\u00e1o c\u00e1o?
+rename_failed = \u0110\u1ed5i t\u00ean kh\u00f4ng th\u00e0nh c\u00f4ng
+template_status = T\u00ecnh tr\u1ea1ng t\u1eadp tin
length_filename_min5_max30 = \u0110\u1ed9 d\u00e0i c\u1ee7a t\u00ean t\u1eadp tin t\u1ed1i thi\u1ec3u l\u00e0 5 v\u00e0 t\u1ed1i \u0111a l\u00e0 30
use_only_letters_numbers_dot_only = Ch\u1ec9 nh\u1eadp K\u00fd t\u1ef1, S\u1ed1 cho t\u00ean t\u1eadp tin v\u00e0 D\u1ea5u ch\u1ea5m(.) cho ph\u1ea7n \u0111u\u00f4i m\u1edf r\u1ed9ng
cell_exist = \u0110\u00e3 t\u1ed3n t\u1ea1i m\u1ed9t excel item c\u00f3 c\u00f9ng d\u00f2ng, c\u1ed9t v\u00e0 sheet.
-download = T\u1ea3i v\u1ec1
+update_successful = C\u1eadp nh\u1eadt th\u00e0nh c\u00f4ng !
+download = T\u1ea3i v\u1ec1
\ No newline at end of file
=== 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 2010-02-24 07:28:03 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2010-02-24 08:56:35 +0000
@@ -1258,6 +1258,26 @@
<interceptor-ref name="fileUploadStack" />
</action>
+ <action name="renameExcelTemplate"
+ class="org.hisp.dhis.reportexcel.filemanager.action.RenameExcelTemplateAction">
+ <result name="success" type="velocity-xml">
+ /dhis-web-excel-reporting/responseSuccess.vm</result>
+ <result name="none" type="velocity-xml">
+ /dhis-web-excel-reporting/responseNone.vm</result>
+ <result name="error" type="velocity-xml">
+ /dhis-web-excel-reporting/responseError.vm</result>
+ <param name="requiredAuthorities">F_EXCEL_TEMPLATE_MANAGEMENT_RENAME</param>
+ </action>
+
+ <action name="updateReportExcelByTemplate"
+ class="org.hisp.dhis.reportexcel.filemanager.action.UpdateReportExcelByTemplateAction">
+ <result name="success" type="velocity-xml">
+ /dhis-web-excel-reporting/responseSuccess.vm</result>
+ <result name="error" type="velocity-xml">
+ /dhis-web-excel-reporting/responseError.vm</result>
+ <param name="requiredAuthorities">F_EXCEL_TEMPLATE_MANAGEMENT_RENAME</param>
+ </action>
+
<action name="downloadExcelTemplate"
class="org.hisp.dhis.reportexcel.filemanager.action.DownloadExcelTemplateFileAction">
<result name="success" type="chain">downloadFile</result>
=== 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-24 07:28:03 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm 2010-02-24 08:56:35 +0000
@@ -1,4 +1,5 @@
<h2>$i18n.getString('excel_template_management')</h2>
+
<form name="uploadForm" id="uploadForm" action="uploadExcelTemplate.action" onsubmit="return validateUploadExcelTemplate(document.getElementById('upload').value, 1);" method="post" enctype="multipart/form-data">
<table>
<tr>
@@ -19,22 +20,37 @@
</table>
</form>
+<table width=100%>
+ <tr>
+ <td>
+ $i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:300px"/>
+ </td>
+ <td>
+
+ </td>
+ <td align=right>
+ <input type="button" value="$i18n.getString( "cancel" )" onclick="window.location='administration.action'" style="width:100px"/>
+ </td>
+ </tr>
+</table>
+
<table width="100%" class="listTable">
<thead>
<tr>
<th>$i18n.getString('name')</th>
+ <th>$i18n.getString('template_status')</th>
<th width="110px">$i18n.getString('operations')</th>
</tr>
</thead>
<tbody id="list">
- #foreach($templateFile in $templateFiles)
- <tr id="tr${templateFile.name}">
- <td>$encoder.htmlEncode( $templateFile.name )</td>
+ #foreach($templateFileName in $mapTemplateFiles.keySet())
+ <tr #id="tr${templateFileName}" >
+ <td>$encoder.htmlEncode( $templateFileName )</td>
+ <td>$encoder.htmlEncode( $mapTemplateFiles.get($templateFileName) )</td>
<td align="left">
- <a href="javascript:deleteExcelTemplate('$templateFile.name');" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
- <a href="javascript:mode = 'edit'; openEditExcelTemplate( '$templateFile.name' );" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
- <a href="downloadExcelTemplate.action?fileName=$templateFile.name" title="$i18n.getString( 'download' )"><img src="images/download.png" alt="$i18n.getString( 'download' )"></a>
-
+ <a href="javascript:deleteExcelTemplate('$templateFileName');" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
+ <a href="javascript:mode = 'edit'; openEditExcelTemplate( '$templateFileName' );" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
+ <a href="downloadExcelTemplate.action?fileName=$templateFileName" title="$i18n.getString( 'download' )"><img src="images/download.png" alt="$i18n.getString( 'download' )"></a>
</td>
</tr>
#end
@@ -43,12 +59,12 @@
<div id="editExcelTemplateDiv" style="position:fixed;display:none;width:444px;z-index:11;background-color: white;border: medium solid silver;height:60px;padding:20px">
<div id="close" style="position:absolute;top:2px;right:2px;cursor: pointer;color:red;" onclick="hideById('editExcelTemplateDiv');deleteDivEffect();hideMessage();">[x]</div>
- <input type="hidden" value="" id="id"/>
+ <input type="text" value="" id="currentFileNameHidden"/>
<table>
<tr>
<td><label>$i18n.getString('name')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td><input type="text" id="name" style="width:20em" name="T1" size="20" onkeyup="javascript: validateRenamingExcelTemplate(this.value ,1);"/></td>
- <td><input type="button" value="$i18n.getString('ok')" id="excelTemplateButtonRename" disabled="disabled" onClick="javascript: "/></td>
+ <td><input type="text" id="newName" style="width:20em" name="T1" size="20" onkeyup="javascript: validateRenamingExcelTemplate(this.value ,1);"/></td>
+ <td><input type="button" value="$i18n.getString('rename')" id="excelTemplateButtonRename" disabled="disabled" onclick="javascript: checkingStatusExcelTemplate(document.getElementById('newName').value, 1, 2);"/></td>
<td><input type="button" value="$i18n.getString('cancel')" onclick="hideById('editExcelTemplateDiv');deleteDivEffect();hideMessage();"/></td>
</tr>
</table>
@@ -58,20 +74,27 @@
<script language="javascript">
var mode = 'add';
- var i18n_file_exists = '$encoder.jsEscape($i18n.getString( 'file_exists' ) , "'")';
+ var i18n_confirm_rename = '$encoder.jsEscape($i18n.getString( 'confirm_rename' ) , "'")';
var i18n_confirm_delete = '$encoder.jsEscape($i18n.getString( 'confirm_delete' ) , "'")';
var i18n_confirm_override = '$encoder.jsEscape($i18n.getString( 'confirm_override' ) , "'")';
+ var i18n_confirm_update_system = '$encoder.jsEscape($i18n.getString( 'confirm_update_system' ) , "'")';
+ var i18n_file_exists = '$encoder.jsEscape($i18n.getString( 'file_exists' ) , "'")';
+ var i18n_file_used_system = '$encoder.jsEscape($i18n.getString( 'file_used_system' ) , "'")';
+ var i18n_rename_successful = '$encoder.jsEscape($i18n.getString( 'rename_successful' ) , "'")';
var i18n_filename_wellformed = '$encoder.jsEscape($i18n.getString( 'filename_wellformed' ) , "'")';
var i18n_length_filename_min5_max30 = '$encoder.jsEscape($i18n.getString( 'length_filename_min5_max30' ) , "'")';
var i18n_use_only_letters_numbers_dot_only = '$encoder.jsEscape($i18n.getString( 'use_only_letters_numbers_dot_only' ) , "'")';
+ var confirmRenamingMessage = i18n_file_used_system + '\n' + i18n_confirm_rename;
+ var confirmUpdateSysMessage = i18n_rename_successful + '\n' + i18n_confirm_update_system;
+
#if ( $message )
-
- $(document).ready( function() {
-
- setMessage( '<b>' + '$newFileUploaded' + '</b><br/>' + '$i18n.getString( "$message" )' );
- });
-
+ #if ( $newFileUploadedOrRenamed )
+ $(document).ready( function() {
+
+ setMessage( '<b>' + '$!newFileUploadedOrRenamed' + '</b><br/>' + '$i18n.getString( "$message" )' );
+ });
+ #end
#end
</script>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js 2010-02-04 09:13:45 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js 2010-02-24 08:56:35 +0000
@@ -6,7 +6,9 @@
// Regular Expression using for checking excel's file name
//----------------------------------------------------------
-regPattern = /^[^0-9\s\W][a-zA-Z0-9]{5,30}\.xl(?:sx|s)$/;
+//regPattern = /^[^0-9\s\W][a-zA-Z_. 0-9]{5,50}\.xl(?:sx|s)$/;
+// or :
+regPattern = /^[a-zA-Z][\w\s\d.]{5,50}\.xl(?:sx|s)$/;
/*
* Delete Excel Template
@@ -58,9 +60,11 @@
return true;
}
-function openEditExcelTemplate() {
-
+function openEditExcelTemplate( currentFileName ) {
+
+ byId("currentFileNameHidden").value = currentFileName;
$("#editExcelTemplateDiv").showAtCenter( true );
+
}
function validateRenamingExcelTemplate( fileName, columnIndex ) {
@@ -75,23 +79,25 @@
if ( value.toLowerCase() == fileName.toLowerCase() )
{
+ disable( "excelTemplateButtonRename" );
setMessage( i18n_file_exists );
- disable( "excelTemplateButtonRename" );
+ break;
}
else if ( applyingPatternForFileName( fileName ) == null )
{
+ disable( "excelTemplateButtonRename" );
setMessage
(
'<b>' + i18n_filename_wellformed + '</b><ul><li>'
+ i18n_length_filename_min5_max30 + '</li><li>'
+ i18n_use_only_letters_numbers_dot_only + '</li>'
);
- disable( "excelTemplateButtonRename" );
+ break;
}
else
{
+ enable( "excelTemplateButtonRename" );
hideMessage();
- enable( "excelTemplateButtonRename" );
}
}
}
@@ -99,4 +105,116 @@
function applyingPatternForFileName( fileName ) {
return fileName.match( regPattern );
-}
\ No newline at end of file
+}
+
+/**
+ param renamingMode::
+ 'RUS': Rename file name and update the system
+ 'RNUS': Rename file name but non-updating the system
+*/
+
+curTemplateName = '';
+newTemplateName = '';
+
+function checkingStatusExcelTemplate( newFileName, keyColumnIndex, statusColumnIndex ) {
+
+ var curFileName = getFieldValue( "currentFileNameHidden" );
+ var list = byId( 'list' );
+ var rows = list.getElementsByTagName( 'tr' );
+ var flagRename = false;
+
+ curTemplateName = curFileName;
+ newTemplateName = newFileName;
+
+ for ( var i = 0; i < rows.length; i++ )
+ {
+ var cell = rows[i].getElementsByTagName( 'td' )[keyColumnIndex-1];
+ var value = cell.firstChild.nodeValue;
+ cell = rows[i].getElementsByTagName( 'td' )[statusColumnIndex-1];
+ var statusFile = cell.firstChild.nodeValue;
+
+ if ( (value.toLowerCase() == curFileName.toLowerCase()) && (statusFile == "true") )
+ {
+ // File exists and being used
+ if ( window.confirm(confirmRenamingMessage) )
+ {
+ renamingExcelTemplate( curFileName, newFileName, "RUS" );
+ }
+ else
+ {
+ hideById('editExcelTemplateDiv');
+ deleteDivEffect();
+ }
+ return;
+ }
+ else
+ {
+ flagRename = true;
+ }
+ }
+
+ // File exists and pending
+ if ( flagRename )
+ {
+ renamingExcelTemplate( curFileName, newFileName, "RNUS" );
+ }
+
+}
+
+function renamingExcelTemplate( curFileName, newFileName, renamingMode ) {
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( renamingExcelTemplateReceived );
+ request.send( "renameExcelTemplate.action?newFileName=" + newFileName + "&curFileName=" + curFileName + "&renamingMode=" + renamingMode );
+
+}
+
+function renamingExcelTemplateReceived( xmlObject ) {
+
+ var type = xmlObject.getAttribute( 'type' );
+ var message = xmlObject.firstChild.nodeValue;
+
+ if ( type == "success" )
+ {
+ hideById('editExcelTemplateDiv');
+ deleteDivEffect();
+
+ if ( window.confirm( confirmUpdateSysMessage ) )
+ {
+ alert("update_system");
+ updateReportExcelByTemplate();
+ }
+ else
+ {
+ window.location.href="listAllExcelTemplates.action?message=" + message;
+ }
+ }
+ else if ( type == "none" )
+ {
+ window.location.href="listAllExcelTemplates.action?message=" + message;
+ }
+ else
+ {
+ setMessage( message );
+ }
+}
+
+function updateReportExcelByTemplate() {
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( updateReportExcelByTemplateCompleted );
+ request.send( "updateReportExcelByTemplate.action?curTemplateName=" + curTemplateName + "&newTemplateName=" + newTemplateName);
+}
+
+function updateReportExcelByTemplateCompleted( xmlObject ) {
+
+ var type = xmlObject.getAttribute( 'type' );
+
+ if ( type != "" )
+ {
+ var message = xmlObject.firstChild.nodeValue;
+ window.location.href="listAllExcelTemplates.action?message=" + message;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseNone.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseNone.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseNone.vm 2010-02-24 08:56:35 +0000
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<message type="none">$encoder.xmlEncode( $message )</message>
+
+