← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20247: Removed support for scientific notation in mathtils/analytics tables, does not play well with num...

 

------------------------------------------------------------
revno: 20247
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-21 11:01:11 +0200
message:
  Removed support for scientific notation in mathtils/analytics tables, does not play well with numeric database column types.
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java
  dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/MathUtilsTest.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-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java	2015-09-10 16:35:55 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/MathUtils.java	2015-09-21 09:01:11 +0000
@@ -56,8 +56,8 @@
     
     private static final double TOLERANCE = 0.01;
     
-    public static final String NUMERIC_REGEXP = "^(-?0|-?[1-9]\\d*)(\\.\\d+)?(E(-)?\\d+)?$";
-    public static final String NUMERIC_LENIENT_REGEXP = "^(-?[0-9]+)(\\.[0-9]+)?(E(-)?\\d+)?$";
+    public static final String NUMERIC_REGEXP = "^(-?0|-?[1-9]\\d*)(\\.\\d+)?$";
+    public static final String NUMERIC_LENIENT_REGEXP = "^(-?[0-9]+)(\\.[0-9]+)?$";
     
     private static final Pattern NUMERIC_PATTERN = Pattern.compile( NUMERIC_REGEXP );
     private static final Pattern NUMERIC_LENIENT_PATTERN = Pattern.compile( NUMERIC_LENIENT_REGEXP );

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/MathUtilsTest.java'
--- dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/MathUtilsTest.java	2015-04-29 10:29:05 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/test/java/org/hisp/dhis/system/util/MathUtilsTest.java	2015-09-21 09:01:11 +0000
@@ -115,9 +115,9 @@
         assertTrue( MathUtils.isNumeric( "-1234" ) );
         assertTrue( MathUtils.isNumeric( "-12.34" ) );
         assertTrue( MathUtils.isNumeric( "-0.34" ) );
-        assertTrue( MathUtils.isNumeric( "6.34E11" ) );
-        assertTrue( MathUtils.isNumeric( "3.342E7" ) );
-        assertTrue( MathUtils.isNumeric( "2.43E-7" ) );
+        assertTrue( MathUtils.isNumeric( "6.34" ) );
+        assertTrue( MathUtils.isNumeric( "3.34" ) );
+        assertTrue( MathUtils.isNumeric( "2.43" ) );
 
         assertFalse( MathUtils.isNumeric( "Hey" ) );
         assertFalse( MathUtils.isNumeric( "45 Perinatal Condition" ) );
@@ -160,9 +160,9 @@
         assertTrue( MathUtils.isNumericLenient( "-1234" ) );
         assertTrue( MathUtils.isNumericLenient( "-12.34" ) );
         assertTrue( MathUtils.isNumericLenient( "-0.34" ) );
-        assertTrue( MathUtils.isNumericLenient( "6.34E11" ) );
-        assertTrue( MathUtils.isNumericLenient( "3.342E7" ) );
-        assertTrue( MathUtils.isNumericLenient( "2.43E-7" ) );
+        assertTrue( MathUtils.isNumericLenient( "6.34" ) );
+        assertTrue( MathUtils.isNumericLenient( "3.342" ) );
+        assertTrue( MathUtils.isNumericLenient( "2.43" ) );
 
         assertFalse( MathUtils.isNumericLenient( "Hey" ) );
         assertFalse( MathUtils.isNumericLenient( "45 Perinatal Condition" ) );