revision-diff.txt (646 Bytes)
···
================================
Tran Thanh Tri
HISP Viet Nam
Cell phone: +84903670967
Website: http://tringuyenvn.com
================================
2010/1/25 noreply@launchpad.net
revno: 1337
committer: Lars Helge Oeverland larshelge@gmail.com
branch nick: trunk
timestamp: Mon 2010-01-25 15:30:51 +0100
message:
Improved DataValue.isZero
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.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-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java’
— dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2010-01-25 14:08:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2010-01-25 14:30:51 +0000
@@ -198,7 +198,7 @@
public boolean isZero() { return dataElement != null && dataElement.getType().equals( DataElement.VALUE_TYPE_INT )
&& value != null && ( value.equals( "0" ) || value.startsWith( "0." ) );
This script will not working fine. new Double(“0.001”).intValue()==0 is true but it must be false.
I thing it must be new Double(value)==(new Double(0))
what do you thing ?
&& value != null && new Double( value ).intValue() == 0;
}
public boolean isNullValue()
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help : https://help.launchpad.net/ListHelp
I don’t think we should allow decimal numbers in the first place, eg it cant be 0.5 people with malaria or vaccines given. But Jason pointed out that regex might be the better solution for this in any case. Feel free to improve, I don’t have strong opinions on this.
···
2010/1/26 Trí Trần Thanh tranthanhtri84@gmail.com
================================
Tran Thanh Tri
HISP Viet Nam
Cell phone: +84903670967
Website: http://tringuyenvn.com================================
2010/1/25 noreply@launchpad.net
revno: 1337
committer: Lars Helge Oeverland larshelge@gmail.com
branch nick: trunk
timestamp: Mon 2010-01-25 15:30:51 +0100
message:
Improved DataValue.isZero
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.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-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java’
— dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2010-01-25 14:08:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2010-01-25 14:30:51 +0000
@@ -198,7 +198,7 @@
public boolean isZero() { return dataElement != null && dataElement.getType().equals( DataElement.VALUE_TYPE_INT )
&& value != null && ( value.equals( "0" ) || value.startsWith( "0." ) );
This script will not working fine. new Double(“0.001”).intValue()==0 is true but it must be false.
I thing it must be new Double(value)==(new Double(0))
what do you thing ?
&& value != null && new Double( value ).i
================================
Tran Thanh Tri
HISP Viet Nam
Cell phone: +84903670967
Website: http://tringuyenvn.com================================
revno: 1337
committer: Lars Helge Oeverland larshelge@gmail.com
branch nick: trunk
timestamp: Mon 2010-01-25 15:30:51 +0100
message:
Improved DataValue.isZero
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.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-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java’
— dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2010-01-25 14:08:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java 2010-01-25 14:30:51 +0000
@@ -198,7 +198,7 @@
public boolean isZero() { return dataElement != null && dataElement.getType().equals( DataElement.VALUE_TYPE_INT )
&& value != null && ( value.equals( "0" ) || value.startsWith( "0." ) );
This script will not working fine. new Double(“0.001”).intValue()==0 is true but it must be false.
I thing it must be new Double(value)==(new Double(0))
what do you thing ?
&& value != null && new Double( value ).i
I don’t think we should allow decimal numbers in the first place, eg it cant be 0.5 people with malaria or vaccines given. But Jason pointed out that regex might be the better solution for this in any case.
Maybe something like
^[0][.]?[0]$
Start word. Read any number of zeroes followed optionally by a ‘.’ followed by any number of zeroes. End word.
0 M
003
0.00 M
0.03
.000 M
00.0 M
008000
Cheers
Bob
···
2010/1/26 Lars Helge Øverland larshelge@gmail.com
2010/1/26 Trí Trần Thanh tranthanhtri84@gmail.com
2010/1/25 noreply@launchpad.net
From my emacs buffer, M indicates a match
Feel free to improve, I don’t have strong opinions on this.
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help : https://help.launchpad.net/ListHelp
Hi all, my way is easy and simple. Cast to Double and compare with new
Double(0). new Double(value).equal(new Double(0)) ? how do you think?
···
On 1/26/10, Bob Jolliffe <bobjolliffe@gmail.com> wrote:
2010/1/26 Lars Helge Øverland <larshelge@gmail.com>
2010/1/26 Trí Trần Thanh <tranthanhtri84@gmail.com>
================================
Tran Thanh Tri
HISP Viet Nam
Cell phone: +84903670967
Website: http://tringuyenvn.com2010/1/25 <noreply@launchpad.net>
------------------------------------------------------------
revno: 1337
committer: Lars Helge Oeverland <larshelge@gmail.com>
branch nick: trunk
timestamp: Mon 2010-01-25 15:30:51 +0100
message:
Improved DataValue.isZero
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk<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<https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription>
.=== 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
2010-01-25 14:08:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
2010-01-25 14:30:51 +0000
@@ -198,7 +198,7 @@
public boolean isZero()
{
return dataElement != null && dataElement.getType().equals(
DataElement.VALUE_TYPE_INT )
- && value != null && ( value.equals( "0" ) ||
value.startsWith( "0." ) );This script will not working fine. *new Double("0.001").intValue()==0 is
true but it must be false.*
I thing it must be n*ew Double(value)==(new Double(0))*
what do you thing ?+ && value != null && new Double( value ).i
I don't think we should allow decimal numbers in the first place, eg it
cant be 0.5 people with malaria or vaccines given. But Jason pointed out
that regex might be the better solution for this in any case.Maybe something like
^[0]*[.]?[0]*$
Start word. Read any number of zeroes followed optionally by a '.' followed
by any number of zeroes. End word.From my emacs buffer, M indicates a match
0 M
003
0.00 M
0.03
.000 M
00.0 M
008000Cheers
BobFeel free to improve, I don't have strong opinions on this.
_______________________________________________
Mailing list:
https://launchpad.net/~dhis2-devs<https://launchpad.net/~dhis2-devs>
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe :
https://launchpad.net/~dhis2-devs<https://launchpad.net/~dhis2-devs>
More help : ListHelp - Launchpad Help
--
Sent from my mobile device
================================
Tran Thanh Tri
HISP Viet Nam
Cell phone: +84903670967
Website: http://tringuyenvn.com
Hi Bob,
I might suggest just a small change.
^[0]*[\.,]?[0]*$
Escape the period and add a comma for some locales that use commas
instead of periods. I am not aware of other decimal points, perhaps a
semicolon?
I am a bit confused though about the concept here. Values in DHIS are
stored in the DB as text, as far as I can tell. People should be
allowed to enter decimal values I think. We have an data element
(Number of liters of fuel). There is no reason why this could not be
entered (and as far as I know, it is) in decimal values. I am sure
there are other examples. Perhaps the validation rules is a better
place to put these types of rules? It sure would be nice to have Regex
capability there, to allow people that are so inclined to create
expressions for validation that would just be evaluated with a regular
expression.
Regards,
JPP
···
2010/1/26 Bob Jolliffe <bobjolliffe@gmail.com>:
2010/1/26 Lars Helge Øverland <larshelge@gmail.com>
2010/1/26 Trí Trần Thanh <tranthanhtri84@gmail.com>
================================
Tran Thanh Tri
HISP Viet Nam
Cell phone: +84903670967
Website: http://tringuyenvn.com2010/1/25 <noreply@launchpad.net>
------------------------------------------------------------
revno: 1337
committer: Lars Helge Oeverland <larshelge@gmail.com>
branch nick: trunk
timestamp: Mon 2010-01-25 15:30:51 +0100
message:
Improved DataValue.isZero
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunkYour 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/datavalue/DataValue.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
2010-01-25 14:08:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
2010-01-25 14:30:51 +0000
@@ -198,7 +198,7 @@
public boolean isZero()
{
return dataElement != null && dataElement.getType().equals(
DataElement.VALUE_TYPE_INT )
- && value != null && ( value.equals( "0" ) ||
value.startsWith( "0." ) );This script will not working fine. new Double("0.001").intValue()==0 is
true but it must be false.
I thing it must be new Double(value)==(new Double(0))
what do you thing ?+ && value != null && new Double( value ).i
I don't think we should allow decimal numbers in the first place, eg it
cant be 0.5 people with malaria or vaccines given. But Jason pointed out
that regex might be the better solution for this in any case.Maybe something like
^[0]*[.]?[0]*$
Start word. Read any number of zeroes followed optionally by a '.' followed
by any number of zeroes. End word.From my emacs buffer, M indicates a match
0 M
003
0.00 M
0.03
.000 M
00.0 M
008000Cheers
BobFeel free to improve, I don't have strong opinions on this.
_______________________________________________
Mailing list: DHIS 2 developers in Launchpad
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : DHIS 2 developers in Launchpad
More help : ListHelp - Launchpad Help_______________________________________________
Mailing list: DHIS 2 developers in Launchpad
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : DHIS 2 developers in Launchpad
More help : ListHelp - Launchpad Help
I don’t think a java.util.regex solution would be hugely more complicated. One advantage is that all it expects is the string datavalue. If casting to a double you might also need to catch a class caste exception to be on the safe side. ie you have to ask is it a double first before you can ask is that double = zero.
Cheers
Bob
···
2010/1/26 Trí Trần Thanh tranthanhtri84@gmail.com
Hi all, my way is easy and simple. Cast to Double and compare with new
Double(0). new Double(value).equal(new Double(0)) ? how do you think?
On 1/26/10, Bob Jolliffe bobjolliffe@gmail.com wrote:
2010/1/26 Lars Helge Øverland larshelge@gmail.com
2010/1/26 Trí Trần Thanh tranthanhtri84@gmail.com
================================
Tran Thanh Tri
HISP Viet Nam
Cell phone: +84903670967
Website: http://tringuyenvn.com
================================
2010/1/25 noreply@launchpad.net
revno: 1337
committer: Lars Helge Oeverland larshelge@gmail.com
branch nick: trunk
timestamp: Mon 2010-01-25 15:30:51 +0100
message:
Improved DataValue.isZero
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
–
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk<https://code.launchpad.net/%7Edhis2-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<https://code.launchpad.net/%7Edhis2-devs-core/dhis2/trunk/+edit-subscription>
.=== 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
2010-01-25 14:08:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
2010-01-25 14:30:51 +0000
@@ -198,7 +198,7 @@
public boolean isZero()
{
return dataElement != null && dataElement.getType().equals(
DataElement.VALUE_TYPE_INT )
&& value != null && ( value.equals( "0" ) ||
value.startsWith( “0.” ) );
This script will not working fine. *new Double(“0.001”).intValue()==0 is
true but it must be false.*
I thing it must be new Double(value)==(new Double(0))
what do you thing ?
&& value != null && new Double( value ).i
I don’t think we should allow decimal numbers in the first place, eg it
cant be 0.5 people with malaria or vaccines given. But Jason pointed out
that regex might be the better solution for this in any case.
Maybe something like
^[0][.]?[0]$
Start word. Read any number of zeroes followed optionally by a ‘.’ followed
by any number of zeroes. End word.
From my emacs buffer, M indicates a match
0 M
003
0.00 M
0.03
.000 M
00.0 M
008000
Cheers
Bob
Feel free to improve, I don’t have strong opinions on this.
Mailing list:
https://launchpad.net/~dhis2-devs<https://launchpad.net/%7Edhis2-devs>
Post to : dhis2-devs@lists.launchpad.netUnsubscribe :
https://launchpad.net/~dhis2-devs<https://launchpad.net/%7Edhis2-devs>
More help : https://help.launchpad.net/ListHelp
–
Sent from my mobile device
================================
Tran Thanh Tri
HISP Viet Nam
Cell phone: +84903670967
Website: http://tringuyenvn.com
================================
Hi Bob,
I might suggest just a small change.
^[0][.,]?[0]$
Escape the period and add a comma for some locales that use commas
instead of periods. I am not aware of other decimal points, perhaps a
semicolon?
True. This is better.
···
2010/1/26 Jason Pickering jason.p.pickering@gmail.com
I am a bit confused though about the concept here. Values in DHIS are
stored in the DB as text, as far as I can tell. People should be
allowed to enter decimal values I think. We have an data element
(Number of liters of fuel). There is no reason why this could not be
entered (and as far as I know, it is) in decimal values. I am sure
there are other examples. Perhaps the validation rules is a better
place to put these types of rules? It sure would be nice to have Regex
capability there, to allow people that are so inclined to create
expressions for validation that would just be evaluated with a regular
expression.
Regards,
JPP
2010/1/26 Bob Jolliffe bobjolliffe@gmail.com:
2010/1/26 Lars Helge Øverland larshelge@gmail.com
2010/1/26 Trí Trần Thanh tranthanhtri84@gmail.com
================================
Tran Thanh Tri
HISP Viet Nam
Cell phone: +84903670967
Website: http://tringuyenvn.com
================================
2010/1/25 noreply@launchpad.net
revno: 1337
committer: Lars Helge Oeverland larshelge@gmail.com
branch nick: trunk
timestamp: Mon 2010-01-25 15:30:51 +0100
message:
Improved DataValue.isZero
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
–
lp:dhis2
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/datavalue/DataValue.java’
— dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
2010-01-25 14:08:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
2010-01-25 14:30:51 +0000
@@ -198,7 +198,7 @@
public boolean isZero()
{
return dataElement != null && dataElement.getType().equals(
DataElement.VALUE_TYPE_INT )
&& value != null && ( value.equals( "0" ) ||
value.startsWith( “0.” ) );
This script will not working fine. new Double(“0.001”).intValue()==0 is
true but it must be false.
I thing it must be new Double(value)==(new Double(0))
what do you thing ?
&& value != null && new Double( value ).i
I don’t think we should allow decimal numbers in the first place, eg it
cant be 0.5 people with malaria or vaccines given. But Jason pointed out
that regex might be the better solution for this in any case.
Maybe something like
^[0][.]?[0]$
Start word. Read any number of zeroes followed optionally by a ‘.’ followed
by any number of zeroes. End word.
From my emacs buffer, M indicates a match
0 M
003
0.00 M
0.03
.000 M
00.0 M
008000
Cheers
Bob
Feel free to improve, I don’t have strong opinions on this.
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help : https://help.launchpad.net/ListHelp
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help : https://help.launchpad.net/ListHelp
Hi Bob,
I might suggest just a small change.
^[0][.,]?[0]$
Escape the period and add a comma for some locales that use commas
instead of periods. I am not aware of other decimal points, perhaps a
semicolon?
True. This is better.
I am a bit confused though about the concept here. Values in DHIS are
stored in the DB as text, as far as I can tell. People should be
allowed to enter decimal values I think. We have an data element
(Number of liters of fuel). There is no reason why this could not be
entered (and as far as I know, it is) in decimal values. I am sure
there are other examples. Perhaps the validation rules is a better
place to put these types of rules? It sure would be nice to have Regex
capability there, to allow people that are so inclined to create
expressions for validation that would just be evaluated with a regular
expression.
I suppose dataelement could have an extra string properties for an (optional) regex. This could be populated with generic defaults for different value types though that is maybe too wasteful. Anyway a user could then create more specialised regexes for particular dataelements. Mind you not too many people are “so inclined”.
Cheers
Bob
···
2010/1/26 Bob Jolliffe bobjolliffe@gmail.com
2010/1/26 Jason Pickering jason.p.pickering@gmail.com
Regards,
JPP
2010/1/26 Bob Jolliffe bobjolliffe@gmail.com:
2010/1/26 Lars Helge Øverland larshelge@gmail.com
2010/1/26 Trí Trần Thanh tranthanhtri84@gmail.com
================================
Tran Thanh Tri
HISP Viet Nam
Cell phone: +84903670967
Website: http://tringuyenvn.com
================================
2010/1/25 noreply@launchpad.net
revno: 1337
committer: Lars Helge Oeverland larshelge@gmail.com
branch nick: trunk
timestamp: Mon 2010-01-25 15:30:51 +0100
message:
Improved DataValue.isZero
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
–
lp:dhis2
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/datavalue/DataValue.java’
— dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
2010-01-25 14:08:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
2010-01-25 14:30:51 +0000
@@ -198,7 +198,7 @@
public boolean isZero()
{
return dataElement != null && dataElement.getType().equals(
DataElement.VALUE_TYPE_INT )
&& value != null && ( value.equals( "0" ) ||
value.startsWith( “0.” ) );
This script will not working fine. new Double(“0.001”).intValue()==0 is
true but it must be false.
I thing it must be new Double(value)==(new Double(0))
what do you thing ?
&& value != null && new Double( value ).i
I don’t think we should allow decimal numbers in the first place, eg it
cant be 0.5 people with malaria or vaccines given. But Jason pointed out
that regex might be the better solution for this in any case.
Maybe something like
^[0][.]?[0]$
Start word. Read any number of zeroes followed optionally by a ‘.’ followed
by any number of zeroes. End word.
From my emacs buffer, M indicates a match
0 M
003
0.00 M
0.03
.000 M
00.0 M
008000
Cheers
Bob
Feel free to improve, I don’t have strong opinions on this.
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help : https://help.launchpad.net/ListHelp
Mailing list: https://launchpad.net/~dhis2-devs
Post to : dhis2-devs@lists.launchpad.net
Unsubscribe : https://launchpad.net/~dhis2-devs
More help : https://help.launchpad.net/ListHelp
True, not that many people are inclined but there are some of us that
find them quite useful. i suspect that many of the most common could
easily be populated as defaults, and developed by those that actually
need it.
I would see this as a huge advantage if implemented.
Let me list some of the things I am thinking about.
1) Min/Max--accept only values 1-199 (^([1-9]|[1-9][0-9]|[1-9][0-9][0-9])$)
2) Identification numbers--for instance, a US Social Security Number
(\b[0-9]{3}-[0-9]{2}-[0-9]{4}\b). Could be handy for the Patient
module especially.
3) Lat/long. I do not know exactly what this would be, but something
like accept number between -180 to 180. Handy for GIS.
4) A decimal value. Perhaps one should be forced to enter a decimal
value, like a persons temperature. [-+]?\b[0-9]*[\.,][0-9]+\b
I agree with Bob. It seems that we must assume that the value is going
to be something that is actually a double just because it is supposed
to be a number. It seems hard to imagine that a number greater than
the range available for a double would even be entered in DHIS, but
who knows...it could happen.
Blueprint anyway? Lars, you don't seem so keen on this, but maybe this
is just for this particular use case, i.e. determining if the value is
zero or not.
Regards,
Jason
···
On Tue, Jan 26, 2010 at 1:38 PM, Bob Jolliffe <bobjolliffe@gmail.com> wrote:
2010/1/26 Bob Jolliffe <bobjolliffe@gmail.com>
2010/1/26 Jason Pickering <jason.p.pickering@gmail.com>
Hi Bob,
I might suggest just a small change.
^[0]*[\.,]?[0]*$
Escape the period and add a comma for some locales that use commas
instead of periods. I am not aware of other decimal points, perhaps a
semicolon?True. This is better.
I am a bit confused though about the concept here. Values in DHIS are
stored in the DB as text, as far as I can tell. People should be
allowed to enter decimal values I think. We have an data element
(Number of liters of fuel). There is no reason why this could not be
entered (and as far as I know, it is) in decimal values. I am sure
there are other examples. Perhaps the validation rules is a better
place to put these types of rules? It sure would be nice to have Regex
capability there, to allow people that are so inclined to create
expressions for validation that would just be evaluated with a regular
expression.I suppose dataelement could have an extra string properties for an
(optional) regex. This could be populated with generic defaults for
different value types though that is maybe too wasteful. Anyway a user
could then create more specialised regexes for particular dataelements.
Mind you not too many people are "so inclined".Cheers
BobRegards,
JPP2010/1/26 Bob Jolliffe <bobjolliffe@gmail.com>:
> 2010/1/26 Lars Helge Øverland <larshelge@gmail.com>
>>
>>
>> 2010/1/26 Trí Trần Thanh <tranthanhtri84@gmail.com>
>>>
>>> ================================
>>> Tran Thanh Tri
>>> HISP Viet Nam
>>> Cell phone: +84903670967
>>> Website: http://tringuyenvn.com
>>> ================================
>>>
>>>
>>> 2010/1/25 <noreply@launchpad.net>
>>>>
>>>> ------------------------------------------------------------
>>>> revno: 1337
>>>> committer: Lars Helge Oeverland <larshelge@gmail.com>
>>>> branch nick: trunk
>>>> timestamp: Mon 2010-01-25 15:30:51 +0100
>>>> message:
>>>> Improved DataValue.isZero
>>>> modified:
>>>>
>>>> dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.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-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java'
>>>> ---
>>>> dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
>>>> 2010-01-25 14:08:24 +0000
>>>> +++
>>>> dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValue.java
>>>> 2010-01-25 14:30:51 +0000
>>>> @@ -198,7 +198,7 @@
>>>> public boolean isZero()
>>>> {
>>>> return dataElement != null && dataElement.getType().equals(
>>>> DataElement.VALUE_TYPE_INT )
>>>> - && value != null && ( value.equals( "0" ) ||
>>>> value.startsWith( "0." ) );
>>>
>>> This script will not working fine. new Double("0.001").intValue()==0
>>> is
>>> true but it must be false.
>>> I thing it must be new Double(value)==(new Double(0))
>>> what do you thing ?
>>>>
>>>> + && value != null && new Double( value ).i
>>
>> I don't think we should allow decimal numbers in the first place, eg
>> it
>> cant be 0.5 people with malaria or vaccines given. But Jason pointed
>> out
>> that regex might be the better solution for this in any case.
>
> Maybe something like
>
> ^[0]*[.]?[0]*$
>
> Start word. Read any number of zeroes followed optionally by a '.'
> followed
> by any number of zeroes. End word.
>
> From my emacs buffer, M indicates a match
> 0 M
> 003
> 0.00 M
> 0.03
> .000 M
> 00.0 M
> 008000
>
> Cheers
> Bob
>
>> Feel free to improve, I don't have strong opinions on this.
>>
>>
>>
>> _______________________________________________
>> Mailing list: DHIS 2 developers in Launchpad
>> Post to : dhis2-devs@lists.launchpad.net
>> Unsubscribe : DHIS 2 developers in Launchpad
>> More help : ListHelp - Launchpad Help
>>
>
>
> _______________________________________________
> Mailing list: DHIS 2 developers in Launchpad
> Post to : dhis2-devs@lists.launchpad.net
> Unsubscribe : DHIS 2 developers in Launchpad
> More help : ListHelp - Launchpad Help
>
>
Feel free to write a blueprint…
https://blueprints.launchpad.net/dhis2/+spec/regex-validation
Done.
Regards,
Jason
···
2010/1/26 Lars Helge Øverland <larshelge@gmail.com>:
Feel free to write a blueprint...