← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 837: New function: Clean up temp directory for Report Excel module

 

------------------------------------------------------------
revno: 837
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2009-10-08 16:18:37 +0700
message:
  New function: Clean up temp directory for Report Excel module
added:
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/action/CleanUpReportExcelAction.java
modified:
  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/viewAdministrator.vm


--
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.
=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/action/CleanUpReportExcelAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/action/CleanUpReportExcelAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/action/CleanUpReportExcelAction.java	2009-10-08 09:18:37 +0000
@@ -0,0 +1,79 @@
+package org.hisp.dhis.reportexcel.action;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+import org.hisp.dhis.reportexcel.ReportLocationManager;
+import org.hisp.dhis.reportexcel.utils.FileUtils;
+
+/**
+ * @author Nguyen Tran Do Xuan Thuy
+ * @version $Id$
+ */
+
+public class CleanUpReportExcelAction
+    extends ActionSupport
+{
+
+    // -------------------------------------------
+    // Dependency
+    // -------------------------------------------
+
+    private ReportLocationManager reportLocationManager;
+
+    public void setReportLocationManager( ReportLocationManager reportLocationManager )
+    {
+        this.reportLocationManager = reportLocationManager;
+    }
+
+    // -------------------------------------------
+    // Action implementation
+    // -------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        File reportTempDir = reportLocationManager.getReportExcelTempDirectory();
+
+        List<File> listFile = FileUtils.getListFile( reportTempDir );
+        Iterator<File> iterFile = listFile.iterator();
+
+        while ( iterFile.hasNext() )
+        {
+            iterFile.next().delete();
+        }
+
+        message = i18n.getString( "cleanup_success" );
+
+        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-10-08 07:28:59 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml	2009-10-08 09:18:37 +0000
@@ -827,5 +827,13 @@
         <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
         <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
 	</bean>
+	
+	<!-- Clean up Report Excel module -->
+	<bean
+        id="org.hisp.dhis.reportexcel.action.CleanUpReportExcelAction"
+        class="org.hisp.dhis.reportexcel.action.CleanUpReportExcelAction"
+        scope="prototype">
+        <property name="reportLocationManager" ref="org.hisp.dhis.reportexcel.ReportLocationManager" />
+    </bean>
 
 </beans>

=== 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	2009-10-07 10:20:08 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties	2009-10-08 09:18:37 +0000
@@ -129,4 +129,6 @@
 select                      = [Select]
 working_in_progress			= Working in progress...
 sheet_of_excel_file         = Sheet of Excel file
-generate_report_by_orgunit_group    = Generate report by orgunit group
\ No newline at end of file
+generate_report_by_orgunit_group    = Generate report by orgunit group
+clean_up                    = Clean temporary directory
+cleanup_success             = Clean up successful
\ No newline at end of file

=== 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	2009-10-07 10:20:08 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties	2009-10-08 09:18:37 +0000
@@ -148,4 +148,5 @@
 sort_order_help				= D\u00f9ng chu\u1ed9t k\u00e9o m\u1ee5c mu\u1ed1n s\u1eafp x\u1ebfp t\u1edbi v\u1ecb tr\u00ed c\u1ea7n thi\u1ebft, sau \u0111\u00f3 ch\u1ecdn C\u1eadp nh\u1eadt th\u1ee9 t\u1ef1
 select                      = [Ch\u1ecdn]
 working_in_progress			= \u0110ang x\u1eed l\u00fd...
-sheet_of_excel_file         = Sheet trong file excel
\ No newline at end of file
+sheet_of_excel_file         = Sheet trong file excel
+cleanup_success             = \u0110\u00e3 x\u00f3a th\u01b0 m\u1ee5c t\u1ea1m
\ 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	2009-10-08 07:28:59 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml	2009-10-08 09:18:37 +0000
@@ -705,5 +705,11 @@
 				/dhis-web-excel-reporting/responseSuccess.vm</result>
 		</action>
 
+        <action name="cleanUpReportExcel"
+            class="org.hisp.dhis.reportexcel.action.CleanUpReportExcelAction">
+            <result name="success" type="velocity-xml">
+                /dhis-web-excel-reporting/responseSuccess.vm</result>
+        </action>
+
 	</package>
 </struts>

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/viewAdministrator.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/viewAdministrator.vm	2009-09-25 06:10:21 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/viewAdministrator.vm	2009-10-08 09:18:37 +0000
@@ -1,8 +1,10 @@
-<h3>$i18n.getString( "administration" )</h3>
+<span id="message" style="top:100px;right:5px;position:fixed;width:200px;z-index:10002" onclick="hideById(this.id);"></span>
+<h3>$i18n.getString( "administration" )</h3>
 <ul>
 	<li><a href="getConfiguration.action">$i18n.getString( "configuration" )&nbsp;</a></li>		
 	<li><a href="listReportExcel.action">$i18n.getString( "reports" )&nbsp;</a></li>		
-	<li><a href="listDataEntryStatus.action">$i18n.getString( "data_status" )&nbsp;</a></li>		
+	<li><a href="listDataEntryStatus.action">$i18n.getString( "data_status" )&nbsp;</a></li>
+	<li><a href="javascript: cleanUp();">$i18n.getString( "clean_up" )&nbsp;</a></li>		
 </ul>
 
 <script>
@@ -13,10 +15,10 @@
 		var request = new Request();
 		request.setResponseTypeXML( 'xmlObject' );
 		request.setCallbackSuccess( cleanUpCompleted );
-		request.send( 'cleanTempDirectory.action' );
+		request.send( 'cleanUpReportExcel.action' );
 	}
 	
 	function cleanUpCompleted( xmlObject ){	
-		alert("Clean up");
+		setMessage(xmlObject.firstChild.nodeValue);
 	}
 </script>
\ No newline at end of file