← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4823: fixed bug #866032; made saving datavalues in dataentry a bit more safe, also removed old datavalu...

 

------------------------------------------------------------
revno: 4823
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-10-04 13:18:18 +0200
message:
  fixed bug #866032; made saving datavalues in dataentry a bit more safe, also removed old datavalue if value is now empty (mobile)
modified:
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java
  dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java


--
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-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java	2011-09-30 11:13:16 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/action/SaveSectionFormAction.java	2011-10-04 11:18:18 +0000
@@ -272,16 +272,23 @@
 
                 value = value.trim();
 
+                if ( value == null || value.length() == 0 || !SectionFormUtils.isInteger( value ) )
+                {
+                    if ( dataValue != null )
+                    {
+                        dataValueService.deleteDataValue( dataValue );
+                    }
+
+                    continue;
+                }
+
                 if ( dataValue == null )
                 {
-                    if ( value != null && value.length() > 0 )
-                    {
-                        needsValidation = true;
+                    needsValidation = true;
 
-                        dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, new Date(),
-                            null, optionCombo );
-                        dataValueService.addDataValue( dataValue );
-                    }
+                    dataValue = new DataValue( dataElement, period, organisationUnit, value, storedBy, new Date(),
+                        null, optionCombo );
+                    dataValueService.addDataValue( dataValue );
                 }
                 else
                 {

=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java	2011-09-30 11:13:16 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/SectionFormUtils.java	2011-10-04 11:18:18 +0000
@@ -209,6 +209,20 @@
     // Static Utils
     // -------------------------------------------------------------------------
 
+    public static boolean isInteger( String value )
+    {
+        try
+        {
+            Integer.parseInt( value );
+        }
+        catch ( NumberFormatException e )
+        {
+            return false;
+        }
+
+        return true;
+    }
+
     public static boolean valueHigher( String value, int max )
     {
         int integerValue;