dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04026
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1330: Data Element Zero value storage management
------------------------------------------------------------
revno: 1330
committer: Tran Thanh Tri <Tran Thanh Tri@compaq>
branch nick: trunk
timestamp: Mon 2010-01-25 14:24:27 +0700
message:
Data Element Zero value storage management
removed:
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/UpdateZeroIsSignificant4DataElementsAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java
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/datavalue/DefaultDataValueService.java
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/org/hisp/dhis/dataadmin/i18n_module.properties
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/javascript/zeroValueStorageManagement.js
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-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2010-01-22 03:15:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2010-01-25 07:24:27 +0000
@@ -400,7 +400,7 @@
* zeroIsSignificant property is true of false
* @param zeroIsSignificant is true or false
*/
- void setZeroIsSignificant4DataElements( Collection<Integer> dataElementIds, boolean zeroIsSignificant );
+ void setZeroIsSignificantForDataElements( Collection<Integer> dataElementIds, boolean zeroIsSignificant );
/**
* Returns all DataElement which zeroIsSignificant property is true or false
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java 2010-01-22 03:15:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementStore.java 2010-01-25 07:24:27 +0000
@@ -196,7 +196,7 @@
* zeroIsSignificant property is true of false
* @param zeroIsSignificant is true or false
*/
- void setZeroIsSignificant4DataElements( Collection<Integer> dataElementIds, boolean zeroIsSignificant );
+ void setZeroIsSignificantForDataElements( Collection<Integer> dataElementIds, boolean zeroIsSignificant );
/**
* Returns all DataElement which zeroIsSignificant property is true or false
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2009-12-23 07:35:17 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2010-01-25 07:24:27 +0000
@@ -50,6 +50,7 @@
{
public static final String TRUE = "true";
public static final String FALSE = "false";
+ public static final String ZERO = "0";
/**
* Part of the DataValue's composite ID
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2010-01-22 03:15:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2010-01-25 07:24:27 +0000
@@ -174,9 +174,12 @@
} );
}
- public void setZeroIsSignificant4DataElements( Collection<Integer> dataElementIds, boolean zeroIsSignificant )
+ public void setZeroIsSignificantForDataElements( Collection<Integer> dataElementIds, boolean zeroIsSignificant )
{
- dataElementStore.setZeroIsSignificant4DataElements( dataElementIds, zeroIsSignificant );
+ if ( !dataElementIds.isEmpty() )
+ {
+ dataElementStore.setZeroIsSignificantForDataElements( dataElementIds, zeroIsSignificant );
+ }
}
public Collection<DataElement> getDataElementsByZeroIsSignificant( boolean zeroIsSignificant )
@@ -188,9 +191,9 @@
DataElementGroup dataElementGroup )
{
Collection<DataElement> dataElements = getDataElementsByZeroIsSignificant( zeroIsSignificant );
-
+
dataElements.retainAll( dataElementGroup.getMembers() );
-
+
return dataElements;
}
=== 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-01-22 03:15:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/hibernate/HibernateDataElementStore.java 2010-01-25 07:24:27 +0000
@@ -238,24 +238,22 @@
return query.list();
}
- public void setZeroIsSignificant4DataElements( Collection<Integer> dataElementIds, boolean zeroIsSignificant )
+ public void setZeroIsSignificantForDataElements( Collection<Integer> dataElementIds, boolean zeroIsSignificant )
{
- for ( Integer id : dataElementIds )
- {
- String sql = "update DataElement d set d.zeroIsSignificant=:zeroIsSignificant where d.id=:id";
-
- Query query = sessionFactory.getCurrentSession().createQuery( sql );
-
- query.setParameter( "zeroIsSignificant", zeroIsSignificant );
-
- query.setParameter( "id", id );
-
- query.executeUpdate();
-
- }
+
+ String sql = "update DataElement d set d.zeroIsSignificant=:zeroIsSignificant where d.id in (:ids)";
+
+ Query query = sessionFactory.getCurrentSession().createQuery( sql );
+
+ query.setParameter( "zeroIsSignificant", zeroIsSignificant );
+
+ query.setParameterList( "ids", dataElementIds );
+
+ query.executeUpdate();
+
}
-
- @SuppressWarnings("unchecked")
+
+ @SuppressWarnings( "unchecked" )
public Collection<DataElement> getDataElementsByZeroIsSignificant( boolean zeroIsSignificant )
{
Session session = sessionFactory.getCurrentSession();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2009-12-24 14:47:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2010-01-25 07:24:27 +0000
@@ -29,6 +29,8 @@
import java.util.Collection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.period.Period;
@@ -44,6 +46,8 @@
public class DefaultDataValueService
implements DataValueService
{
+ private static final Log LOG = LogFactory.getLog( DefaultDataValueService.class );
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -61,22 +65,76 @@
public void addDataValue( DataValue dataValue )
{
- if ( !( dataValue.getValue() == null && dataValue.getComment() == null ) )
+
+ if ( !(dataValue.getValue() == null && dataValue.getComment() == null) )
{
- dataValueStore.addDataValue( dataValue );
+ if ( isZero( dataValue ) )
+ {
+ if ( dataValue.getDataElement().isZeroIsSignificant() )
+ {
+ int value = Integer.parseInt( dataValue.getValue() );
+
+ dataValue.setValue( String.valueOf( value ) );
+
+ dataValueStore.addDataValue( dataValue );
+
+ LOG.info( "Allow save zero value" );
+ }
+ }
+ else
+ {
+ dataValueStore.addDataValue( dataValue );
+ }
+
}
}
public void updateDataValue( DataValue dataValue )
{
+
if ( dataValue.getValue() == null && dataValue.getComment() == null )
{
dataValueStore.deleteDataValue( dataValue );
}
else
{
- dataValueStore.updateDataValue( dataValue );
- }
+ if ( isZero( dataValue ) )
+ {
+ if ( dataValue.getDataElement().isZeroIsSignificant() )
+ {
+ int value = Integer.parseInt( dataValue.getValue() );
+
+ dataValue.setValue( String.valueOf( value ) );
+
+ dataValueStore.updateDataValue( dataValue );
+
+ LOG.info( "Allow save zero value" );
+ }
+ }
+ else
+ {
+
+ dataValueStore.updateDataValue( dataValue );
+ }
+
+ }
+ }
+
+ private boolean isZero( DataValue dataValue )
+ {
+ if ( !dataValue.getDataElement().getType().equalsIgnoreCase( DataElement.VALUE_TYPE_INT ) )
+ {
+ return false;
+ }
+
+ Double value = Double.parseDouble( dataValue.getValue() );
+
+ if ( value.equals( Double.parseDouble( DataValue.ZERO ) ) )
+ {
+ return true;
+ }
+
+ return false;
}
public void deleteDataValue( DataValue dataValue )
@@ -104,7 +162,7 @@
{
return dataValueStore.getValue( dataElementId, periodId, sourceId, categoryOptionComboId );
}
-
+
// -------------------------------------------------------------------------
// Collections of DataValues
// -------------------------------------------------------------------------
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/UpdateZeroIsSignificant4DataElementsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/UpdateZeroIsSignificant4DataElementsAction.java 2010-01-22 03:15:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/zerovaluestorage/UpdateZeroIsSignificant4DataElementsAction.java 1970-01-01 00:00:00 +0000
@@ -1,87 +0,0 @@
-package org.hisp.dhis.dataadmin.action.zerovaluestorage;
-
-/*
- * 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.List;
-
-import org.hisp.dhis.dataelement.DataElementService;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Tran Thanh Tri
- * @version $Id$
- */
-
-public class UpdateZeroIsSignificant4DataElementsAction
- implements Action
-{
-
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private DataElementService dataElementService;
-
- public void setDataElementService( DataElementService dataElementService )
- {
- this.dataElementService = dataElementService;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private List<Integer> ignoreZeroValueDataElements;
-
- public void setIgnoreZeroValueDataElements( List<Integer> ignoreZeroValueDataElements )
- {
- this.ignoreZeroValueDataElements = ignoreZeroValueDataElements;
- }
-
-
- private List<Integer> zeroDataValueElements;
-
- public void setZeroDataValueElements( List<Integer> zeroDataValueElements )
- {
- this.zeroDataValueElements = zeroDataValueElements;
- }
-
-
- @Override
- public String execute()
- throws Exception
- {
- dataElementService.setZeroIsSignificant4DataElements( ignoreZeroValueDataElements, false );
-
- dataElementService.setZeroIsSignificant4DataElements( zeroDataValueElements, true );
-
- 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-01-22 03:15:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2010-01-25 07:24:27 +0000
@@ -285,8 +285,8 @@
</bean>
<bean
- id="org.hisp.dhis.dataadmin.action.zerovaluestorage.UpdateZeroIsSignificant4DataElementsAction"
- class="org.hisp.dhis.dataadmin.action.zerovaluestorage.UpdateZeroIsSignificant4DataElementsAction"
+ id="org.hisp.dhis.dataadmin.action.zerovaluestorage.UpdateZeroIsSignificantForDataElementsAction"
+ class="org.hisp.dhis.dataadmin.action.zerovaluestorage.UpdateZeroIsSignificantForDataElementsAction"
scope="prototype">
<property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2010-01-22 03:15:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2010-01-25 07:24:27 +0000
@@ -138,8 +138,8 @@
invalid_validation_rule_left_side_expressions = Invalid validation rule left side expressions
invalid_validation_rule_right_side_expressions = Invalid validation rule right side expressions
category_structure = Category structure
-dataelement_zero_storage_management = DataElement Zero Value Storage Management
-intro_dataelement_zero_storage_management = DataElement Zero Value Storage Management
+dataelement_zero_storage_management = DataElement Zero Value Storage
+intro_dataelement_zero_storage_management = DataElement Zero Value Storage
ignore_zero_data_values = Ignore zero data values
store_zero_data_values = Store zero data values
all = Select/ALL
@@ -151,4 +151,6 @@
reset = Reset
confirm = Confirm
merging = Merging
+move_all = Move All
+move_selected = Move Selected
=== 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-01-22 03:15:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2010-01-25 07:24:27 +0000
@@ -320,8 +320,8 @@
/dhis-web-maintenance-dataadmin/responseDataElements.vm</result>
</action>
- <action name="updateZeroIsSignificant4DataElements"
- class="org.hisp.dhis.dataadmin.action.zerovaluestorage.UpdateZeroIsSignificant4DataElementsAction">
+ <action name="updateZeroIsSignificantForDataElements"
+ class="org.hisp.dhis.dataadmin.action.zerovaluestorage.UpdateZeroIsSignificantForDataElementsAction">
<result name="success" type="redirect">index.action</result>
</action>
=== modified 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-01-22 03:15:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/zeroValueStorageManagement.js 2010-01-25 07:24:27 +0000
@@ -80,6 +80,12 @@
filterSaveZeroValueDataElements();
}
+function moveAllLeftToRight()
+{
+ selectAllById('ignoreZeroValueDataElements');
+ moveLeftToRight();
+}
+
function moveRightToLeft()
{
var list = byId('zeroDataValueElements');
@@ -98,6 +104,12 @@
filterSaveZeroValueDataElements();
}
+function moveAllRightToLeft()
+{
+ selectAllById('zeroDataValueElements');
+ moveRightToLeft();
+}
+
function filterIgnoreZeroValueDataElements()
{
=== 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-01-22 03:15:07 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/zeroValueStorageManagement.vm 2010-01-25 07:24:27 +0000
@@ -1,6 +1,6 @@
<h3>$i18n.getString( "dataelement_zero_storage_management" )</h3>
<br>
-<form id="ZeroDataValueManagement" method="POST" action="updateZeroIsSignificant4DataElements.action">
+<form id="ZeroDataValueManagement" method="POST" action="updateZeroIsSignificantForDataElements.action">
<table>
<thead>
<tr>
@@ -20,14 +20,7 @@
</select>
</td>
<td></td>
- <td>
- <select onchange="getDataElementsByGroupSaveZeroValue(this.value)">
- <option>$i18n.getString( "all" )</option>
- #foreach( $dataElementGroup in $dataElementGroups )
- <option value='$dataElementGroup.id'>$encoder.jsEscape( $dataElementGroup.name, "'" )</option>
- #end
- </select>
- </td>
+ <td></td>
</tr>
<tr>
<td><input type="text" style="width:100%" id="filterIgnoreZeroValue" onkeyup="filterIgnoreZeroValueDataElements()"/></td>
@@ -41,8 +34,10 @@
</td>
<td style="text-align:center">
- <input type="button" value=">" title="$i18n.getString('move_selected')" onclick="moveLeftToRight()"><br>
- <input type="button" value="<" title="$i18n.getString('remove_selected')" onclick="moveRightToLeft()">
+ <input type="button" value=">>" title="$i18n.getString('move_all')" onclick="moveAllLeftToRight()" style="width:50px"/><br>
+ <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="moveAllRightToLeft()" style="width:50px"/>
</td>
<td>