dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04050
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1342: Function Excel-File Management - Working in process
------------------------------------------------------------
revno: 1342
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-01-26 15:19:44 +0700
message:
Function Excel-File Management - Working in process
added:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/DeleteExcelTemplateAction.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js
modified:
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/resources/META-INF/dhis/beans.xml
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
--
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/filemanager/action/DeleteExcelTemplateAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/DeleteExcelTemplateAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/DeleteExcelTemplateAction.java 2010-01-26 08:19:44 +0000
@@ -0,0 +1,100 @@
+package org.hisp.dhis.reportexcel.filemanager.action;
+
+import java.io.File;
+import java.util.Collection;
+
+import org.hisp.dhis.i18n.I18n;
+import org.hisp.dhis.options.SystemSettingManager;
+import org.hisp.dhis.reportexcel.ReportExcel;
+import org.hisp.dhis.reportexcel.ReportExcelService;
+import org.hisp.dhis.reportexcel.utils.FileUtils;
+
+import com.opensymphony.xwork2.Action;
+
+public class DeleteExcelTemplateAction
+ implements Action
+{
+ // -------------------------------------------
+ // Dependency
+ // -------------------------------------------
+
+ private SystemSettingManager systemSettingManager;
+
+ private ReportExcelService reportService;
+
+ // -------------------------------------------
+ // Input
+ // -------------------------------------------
+
+ private String fileName;
+
+ // -------------------------------------------
+ // Output
+ // -------------------------------------------
+
+ private String message;
+
+ private I18n i18n;
+
+ // -------------------------------------------
+ // Getter && Setter
+ // -------------------------------------------
+
+ public void setSystemSettingManager( SystemSettingManager systemSettingManager )
+ {
+ this.systemSettingManager = systemSettingManager;
+ }
+
+ public void setReportService( ReportExcelService reportService )
+ {
+ this.reportService = reportService;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public void setI18n( I18n i18n )
+ {
+ this.i18n = i18n;
+ }
+
+ public void setFileName( String fileName )
+ {
+ this.fileName = fileName;
+ }
+
+ // -------------------------------------------
+ // Action implementation
+ // -------------------------------------------
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ message = "";
+
+ Collection<ReportExcel> reports = reportService.getALLReportExcel();
+ for(ReportExcel report : reports){
+ String name = report.getExcelTemplateFile();
+ if(name.equals( fileName )){
+ message += " - " + report.getName() + "<br>";
+ }
+ }
+
+ if(message.length()>0){
+ message = i18n.getString( "report_user_template" ) + "<br>" + message;
+ return ERROR;
+ }
+
+ String templateDirectory = (String) systemSettingManager
+ .getSystemSetting( SystemSettingManager.KEY_REPORT_TEMPLATE_DIRECTORY );
+
+ System.out.println("\n\n\n === File : " + templateDirectory + File.separator + fileName);
+ FileUtils.delete( templateDirectory + File.separator + fileName );
+
+ return SUCCESS;
+ }
+
+}
=== 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-01-26 07:04:17 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/filemanager/action/ExcelTemplateListAction.java 2010-01-26 08:19:44 +0000
@@ -23,7 +23,7 @@
private Collection<File> templateFiles;
// -------------------------------------------
- // Getter
+ // Getter && Setter
// -------------------------------------------
public Collection<File> getTemplateFiles()
=== 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-01-26 07:15:52 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-01-26 08:19:44 +0000
@@ -447,7 +447,7 @@
<property name="initPOIStylesManager"
ref="org.hisp.dhis.reportexcel.preview.manager.InitializePOIStylesManager" />
<property name="organisationUnitService"
- ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
</bean>
<bean
@@ -1233,18 +1233,29 @@
scope="prototype">
<property name="reportService" ref="org.hisp.dhis.reportexcel.ReportExcelService" />
</bean>
-
- <bean id="org.hisp.dhis.reportexcel.excelitem.action.CopyExcelItemToGroupAction"
+
+ <bean
+ id="org.hisp.dhis.reportexcel.excelitem.action.CopyExcelItemToGroupAction"
class="org.hisp.dhis.reportexcel.excelitem.action.CopyExcelItemToGroupAction"
scope="prototype">
- <property name="excelItemService" ref="org.hisp.dhis.reportexcel.excelitem.ExcelItemService" />
+ <property name="excelItemService"
+ ref="org.hisp.dhis.reportexcel.excelitem.ExcelItemService" />
<property name="statementManager" ref="statementManager" />
</bean>
-
- <bean id="org.hisp.dhis.reportexcel.filemanager.action.ExcelTemplateListAction"
+
+ <bean
+ id="org.hisp.dhis.reportexcel.filemanager.action.ExcelTemplateListAction"
class="org.hisp.dhis.reportexcel.filemanager.action.ExcelTemplateListAction"
scope="prototype">
<property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager" />
</bean>
+ <bean
+ id="org.hisp.dhis.reportexcel.filemanager.action.DeleteExcelTemplateAction"
+ class="org.hisp.dhis.reportexcel.filemanager.action.DeleteExcelTemplateAction"
+ scope="prototype">
+ <property name="systemSettingManager" ref="org.hisp.dhis.options.SystemSettingManager" />
+ <property name="reportService" ref="org.hisp.dhis.reportexcel.ReportExcelService" />
+ </bean>
+
</beans>
=== 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-01-26 07:15:52 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2010-01-26 08:19:44 +0000
@@ -1212,7 +1212,8 @@
</result>
</action>
- <!-- Period Column -->
+ <!-- File management -->
+
<action name="excelTemplateList"
class="org.hisp.dhis.reportexcel.filemanager.action.ExcelTemplateListAction">
<result name="success" type="velocity">/main.vm</result>
@@ -1221,5 +1222,14 @@
<param name="javascripts">javascript/commons.js,javascript/exceltemplate.js</param>
</action>
+ <action name="deleteExcelTemplate"
+ class="org.hisp.dhis.reportexcel.filemanager.action.DeleteExcelTemplateAction">
+ <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>
+ </action>
+
+
</package>
</struts>
=== 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-01-26 07:15:52 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelTemplateList.vm 2010-01-26 08:19:44 +0000
@@ -24,22 +24,7 @@
<td align="left">
<a href="openExcelItemGroupAssociations.action?excelItemGroupId=$excelItemGroup.id" title="$i18n.getString( 'associations' )"><img src="../images/assign.png" alt="$i18n.getString( 'associations' )"></a>
<a href="listExcelItems.action?excelItemGroupId=$excelItemGroup.id" title="$i18n.getString( 'excel_item' )"><img src="../images/add_section.png" alt="$i18n.getString( 'excelitem' )"></a>
- <a href="javascript:deleteExcelItemGroup('$excelItemGroup.id');" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
- <a href="javascript:mode = 'edit'; openUpdateExcelItemGroup( '$excelItemGroup.id' );" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"></a>
- #if($excelItemGroup.isOrganisationUnitGroupListing())
- <a href="openUpdateOrgnisationUnitGroupForExcelItemGroup.action?id=$excelItemGroup.id" title="$i18n.getString( 'organisation_unit_group' )"><img src="images/group_1.jpg"/></a>
- #end
- #if($excelItemGroup.isCategory())
- <a href="listDataElementGroupOrderForExcelItemGroup.action?id=$excelItemGroup.id" title="$i18n.getString( 'dataelement_groups' )"><img src="images/group.jpg"/></a>
- #end
- <!-- #if($report.isOrganisationUnitGroupListing())
- <a href="openUpdateOrgnisationUnitGroupListingReport.action?id=$report.id" title="$i18n.getString( 'organisation_unit_group' )"><img src="images/group_1.jpg"/></a>
- #end
- #if($report.isCategory())
- <a href="listDataElementGroupOrder.action?id=$report.id" title="$i18n.getString( 'dataelement_groups' )"><img src="images/group.jpg"/></a>
-
- #end-->
-
+ <a href="javascript: deleteExcelTemplate('$templateFile.name');" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"></a>
</td>
</tr>
@@ -52,46 +37,8 @@
</tbody>
</table>
-<div id="divExcelitemGroup" style="position:fixed;display:none;width:400px;z-index:11;background-color: white;border: medium solid silver;height:100px;padding:20px;">
- <div id="close" style="position:absolute;top:2px;right:2px;cursor: pointer;color:red;" onclick="hideById('divExcelitemGroup');deleteDivEffect();">[x]</div>
- <input type="hidden" value="" id="id"/>
- <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"/></td>
- </tr>
- <tr>
- <td><label>$i18n.getString('report_type')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td>
- <select type="text" id="type" name="type" style="min-width:20em">
- <option value='NORMAL'>$i18n.getString('NORMAL')</option>
- <option value='CATEGORY'>$i18n.getString('CATEGORY')</option>
- <!-- <option value='PERIOD_COLUMN_LISTING'>$i18n.getString('PERIOD_COLUMN_LISTING')</option> -->
- <option value='ORGANIZATION_GROUP_LISTING'>$i18n.getString('ORGANIZATION_GROUP_LISTING')</option>
- </select>
- </td>
- </tr>
- <tr>
- <td><label>$i18n.getString('periodType')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
- <td>
- <select type="text" id="periodType" name="periodType" style="min-width:20em">
- #foreach ( $periodType in $periodTypes )
- <option value="$periodType.name" #if( $excelitemGroup.periodType.name.equals( $periodType.name ) ) selected="selected" #end>$i18n.getString( $periodType.name )</option>
- #end
- </select>
- </td>
- </tr>
-
- </table>
- <p align="center">
- <input type="button" value="$i18n.getString('ok')" id="excelitemGroupAddUpdateButton" onClick="validateExcelItemGroup()"/>
- <input type="button" value="$i18n.getString('cancel')" onclick="hideById('divExcelitemGroup');deleteDivEffect();"/>
- </p>
-</div>
<script language="javascript">
- var mode = 'add';
var i18n_confirm_delete = '$encoder.jsEscape($i18n.getString( 'confirm_delete' ) , "'")';
-
</script>
<span id="message" style="top:100px;right:5px;position:fixed;width:200px;z-index:10002" onclick="javascript:hideById(this.id);"></span>
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/exceltemplate.js 2010-01-26 08:19:44 +0000
@@ -0,0 +1,29 @@
+// ========================================================================================================================
+// EXCEL TEMPLATE MANAGER
+// ========================================================================================================================
+
+/*
+* Delete Excel Template
+*/
+function deleteExcelTemplate( fileName ) {
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( deleteExcelTemplateReceived );
+ request.send( "deleteExcelTemplate.action?fileName=" + fileName );
+
+}
+
+function deleteExcelTemplateReceived( xmlObject ) {
+
+ var type = xmlObject.getAttribute( 'type' );
+
+ if ( type == 'error' )
+ {
+ setMessage(xmlObject.firstChild.nodeValue);
+ }
+ else
+ {
+ window.location.href = 'excelTemplateList.action';
+ }
+}
\ No newline at end of file