dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03910
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1302: Copy excel items to group - Excel reporting.
------------------------------------------------------------
revno: 1302
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Tue 2010-01-12 13:00:44 +0700
message:
Copy excel items to group - Excel reporting.
added:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/CopyExcelItemToGroupAction.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/excelitems.vm
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitems.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.
=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/CopyExcelItemToGroupAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/CopyExcelItemToGroupAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/excelitem/action/CopyExcelItemToGroupAction.java 2010-01-12 06:00:44 +0000
@@ -0,0 +1,132 @@
+package org.hisp.dhis.reportexcel.excelitem.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.util.Collection;
+
+import org.amplecode.quick.StatementManager;
+import org.hisp.dhis.reportexcel.action.ActionSupport;
+import org.hisp.dhis.reportexcel.excelitem.ExcelItem;
+import org.hisp.dhis.reportexcel.excelitem.ExcelItemGroup;
+import org.hisp.dhis.reportexcel.excelitem.ExcelItemService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Chau Thu Tran
+ * @version $Id$
+ */
+
+public class CopyExcelItemToGroupAction extends ActionSupport {
+ // -------------------------------------------
+ // Dependency
+ // -------------------------------------------
+
+ private ExcelItemService excelItemService;
+
+ private StatementManager statementManager;
+
+ // -------------------------------------------
+ // Input
+ // -------------------------------------------
+
+ private Integer sheetNo;
+
+ private Collection<String> itemIds;
+
+ private Integer excelItemGroupDestId;
+
+ // -------------------------------------------
+ // Getter & Setter
+ // -------------------------------------------
+
+ public void setStatementManager(StatementManager statementManager) {
+ this.statementManager = statementManager;
+ }
+
+ public void setItemIds(Collection<String> itemIds) {
+ this.itemIds = itemIds;
+ }
+
+ public Integer getSheetNo() {
+ return sheetNo;
+ }
+
+ public void setExcelItemGroupDestId(Integer excelItemGroupDestId) {
+ this.excelItemGroupDestId = excelItemGroupDestId;
+ }
+
+ public void setExcelItemService(ExcelItemService excelItemService) {
+ this.excelItemService = excelItemService;
+ }
+
+ public void setSheetNo(Integer sheetNo) {
+ this.sheetNo = sheetNo;
+ }
+
+ // -------------------------------------------
+ // Action implementation
+ // -------------------------------------------
+
+ public String execute() throws Exception {
+
+ statementManager.initialise();
+
+ ExcelItemGroup dest = excelItemService.getExcelItemGroup(excelItemGroupDestId);
+
+ for (String itemId : itemIds) {
+
+ ExcelItem item = excelItemService
+ .getExcelItem(Integer.parseInt(itemId));
+
+ ExcelItem excelItem = new ExcelItem();
+
+ excelItem.setName(item.getName());
+
+ excelItem.setRow(item.getRow());
+
+ excelItem.setColumn(item.getColumn());
+
+ excelItem.setExpression(item.getExpression());
+
+ excelItem.setSheetNo(sheetNo);
+
+ excelItem.setExcelItemGroup(dest);
+
+ excelItemService.addExcelItem(excelItem);
+
+ }
+
+ message = i18n.getString("success");
+
+ statementManager.destroy();
+
+ 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-12-18 09:27:51 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-01-12 06:00:44 +0000
@@ -1233,6 +1233,12 @@
scope="prototype">
<property name="reportService" ref="org.hisp.dhis.reportexcel.ReportExcelService" />
</bean>
-
+
+ <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="statementManager" ref="statementManager" />
+ </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-12-18 09:27:51 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module.properties 2010-01-12 06:00:44 +0000
@@ -179,4 +179,5 @@
available_dataelements = Available Data Elements
value_rounded = This value maybe have been rounded
level_and_orgunit_group = Level and Organisation Unit Group
-levels = Level
\ No newline at end of file
+levels = Level
+no_item = Don't have any items chosen
\ 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-12-17 02:15:50 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/org/hisp/dhis/reportexcel/i18n_module_vi_VN.properties 2010-01-12 06:00:44 +0000
@@ -177,4 +177,5 @@
list_of_excel_items = Danh s\u00e1ch c\u00e1c excel item
selected_dataelements = Ph\u1ea7n t\u1eed c\u00f3 s\u1eb5n
available_dataelements = Ph\u1ea7n t\u1eed \u0111\u01b0\u1ee3c ch\u1ecdn
-value_rounded = Gi\u00e1 tr\u1ecb n\u00e0y c\u00f3 th\u1ec3 \u0111\u00e3 \u0111\u01b0\u1ee3c l\u00e0m tr\u00f2n
\ No newline at end of file
+value_rounded = Gi\u00e1 tr\u1ecb n\u00e0y c\u00f3 th\u1ec3 \u0111\u00e3 \u0111\u01b0\u1ee3c l\u00e0m tr\u00f2n
+no_item = Kh\u00f4ng c\u00f3 ph\u1ea7n t\u1eed \u0111\u01b0\u1ee3c ch\u1ecdn
\ 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-12-18 09:27:51 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2010-01-12 06:00:44 +0000
@@ -418,6 +418,13 @@
/dhis-web-excel-reporting/responseSuccess.vm</result>
<param name="requiredAuthorities">F_EXCEL_REPORT_ADMINISTRATION</param>
</action>
+
+ <action name="copyExcelItemsToGroup"
+ class="org.hisp.dhis.reportexcel.excelitem.action.CopyExcelItemToGroupAction">
+ <result name="success" type="velocity-xml">
+ /dhis-web-excel-reporting/responseSuccess.vm</result>
+ <param name="requiredAuthorities">F_COPY_EXCEL_ITEM_ADMINISTRATION</param>
+ </action>
<action name="getListSheet"
class="org.hisp.dhis.reportexcel.item.action.GetListSheetAction">
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelitems.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelitems.vm 2009-12-16 03:37:57 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/excelitems.vm 2010-01-12 06:00:44 +0000
@@ -6,25 +6,27 @@
$i18n.getString( "filter_by_name" ): <input type="text" onkeyup="filterValues( this.value , 1)" style="width:300px"/>
</td>
<td align="right">
- <input type="button" onclick="mode='add'; openAddExcelItem()" value="$i18n.getString('add')" style="width:100px"/>
- <input type="button" onclick="window.location='listAllExcelItemGroup.action'" value="$i18n.getString('cancel')" style="width:100px"/>
+ <input type="button" onclick="mode='add'; openAddExcelItem()" value="$i18n.getString('add')" style="width:150px"/> <br>
+ <input type="button" onclick="copySelectedItemToGroup()" value="$i18n.getString('copy_selected_item_to')" style="width:150px"/><br>
+ <input type="button" onclick="window.location='listAllExcelItemGroup.action'" value="$i18n.getString('cancel')" style="width:150px"/>
</td>
</tr>
</table>
<table width="100%">
<tr>
+ <th><input type="checkbox" id="checkAll" name="checkAll"></th>
<th>$i18n.getString('name')</th>
<th>$i18n.getString('sheetNo')</th>
- <th>$i18n.getString('row')</th>
+ <th>$i18n.getString('row')</th>
<th>$i18n.getString('column')</th>
- <th>$i18n.getString('expression')</th>
-
+ <th>$i18n.getString('expression')</th>
<th width="70px">$i18n.getString('operations')</th>
</tr>
<tbody id="list">
#set( $mark = false )
#foreach($excelItem in $excelItems)
<tr #alternate( $mark )>
+ <td><input type="checkbox" id="excelItemChecked" name="excelItemChecked" value='$excelItem.id'></td>
<td>$encoder.htmlEncode( $excelItem.name )</td>
<td>$excelItem.sheetNo</td>
<td>$excelItem.row</td>
@@ -41,7 +43,9 @@
#set( $mark = true )
#end
#end
- </tbody>
+ <tr>
+ <td>
+ </tbody>
</table>
<script type="text/javascript">
@@ -133,25 +137,26 @@
dataElementGroups['$dataElementGroup.id'] = '$encoder.jsEscape( $dataElementGroup.name, "'" )';
#end
+ var no_item = '$encoder.jsEscape( $i18n.getString("no_item"), "'" )';
</script>
<div id="copyTo" style="position:fixed;display:none;width:450px;z-index:10001;background-color: white;border: medium solid silver;padding:20px;">
<div id="close" style="position:absolute;top:2px;right:2px;cursor: pointer;color:red;" onclick="hideById('copyTo'); deleteDivEffect();">[x]</div>
<table width="100%">
<tr>
- <td>$i18n.getString('reports')</td>
+ <td><label>$i18n.getString('reports')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td>
<select id="targetGroup" style="max-width:30em;min-width:30em;">
</select>
</td>
</tr>
<tr>
- <td>$i18n.getString('sheet_no')</td>
+ <td><label>$i18n.getString('sheet_no')<em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
<td><input id="targetSheetNo" type="text"/></td>
</tr>
</table>
<p align="center">
-<input type="button" value="$i18n.getString('ok')" onclick="saveCopyItems();"/>
+<input type="button" value="$i18n.getString('ok')" onclick="saveCopyExcelItemsToGroup();"/>
<input type="button" value="$i18n.getString('cancel')" onclick="hideById('copyTo'); deleteDivEffect();"/>
</p>
</div>
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitems.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitems.js 2009-12-16 03:37:57 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitems.js 2010-01-12 06:00:44 +0000
@@ -467,4 +467,86 @@
}
setMessage( warningMessages );
+}
+
+// -----------------------------------------------------------------------
+// SAVE COPY EXCEL ITEM TO GROUP
+// -----------------------------------------------------------------------
+
+function copySelectedItemToGroup(){
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( copySelectedItemToGroupReceived );
+ request.send( "getAllExcelItemGroup.action" );
+
+}
+
+function copySelectedItemToGroupReceived( xmlObject ) {
+
+ var reports = xmlObject.getElementsByTagName("excelitemgroup");
+ var selectList = document.getElementById("targetGroup");
+ var options = selectList.options;
+
+ options.length = 0;
+
+ for( var i = 0 ; i < reports.length ; i++ ) {
+
+ var id = reports[i].getElementsByTagName("id")[0].firstChild.nodeValue;
+ var name = reports[i].getElementsByTagName("name")[0].firstChild.nodeValue;
+ options.add(new Option(name,id), null);
+ }
+
+ $("#copyTo").showAtCenter( true );
+}
+
+// -----------------------------------------------------------------------
+// SAVE COPY EXCEL ITEM TO GROUP
+// -----------------------------------------------------------------------
+
+function saveCopyExcelItemsToGroup() {
+
+ var list = document.getElementsByName('excelItemChecked');
+
+ // If have also ReportItem(s) in Copying list
+ // do copy and prepare the message notes
+ if ( list.length > 0 ) {
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( saveCopyExcelItemsToGroupReceived );
+
+ var params = "excelItemGroupDestId=" + byId("targetGroup").value;
+ params += "&sheetNo=" + byId('targetSheetNo').value;
+
+ for (var i=0 ;i<list.length; i++)
+ {
+ if(list.item(i).checked){
+ params += "&itemIds=" + list.item(i).value;
+ }
+ }
+
+ request.sendAsPost(params);
+ request.send( "copyExcelItemsToGroup.action");
+ }
+ // If have no any ReportItem(s) will be copied
+ // and also have ReportItem(s) in Duplicating list
+ else {
+
+ setMessage( no_item );
+ }
+
+}
+
+function saveCopyExcelItemsToGroupReceived( data ) {
+
+ //var type = data.getAttribute("type");
+
+ //if ( type == "success" ) {
+ setMessage( data.firstChild.nodeValue );
+ //}
+
+ hideById("copyTo");
+ deleteDivEffect();
+
}
\ No newline at end of file