dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #07630
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2198: fixed bugs: cannot create expression in category report excel
------------------------------------------------------------
revno: 2198
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Thu 2010-09-23 10:14:24 +0700
message:
fixed bugs: cannot create expression in category report excel
removed:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseDataElementOrder.vm
added:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/GetDataElementCategoryOptionCombosAction.java
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/ajax/jsonDataElementCategoryOptionCombos.vm
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/struts.xml
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/dataelementExpressionBuilderForm.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/item/action/GetDataElementCategoryOptionCombosAction.java'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/GetDataElementCategoryOptionCombosAction.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/java/org/hisp/dhis/reportexcel/item/action/GetDataElementCategoryOptionCombosAction.java 2010-09-23 03:14:24 +0000
@@ -0,0 +1,91 @@
+package org.hisp.dhis.reportexcel.item.action;
+
+/*
+ * Copyright (c) 2004-2010, 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.ArrayList;
+import java.util.List;
+
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
+import org.hisp.dhis.reportexcel.DataElementGroupOrder;
+import org.hisp.dhis.reportexcel.ReportExcelCategory;
+import org.hisp.dhis.reportexcel.ReportExcelService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Tran Thanh Tri
+ * @version $Id$
+ */
+public class GetDataElementCategoryOptionCombosAction
+ implements Action
+{
+ // -------------------------------------------------------------------------
+ // Dependencies
+ // -------------------------------------------------------------------------
+
+ private ReportExcelService reportService;
+
+ public void setReportService( ReportExcelService reportService )
+ {
+ this.reportService = reportService;
+ }
+
+ // -------------------------------------------------------------------------
+ // Output
+ // -------------------------------------------------------------------------
+
+ private Integer id;
+
+ public void setId( Integer id )
+ {
+ this.id = id;
+ }
+
+ public List<DataElementCategoryOptionCombo> dataElementCategoryOptionCombos;
+
+ public List<DataElementCategoryOptionCombo> getDataElementCategoryOptionCombos()
+ {
+ return dataElementCategoryOptionCombos;
+ }
+
+ @Override
+ public String execute()
+ throws Exception
+ {
+ ReportExcelCategory report = (ReportExcelCategory) reportService.getReportExcel( id );
+
+ DataElementGroupOrder dataElementGroupOrder = report.getDataElementOrders().iterator().next();
+
+ DataElement de = dataElementGroupOrder.getDataElements().iterator().next();
+
+ dataElementCategoryOptionCombos = new ArrayList<DataElementCategoryOptionCombo>( de.getCategoryCombo()
+ .getOptionCombos() );
+
+ 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 2010-09-22 07:30:22 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/META-INF/dhis/beans.xml 2010-09-23 03:14:24 +0000
@@ -350,6 +350,13 @@
scope="prototype">
<property name="reportService" ref="org.hisp.dhis.reportexcel.ReportExcelService" />
</bean>
+
+ <bean
+ id="org.hisp.dhis.reportexcel.item.action.GetDataElementCategoryOptionCombosAction"
+ class="org.hisp.dhis.reportexcel.item.action.GetDataElementCategoryOptionCombosAction"
+ scope="prototype">
+ <property name="reportService" ref="org.hisp.dhis.reportexcel.ReportExcelService" />
+ </bean>
<bean
id="org.hisp.dhis.reportexcel.item.action.ValidationReportExcelItemAction"
=== 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-09-22 07:30:22 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/resources/struts.xml 2010-09-23 03:14:24 +0000
@@ -132,7 +132,7 @@
<action name="getReportExcelGroups"
class="org.hisp.dhis.reportexcel.action.GetReportExcelGroupsAction">
- <result name="success" type="velocity">
+ <result name="success" type="velocity-xml">
/dhis-web-excel-reporting/report/ajax/responseReportGroups.vm
</result>
</action>
@@ -222,13 +222,7 @@
<result name="success" type="redirect">
listDataElementGroupOrder.action?id=${id}</result>
</action>
-
- <action name="getDataElementGroupOrder"
- class="org.hisp.dhis.reportexcel.category.action.GetDataElementGroupOrderAction">
- <result name="success" type="velocity-xml">
- /dhis-web-excel-reporting/responseDataElementOrder.vm</result>
- </action>
-
+
<action name="openSortDataElement"
class="org.hisp.dhis.reportexcel.category.action.GetDataElementGroupOrderAction">
<result name="success" type="velocity">/main.vm</result>
@@ -401,9 +395,13 @@
listReportExcelItemAction.action?reportId=${reportId}
</result>
<param name="requiredAuthorities">F_EXCEL_REPORT_ADMINISTRATION</param>
+ </action>
+
+ <action name="getDataElementCategoryOptionCombos"
+ class="org.hisp.dhis.reportexcel.item.action.GetDataElementCategoryOptionCombosAction">
+ <result name="success" type="velocity-json">/dhis-web-excel-reporting/report/ajax/jsonDataElementCategoryOptionCombos.vm</result>
</action>
-
<action name="deleteReportExcelItem"
class="org.hisp.dhis.reportexcel.item.action.DeleteReportExcelItemAction">
<result name="success" type="velocity-json">
=== added file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/ajax/jsonDataElementCategoryOptionCombos.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/ajax/jsonDataElementCategoryOptionCombos.vm 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/ajax/jsonDataElementCategoryOptionCombos.vm 2010-09-23 03:14:24 +0000
@@ -0,0 +1,9 @@
+#set( $size = $dataElementCategoryOptionCombos.size() )
+{ "dataElementCategoryOptionCombos": [
+#foreach( $de in $dataElementCategoryOptionCombos )
+ {
+ "id": $!{de.id},
+ "name": "$!encoder.jsEncode( ${de.name} )"
+ }#if( $velocityCount < $size ),#end
+#end
+] }
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/dataelementExpressionBuilderForm.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/dataelementExpressionBuilderForm.vm 2010-09-08 10:40:26 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/report/dataelementExpressionBuilderForm.vm 2010-09-23 03:14:24 +0000
@@ -5,8 +5,9 @@
deExpressionValidator = validation( 'dataelement-form', function(){
updateDeExpression();
});
-
+ #if(!$reportExcel.isCategory())
remoteValidate( jQuery( "#dataelement textarea[id=formula]"), '../dhis-web-commons-ajax-json/getExpressionText.action' );
+ #end
});
@@ -30,11 +31,14 @@
<a href="#" onclick="insertOperation( '+' )"><img src="images/plus.png" alt="$i18n.getString( 'plus' )"></a>
<a href="#" onclick="insertOperation( '-' )"><img src="images/minus.png" alt="$i18n.getString( 'minus' )"></a>
</td>
- <td>
+ <td>
+ #if(!$reportExcel.isCategory())
<select id="groupSelect" style="width:500px"onchange="getDataElements(this.value, '#dataelement select[id=elementSelect]')"></select>
+ #end
<select id="elementSelect" size="15" style="width:500px;" ondblclick="insertExpression()"></select>
</td>
</tr>
+ #if(!$reportExcel.isCategory())
<tr>
<th colspan="2">$i18n.getString( "description" )</th>
<tr>
@@ -43,6 +47,7 @@
<div id="expression-description" style="width:750px;height:30px;overflow:auto"></div>
</td>
</th>
+ #end
</table>
<br>
<br>
@@ -65,11 +70,18 @@
function deExpressionBuilderForm()
{
+ #if($reportExcel.isCategory())
+ getDataElementCategoryOptionCombos();
+ #else
loadDataElementGroups("#dataelement select[id=groupSelect]") ;
+ #end
setFieldValue( 'dataelement textarea[id=formula]', getFieldValue('expression') );
-
- showPopupWindowById( 'dataelement', 800, 400 );
+ #if(!$reportExcel.isCategory())
+ showPopupWindowById( 'dataelement', 800, 400 );
+ #else
+ showPopupWindowById( 'dataelement', 800, 320 );
+ #end
}
function getDataElements( id, target )
@@ -86,5 +98,19 @@
loadCategoryOptionComboByDE( id, targetId );
}
+ function getDataElementCategoryOptionCombos()
+ {
+ jQuery.postJSON('getDataElementCategoryOptionCombos.action'
+ , {id:$reportExcel.id}
+ , function( json ){
+ var select = jQuery("#dataelement select[id=elementSelect]");
+ select.empty();
+ jQuery.each( json.dataElementCategoryOptionCombos, function(i, item ){
+ select.append( "<option value='" + item.id + "'>" + item.name + "</option>" );
+ });
+
+ });
+ }
+
</script>
=== removed file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseDataElementOrder.vm'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseDataElementOrder.vm 2009-09-17 07:12:56 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/responseDataElementOrder.vm 1970-01-01 00:00:00 +0000
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<dataElementGroupOrder>
- <name>$dataElementGroupOrder.name</name>
- <code>$dataElementGroupOrder.code</code>
- <dataElements>
- #foreach( $dataElement in $dataElementGroupOrder.dataElements )
- <dataElement>
- <id>$dataElement.id</id>
- <name>$encoder.xmlEncode( $dataElement.name )</name>
- </dataElement>
- #end
- </dataElements>
-</dataElementGroupOrder>
\ No newline at end of file