dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #07638
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2204: fixed bug: zero values storage and saving zero in system doesn't synchronyzing
------------------------------------------------------------
revno: 2204
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Thu 2010-09-23 14:35:25 +0700
message:
fixed bug: zero values storage and saving zero in system doesn't synchronyzing
removed:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/GetDataElementsByZeroIsSignificantAndGroupAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/zeroValueStorageManagement.js
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/zeroValueStorageManagement.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
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2010-09-20 08:49:55 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2010-09-23 07:35:25 +0000
@@ -249,11 +249,11 @@
public void setZeroIsSignificantForDataElements( Collection<Integer> dataElementIds )
{
- String sql = "update dataelement d set d.zeroissignificant=false";
+ String sql = "update dataelement set zeroissignificant=false";
statementManager.getHolder().executeUpdate( sql );
- sql = "update dataelement d set d.zeroissignificant=true where d.dataelementid in (" + TextUtils.getCommaDelimitedString( dataElementIds ) + ")";
+ sql = "update dataelement set zeroissignificant=true where dataelementid in (" + TextUtils.getCommaDelimitedString( dataElementIds ) + ")";
statementManager.getHolder().executeUpdate( sql );
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm 2010-05-27 11:06:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElements.vm 2010-09-23 07:35:25 +0000
@@ -8,7 +8,8 @@
"shortName": "$!encoder.jsEncode( ${dataElement.shortName} )",
"code": "$!encoder.jsEncode( ${dataElement.code} )",
"type": "$!{dataElement.type}",
- "aggregationOperator": "$!{dataElement.aggregationOperator}"
+ "aggregationOperator": "$!{dataElement.aggregationOperator}",
+ "zeroIsSignificant": "$!{dataElement.zeroIsSignificant}"
}#if( $velocityCount < $size ),#end
#end
] }
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/GetDataElementsByZeroIsSignificantAndGroupAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/GetDataElementsByZeroIsSignificantAndGroupAction.java 2010-08-27 12:08:17 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/GetDataElementsByZeroIsSignificantAndGroupAction.java 1970-01-01 00:00:00 +0000
@@ -1,110 +0,0 @@
-package org.hisp.dhis.dataadmin.action.zerovaluestorage;
-
-/*
- * 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.Collections;
-import java.util.List;
-
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementGroup;
-import org.hisp.dhis.dataelement.DataElementService;
-import org.hisp.dhis.dataelement.comparator.DataElementNameComparator;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Tran Thanh Tri
- * @version $Id$
- */
-
-public class GetDataElementsByZeroIsSignificantAndGroupAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private DataElementService dataElementService;
-
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private boolean saveZeroValue;
-
- public void setSaveZeroValue( boolean saveZeroValue )
- {
- this.saveZeroValue = saveZeroValue;
- }
-
- private Integer dataElementGroupId;
-
- public void setDataElementGroupId( Integer dataElementGroupId )
- {
- this.dataElementGroupId = dataElementGroupId;
- }
-
- // -------------------------------------------------------------------------
- // Output
- // -------------------------------------------------------------------------
-
- private List<DataElement> dataElements;
-
- public List<DataElement> getDataElements()
- {
- return dataElements;
- }
-
- @Override
- public String execute()
- throws Exception
- {
- if ( dataElementGroupId == null )
- {
- dataElements = new ArrayList<DataElement>( dataElementService
- .getDataElementsByZeroIsSignificant( saveZeroValue ) );
- }
- else
- {
- DataElementGroup dataElementGroup = dataElementService.getDataElementGroup( dataElementGroupId );
-
- dataElements = new ArrayList<DataElement>( dataElementService.getDataElementsByZeroIsSignificantAndGroup(
- saveZeroValue, dataElementGroup ) );
- }
-
- Collections.sort( dataElements, new DataElementNameComparator() );
-
- return SUCCESS;
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2010-09-21 12:42:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2010-09-23 07:35:25 +0000
@@ -174,14 +174,6 @@
</bean>
<!-- Data Element Zero Value Storage Management -->
-
- <bean
- id="org.hisp.dhis.dataadmin.action.zerovaluestorage.GetDataElementsByZeroIsSignificantAndGroupAction"
- class="org.hisp.dhis.dataadmin.action.zerovaluestorage.GetDataElementsByZeroIsSignificantAndGroupAction"
- scope="prototype">
- <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
- </bean>
-
<bean
id="org.hisp.dhis.dataadmin.action.zerovaluestorage.OpenDataElementsZeroIsSignificantManagerAction"
class="org.hisp.dhis.dataadmin.action.zerovaluestorage.OpenDataElementsZeroIsSignificantManagerAction"
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2010-09-21 12:42:34 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2010-09-23 07:35:25 +0000
@@ -241,16 +241,8 @@
<result name="success" type="velocity">/main.vm</result>
<param name="page">
/dhis-web-maintenance-dataadmin/zeroValueStorageManagement.vm</param>
- <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
- <param name="javascripts">
- javascript/zeroValueStorageManagement.js</param>
- </action>
-
- <action name="getDataElementsByZeroIsSignificantAndGroup"
- class="org.hisp.dhis.dataadmin.action.zerovaluestorage.GetDataElementsByZeroIsSignificantAndGroupAction">
- <result name="success" type="velocity-xml">
- /dhis-web-maintenance-dataadmin/responseDataElements.vm</result>
- </action>
+ <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param>
+ </action>
<action name="updateZeroIsSignificantForDataElements"
class="org.hisp.dhis.dataadmin.action.zerovaluestorage.UpdateZeroIsSignificantForDataElementsAction">
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/zeroValueStorageManagement.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/zeroValueStorageManagement.js 2010-09-20 08:49:55 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/zeroValueStorageManagement.js 1970-01-01 00:00:00 +0000
@@ -1,147 +0,0 @@
-function init()
-{
- var id;
- for ( id in ignoreZeroValueDataElements )
- {
- $("#ignoreZeroValueDataElements").append( $( "<option></option>" ).attr( "value",id ).text( ignoreZeroValueDataElements[id] )) ;
- }
-
- for ( id in zeroDataValueElements )
- {
- $("#zeroDataValueElements").append( $( "<option></option>" ).attr( "value",id ).text( zeroDataValueElements[id] )) ;
- }
-}
-
-function getDataElementsByGroupIgnoreZeroValue ( dataElementGroupId )
-{
- var request = new Request();
- request.setResponseTypeXML( 'dataElements' );
- request.setCallbackSuccess( getDataElementsByGroupIgnoreZeroValueCompleted );
- request.send( 'getDataElementsByZeroIsSignificantAndGroup.action?dataElementGroupId=' + dataElementGroupId +
- '&saveZeroValue=false' );
-}
-
-function getDataElementsByGroupIgnoreZeroValueCompleted( dataElements )
-{
- ignoreZeroValueDataElements = new Object();
- var dataElementTags = dataElements.getElementsByTagName( 'dataElement' );
- for(var i=0;i<dataElementTags.length;i++){
- var listDataElement = dataElementTags.item(i);
- var id = listDataElement.getElementsByTagName( 'id' )[0].firstChild.nodeValue;
- var name = listDataElement.getElementsByTagName( 'name' )[0].firstChild.nodeValue;
- ignoreZeroValueDataElements[id] = name;
- }
-
- filterIgnoreZeroValueDataElements();
-}
-
-function getDataElementsByGroupSaveZeroValue ( dataElementGroupId )
-{
- var request = new Request();
- request.setResponseTypeXML( 'dataElements' );
- request.setCallbackSuccess( getDataElementsByGroupSaveZeroValueCompleted );
- request.send( 'getDataElementsByZeroIsSignificantAndGroup.action?dataElementGroupId=' + dataElementGroupId +
- '&saveZeroValue=true' );
-}
-
-function getDataElementsByGroupSaveZeroValueCompleted( dataElements )
-{
- zeroDataValueElements = new Object();
- var dataElementTags = dataElements.getElementsByTagName( 'dataElement' );
- for(var i=0;i<dataElementTags.length;i++){
- var listDataElement = dataElementTags.item(i);
- var id = listDataElement.getElementsByTagName( 'id' )[0].firstChild.nodeValue;
- var name = listDataElement.getElementsByTagName( 'name' )[0].firstChild.nodeValue;
- zeroDataValueElements[id] = name;
- }
-
- filterSaveZeroValueDataElements();
-}
-
-function moveLeftToRight()
-{
- var list = byId('ignoreZeroValueDataElements');
-
- while ( list.selectedIndex != -1 )
- {
- var id = list.options[list.selectedIndex].value;
-
- list.options[list.selectedIndex].selected = false;
-
- zeroDataValueElements[id] = ignoreZeroValueDataElements[id];
-
- delete ignoreZeroValueDataElements[id];
- }
- filterIgnoreZeroValueDataElements();
- filterSaveZeroValueDataElements();
-}
-
-function moveAllLeftToRight()
-{
- selectAllById('ignoreZeroValueDataElements');
- moveLeftToRight();
-}
-
-function moveRightToLeft()
-{
- var list = byId('zeroDataValueElements');
-
- while ( list.selectedIndex != -1 )
- {
- var id = list.options[list.selectedIndex].value;
-
- list.options[list.selectedIndex].selected = false;
-
- ignoreZeroValueDataElements[id] = zeroDataValueElements[id];
-
- delete zeroDataValueElements[id];
- }
- filterIgnoreZeroValueDataElements();
- filterSaveZeroValueDataElements();
-}
-
-function moveAllRightToLeft()
-{
- selectAllById('zeroDataValueElements');
- moveRightToLeft();
-}
-
-function filterIgnoreZeroValueDataElements()
-{
-
- var filter = byId( 'filterIgnoreZeroValue' ).value;
- var list = byId('ignoreZeroValueDataElements');
- list.options.length = 0;
- for ( var id in ignoreZeroValueDataElements )
- {
- var value = ignoreZeroValueDataElements[id];
-
- if ( value.toLowerCase().indexOf( filter.toLowerCase() ) != -1 )
- {
- list.add( new Option( value, id ), null );
- }
- }
-}
-
-function filterSaveZeroValueDataElements()
-{
-
- var filter = byId( 'filterSaveZeroValue' ).value;
- var list = byId('zeroDataValueElements');
- list.options.length = 0;
- for ( var id in zeroDataValueElements )
- {
- var value = zeroDataValueElements[id];
-
- if ( value.toLowerCase().indexOf( filter.toLowerCase() ) != -1 )
- {
- list.add( new Option( value, id ), null );
- }
- }
-}
-
-function submitForm()
-{
- selectAllById('zeroDataValueElements');
- byId('ZeroDataValueManagement').submit();
-}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/zeroValueStorageManagement.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/zeroValueStorageManagement.vm 2010-09-21 06:16:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/zeroValueStorageManagement.vm 2010-09-23 07:35:25 +0000
@@ -1,7 +1,6 @@
-
<h3>$i18n.getString( "zero_storage_management" ) #openHelp( "zeroValueStorage" )</h3>
<br/>
-<form id="ZeroDataValueManagement" method="POST" action="updateZeroIsSignificantForDataElements.action">
+<form id="ZeroDataValueManagement" method="POST" action="updateZeroIsSignificantForDataElements.action" onsubmit="selectAllById( 'zeroDataValueElements' )">
<table>
<thead>
<tr>
@@ -13,10 +12,10 @@
<tbody>
<tr>
<td>
- <select onchange="getDataElementsByGroupIgnoreZeroValue(this.value)">
- <option>$i18n.getString( "all" )</option>
+ <select onchange="getSaveZeroDataElements(this.value)">
+ <option value="">$i18n.getString( "all" )</option>
#foreach( $dataElementGroup in $dataElementGroups )
- <option value='$dataElementGroup.id'>$encoder.jsEscape( $dataElementGroup.name, "'" )</option>
+ <option value='$dataElementGroup.id'>$encoder.htmlEncode( $dataElementGroup.name )</option>
#end
</select>
</td>
@@ -24,43 +23,56 @@
<td></td>
</tr>
<tr>
- <td><input type="text" style="width:100%" id="filterIgnoreZeroValue" onkeyup="filterIgnoreZeroValueDataElements()"/></td>
+ <td><input type="text" style="width:100%" id="filterIgnoreZeroValue" onkeyup="filterList( this.value, 'ignoreZeroValueDataElements')"/></td>
<td></td>
- <td><input type="text" style="width:100%" id="filterSaveZeroValue" onkeyup="filterSaveZeroValueDataElements()"/></td>
+ <td><input type="text" style="width:100%" id="filterSaveZeroValue" onkeyup="filterList( this.value, 'zeroDataValueElements')"/></td>
</tr>
<tr>
<td>
- <select id="ignoreZeroValueDataElements" name="ignoreZeroValueDataElements" size="10" multiple="multiple" style="min-width:25em; height:25em" ondblclick="moveLeftToRight()">
+ <select id="ignoreZeroValueDataElements" name="ignoreZeroValueDataElements" size="10" multiple="multiple" style="min-width:25em; height:25em" ondblclick="moveSelectedById('ignoreZeroValueDataElements', 'zeroDataValueElements')">
+ #foreach( $zero in $ignoreZeroValueDataElements )
+ <option value='$zero.id'>$encoder.htmlEncode( $zero.name )</option>
+ #end
</select>
</td>
<td style="text-align:center">
- <input type="button" value=">" title="$i18n.getString('move_selected')" onclick="moveLeftToRight()" style="width:50px"/><br/>
- <input type="button" value="<" title="$i18n.getString('move_selected')" onclick="moveRightToLeft()" style="width:50px"/><br/>
- <input type="button" value=">>" title="$i18n.getString('move_all')" onclick="moveAllLeftToRight()" style="width:50px"/><br/>
- <input type="button" value="<<" title="$i18n.getString('move_all')" onclick="moveAllRightToLeft()" style="width:50px"/>
+ <input type="button" value=">" title="$i18n.getString('move_selected')" onclick="moveSelectedById('ignoreZeroValueDataElements', 'zeroDataValueElements')" style="width:50px"/><br/>
+ <input type="button" value="<" title="$i18n.getString('move_selected')" onclick="moveSelectedById('zeroDataValueElements', 'ignoreZeroValueDataElements')" style="width:50px"/><br/>
+ <input type="button" value=">>" title="$i18n.getString('move_all')" onclick="moveAllById('ignoreZeroValueDataElements', 'zeroDataValueElements')" style="width:50px"/><br/>
+ <input type="button" value="<<" title="$i18n.getString('move_all')" onclick="moveAllById('zeroDataValueElements', 'ignoreZeroValueDataElements')" style="width:50px"/>
</td>
<td>
- <select id="zeroDataValueElements" name="zeroDataValueElements" size="10" multiple="multiple" style="min-width:25em; height:25em" ondblclick="moveRightToLeft()">
+ <select id="zeroDataValueElements" name="zeroDataValueElements" size="10" multiple="multiple" style="min-width:25em; height:25em" ondblclick="moveSelectedById('zeroDataValueElements', 'ignoreZeroValueDataElements')">
+ #foreach( $zero in $zeroDataValueElements )
+ <option value='$zero.id'>$encoder.htmlEncode( $zero.name )</option>
+ #end
</select>
</td>
</tr>
</tbody>
</table>
<p>
- <input type="button" value="$i18n.getString( 'save' )" onclick="submitForm()" style="width:100px"/><input
- type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='index.action'" style="width:100px"/>
+ <input type="submit" value="$i18n.getString( 'save' )" style="width:100px"/>
+ <input type="button" value="$i18n.getString( 'cancel' )" onclick="window.location.href='index.action'" style="width:100px"/>
</p>
</form>
<script>
- var ignoreZeroValueDataElements = new Object();
-#foreach( $dataElement in $ignoreZeroValueDataElements )
- ignoreZeroValueDataElements['$dataElement.id'] = '$encoder.jsEscape( $dataElement.name, "'" )';
-#end
- var zeroDataValueElements = new Object();
-#foreach( $dataElement in $zeroDataValueElements )
- zeroDataValueElements['$dataElement.id'] = '$encoder.jsEscape( $dataElement.name, "'" )';
-#end
- init();
+ function getSaveZeroDataElements( value )
+ {
+ jQuery.postJSON('../dhis-web-commons-ajax-json/getDataElements.action'
+ , {id: value },
+ function( json ){
+ var ignoreZeroValueDataElements = jQuery("#ignoreZeroValueDataElements");
+ ignoreZeroValueDataElements.empty();
+ jQuery.each( json.dataElements, function(i, item){
+ if( item.zeroIsSignificant == 'false' )
+ {
+ ignoreZeroValueDataElements.append( "<option value='" + item.id + "'>" + item.name + "</option>");
+ }
+ });
+ });
+ }
+
</script>
\ No newline at end of file