Re: [rules-users] NullPointerException with Wrapper objects

2009-05-14 Thread Shannon Lal
Shabbir,
Do you still need to code section for this? If so, can you show me how you
are loading this into the Working Memory(i.e. the Java code you use prior to
executing the rules).

Shannon

2009/5/14 Wolfgang Laun 

> All right, let's hope that "business user" is up to write the rules, even
> without null checks ;-)
> Seriously now: are they up to handling monetary units represented as
> floating point numbers? A recent thread has emphasized the problems arising
> from tests such as floatVal <= floatConst, and I've been preaching about
> possible inconsistencies due to the inherent nature of FP arithmetic, even
> for doing sums. BigDecimal is one solution, but I guess your BUs will go
> ballistic if you tell them about the consequences...
>
> But here's my last proposal for circumnavigating the NPE issue:
>
> At the point of fact insertion, wrap all "dangerous" bean objects into a
> container fact with a single field and insert the container. Write rules
> matching the container, testing the wrapped object for field == null and
> whatever; if so, change and log; and now insert the wrapped object as a fact
> proper. (If necessary, you could even write a single rule for all fact
> types, using inspection to determine all dangerous fields.)
>
> -W
>
>
> 2009/5/14 Shabbir Dhari 
>
>>  Thanks to all.
>>
>> The problem we have is that rules will be code by business user. As a
>> developer I don’t mind putting null check on every rule. But for business
>> user its unacceptable for checking null for the same attribute in around 50
>> rules.
>>
>> Shannon, can you please elaborate more about your solution or if possible
>> post some simple code?**
>> > Date: Wed, 13 May 2009 08:28:53 -0700
>> > From: greg_bar...@yahoo.com
>> > Subject: RE: [rules-users] NullPointerException with Wrapper objects
>> > To: rules-users@lists.jboss.org
>> >
>> >
>> > Well, like Wolfgang said, good luck with that. :) The only rules engine
>> I know that does this is Tibco BusinessEvents, and it's accomplished by
>> making a copy of your objects before inserting them into working memory.
>> >
>> > >From this forum post I'm guessing JRules doesn't do it:
>> http://forums.ilog.com/brms/index.php?topic=1439.0
>> >
>> > And probably Blaze Advisor doesn't do it either:
>> >
>> http://discuss.fico.com/blaze/board/message?board.id=Blaze_Advisor_Users_Forum&message.id=591
>> >
>> > So, I'm thinking you're stuck with having to do null checks.
>> >
>>
>>
>> --
>> Click Here View photos of singles in your 
>> area<http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fdating%2Eninemsn%2Ecom%2Eau%2Fsearch%2Fsearch%2Easpx%3Fexec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT>
>>
>> ___
>> rules-users mailing list
>> rules-users@lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Wolfgang Laun
All right, let's hope that "business user" is up to write the rules, even
without null checks ;-)
Seriously now: are they up to handling monetary units represented as
floating point numbers? A recent thread has emphasized the problems arising
from tests such as floatVal <= floatConst, and I've been preaching about
possible inconsistencies due to the inherent nature of FP arithmetic, even
for doing sums. BigDecimal is one solution, but I guess your BUs will go
ballistic if you tell them about the consequences...

But here's my last proposal for circumnavigating the NPE issue:

At the point of fact insertion, wrap all "dangerous" bean objects into a
container fact with a single field and insert the container. Write rules
matching the container, testing the wrapped object for field == null and
whatever; if so, change and log; and now insert the wrapped object as a fact
proper. (If necessary, you could even write a single rule for all fact
types, using inspection to determine all dangerous fields.)

-W


2009/5/14 Shabbir Dhari 

>  Thanks to all.
>
> The problem we have is that rules will be code by business user. As a
> developer I don’t mind putting null check on every rule. But for business
> user its unacceptable for checking null for the same attribute in around 50
> rules.
>
> Shannon, can you please elaborate more about your solution or if possible
> post some simple code?**
> > Date: Wed, 13 May 2009 08:28:53 -0700
> > From: greg_bar...@yahoo.com
> > Subject: RE: [rules-users] NullPointerException with Wrapper objects
> > To: rules-users@lists.jboss.org
> >
> >
> > Well, like Wolfgang said, good luck with that. :) The only rules engine I
> know that does this is Tibco BusinessEvents, and it's accomplished by making
> a copy of your objects before inserting them into working memory.
> >
> > >From this forum post I'm guessing JRules doesn't do it:
> http://forums.ilog.com/brms/index.php?topic=1439.0
> >
> > And probably Blaze Advisor doesn't do it either:
> >
> http://discuss.fico.com/blaze/board/message?board.id=Blaze_Advisor_Users_Forum&message.id=591
> >
> > So, I'm thinking you're stuck with having to do null checks.
> >
>
>
> --
> Click Here View photos of singles in your 
> area<http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fdating%2Eninemsn%2Ecom%2Eau%2Fsearch%2Fsearch%2Easpx%3Fexec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Shabbir Dhari





Thanks to
all.



The problem we have is that rules will be code by business user. As a developer
I don’t mind putting null check on every rule. But for business user its
unacceptable for checking null for the same attribute in around 50 rules. 



Shannon, can you please elaborate more about your
solution or if possible post some simple code?

> Date: Wed, 13 May 2009 08:28:53 -0700
> From: greg_bar...@yahoo.com
> Subject: RE: [rules-users] NullPointerException with Wrapper objects
> To: rules-users@lists.jboss.org
> 
> 
> Well, like Wolfgang said, good luck with that. :)  The only rules engine I 
> know that does this is Tibco BusinessEvents, and it's accomplished by making 
> a copy of your objects before inserting them into working memory.  
> 
> >From this forum post I'm guessing JRules doesn't do it: 
> >http://forums.ilog.com/brms/index.php?topic=1439.0
> 
> And probably Blaze Advisor doesn't do it either:
> http://discuss.fico.com/blaze/board/message?board.id=Blaze_Advisor_Users_Forum&message.id=591
> 
> So, I'm thinking you're stuck with having to do null checks.
> 


_
View photos of singles in your area Click Here
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fdating%2Eninemsn%2Ecom%2Eau%2Fsearch%2Fsearch%2Easpx%3Fexec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Greg Barton

Well, like Wolfgang said, good luck with that. :)  The only rules engine I know 
that does this is Tibco BusinessEvents, and it's accomplished by making a copy 
of your objects before inserting them into working memory.  

>From this forum post I'm guessing JRules doesn't do it: 
>http://forums.ilog.com/brms/index.php?topic=1439.0

And probably Blaze Advisor doesn't do it either:
http://discuss.fico.com/blaze/board/message?board.id=Blaze_Advisor_Users_Forum&message.id=591

So, I'm thinking you're stuck with having to do null checks.

--- On Wed, 5/13/09, Shabbir Dhari  wrote:

> From: Shabbir Dhari 
> Subject: RE: [rules-users] NullPointerException with Wrapper objects
> To: rules-users@lists.jboss.org
> Date: Wednesday, May 13, 2009, 5:44 AM
> Thanks for all you efforts  :) but what is the difference
> between calling function from every rule or putting null
> check. I give up. I am looking for other rule engines.
>  
> 
> 
> Date: Wed, 13 May 2009 12:19:08 +0200
> Subject: Re: [rules-users] NullPointerException with
> Wrapper objects
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
> 
> Well, I hope you get paid for all the extra work ;-)
> 
> Define, in your .drl file,
> 
> function float safe( Float v ){
>   return v == null ? 0 : v;
> }
> 
> and wrap all references to the "dangerous"
> field(s) in your LHS pattern expressions with this call,
> except, of course, in the rule where you fix and log the
> field.
> 
> -W
> 
> 
> 
> 
> 2009/5/13 Shabbir Dhari 
> 
> 
> 
> Well I cant explain you all the issues and requirements
> here. Simply we dont have provision to do so. We have to
> check the null in the rules and log the message plus other
> evaluation and arithmetic.
>  
> 
> 
> Date: Wed, 13 May 2009 10:36:59 +0200
> 
> 
> 
> Subject: Re: [rules-users] NullPointerException with
> Wrapper objects
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
> 
> But you do control the insertion of your facts. Rather than
> cluttering rules with conditions dealing with irregular
> values, preprocess the object. And you should be able to log
> from there, just as well.
> -W
> 
> 
> 2009/5/13 Shabbir Dhari 
> 
> 
> I can not initialize property as need to log the message.
> The bean comes from outside our application scope. We do not
> have control to make them menodatory. And we need to log the
> message. You mean there is no solution of this problem? And
> remember my second rule does not compare propery but it
> performs some calculations. 
>  
> 
> 
> Date: Wed, 13 May 2009 09:01:05 +0200 
> 
> Subject: Re: [rules-users] NullPointerException with
> Wrapper objects
> From: wolfgang.l...@gmail.com 
> 
> To: rules-users@lists.jboss.org
> 
> What about setting the field to 0 in the constructor of
> Salary?
> Or using float (not java.lang.Float)?
> -W
> 
> 
> 2009/5/13 Shabbir Dhari 
> 
> 
> I know this work around. But I have more than 50 rules
> using that attribute and it looks very ugly to put null on
> every rule and its not single attribute. There are more than
> 30 attributes in the bean and using them in LHS. Any other
> sophisticated way?
> 
> > Date: Tue, 12 May 2009 23:15:54 -0700
> > From: greg_bar...@yahoo.com
> > Subject: Re: [rules-users] NullPointerException with
> Wrapper objects 
> 
> > To: rules-users@lists.jboss.org
> > 
> > 
> 
> > All conditions of all applicable rules are evaluated
> when you insert an object into working memory. This decides
> which rule actions can go on the agenda. Only when a rule
> action is on the agenda is the salience used to determine
> the order of action firing. So doing the null check in the
> way you're doing it will not work.
> > 
> > You must put the null check in the same rule, before
> the potentially null property is used.
> > 
> > rule "Nett Salary" salience 70
> > when
> > Salary ( loanDeduction != null, nett != ( gross –
> loanDeduction – pf) )
> > then
> > log("Invalid nett salary amount");
> > end
> > 
> 
> 
> 
> 
> Check out the new Windows Live Messenger Looking for a
> fresh way to share your photos?
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 
> 
> 
> 
> Click Here View photos of singles in your area
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailma

Re: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Shannon Lal
I am no expert on drools; however, you might want to retract loanDeduction
from the Working Memory if it is null.  Your first rule determines that it
is null and then you set the value (ld = 0f); however, you should be using
an insert to put this into working memory.  The other alternative is to
retract the loan Deduction  from working memory and add a logic check in the
Nett Salary rule to see if loan Dedcution is null.

I am working on some Drools stuff today if you need some more help on this.

Shannon


On Wed, May 13, 2009 at 1:14 AM, dhai  wrote:

>
> I am facing problems which many have encountered in the past. I searched
> forums but could not get precise answer. The problem is with null values in
> Wrapper objects. See the following code:
>
> rule "Null Check " salience 100
>when
>Salary ( ld : loanDeduction==null || < 0f ) // loanDeduction
> is java.lang.Float
>then
>log("Load return is null"); //Global function
>ld = 0f;
> end
>
> rule "Nett Salary" salience 70
>when
>Salary ( nett != ( gross – loanDeduction – pf) )
>then
>log("Invalid nett salary amount");
> end
>
> You may have idea what I am trying to do. But I get NullPointerException in
> “Nett Salary” rule when I fire the rules having fact with null in the
> loanDeduction attribute. I believe my “Null Check” exception should execute
> first and it does when I put negative value in loadDeduction. What is
> solution in such a case?
> --
> View this message in context:
> http://www.nabble.com/NullPointerException-with-Wrapper-objects-tp23515500p23515500.html
> Sent from the drools - user mailing list archive at Nabble.com.
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Wolfgang Laun
2009/5/13 Shabbir Dhari 

>  Thanks for all you efforts  :) but what is the difference between calling
> function from every rule or putting null check.
>

It's much easier to add.



> I give up. I am looking for other rule engines.
>

As they must apparently (due to JavaBeans) be Java-based, I'd be very much
surprised if you'll find what you are looking for.

-W



>
>
> --
> Date: Wed, 13 May 2009 12:19:08 +0200
>
> Subject: Re: [rules-users] NullPointerException with Wrapper objects
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
>
> Well, I hope you get paid for all the extra work ;-)
>
> Define, in your .drl file,
>
> function float safe( Float v ){
>   return v == null ? 0 : v;
> }
>
> and wrap all references to the "dangerous" field(s) in your LHS pattern
> expressions with this call, except, of course, in the rule where you fix and
> log the field.
>
> -W
>
>
>
> 2009/5/13 Shabbir Dhari 
>
>  Well I cant explain you all the issues and requirements here. Simply we
> dont have provision to do so. We have to check the null in the rules and log
> the message plus other evaluation and arithmetic.
>
> ------
> Date: Wed, 13 May 2009 10:36:59 +0200
>
> Subject: Re: [rules-users] NullPointerException with Wrapper objects
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
>
> But you do control the insertion of your facts. Rather than cluttering
> rules with conditions dealing with irregular values, preprocess the object.
> And you should be able to log from there, just as well.
> -W
>
> 2009/5/13 Shabbir Dhari 
>
> I can not initialize property as need to log the message. The bean comes
> from outside our application scope. We do not have control to make them
> menodatory. And we need to log the message. You mean there is no solution of
> this problem? And remember my second rule does not compare propery but
> it performs some calculations.
>
> --
> Date: Wed, 13 May 2009 09:01:05 +0200
> Subject: Re: [rules-users] NullPointerException with Wrapper objects
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
>
> What about setting the field to 0 in the constructor of Salary?
> Or using float (not java.lang.Float)?
> -W
>
> 2009/5/13 Shabbir Dhari 
>
> I know this work around. But I have more than 50 rules using that attribute
> and it looks very ugly to put null on every rule and its not single
> attribute. There are more than 30 attributes in the bean and using them in
> LHS. Any other sophisticated way?
>
> > Date: Tue, 12 May 2009 23:15:54 -0700
> > From: greg_bar...@yahoo.com
> > Subject: Re: [rules-users] NullPointerException with Wrapper objects
> > To: rules-users@lists.jboss.org
> >
> >
> > All conditions of all applicable rules are evaluated when you insert an
> object into working memory. This decides which rule actions can go on the
> agenda. Only when a rule action is on the agenda is the salience used to
> determine the order of action firing. So doing the null check in the way
> you're doing it will not work.
> >
> > You must put the null check in the same rule, before the potentially null
> property is used.
> >
> > rule "Nett Salary" salience 70
> > when
> > Salary ( loanDeduction != null, nett != ( gross – loanDeduction – pf) )
> > then
> > log("Invalid nett salary amount");
> > end
> >
>
>
> --
> Check out the new Windows Live Messenger Looking for a fresh way to share
> your photos? <http://windowslive.ninemsn.com.au/article.aspx?id=792335>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> --
> Click Here View photos of singles in your 
> area<http://a.ninemsn.com.au/b.aspx?URL=http://dating.ninemsn.com.au/search/search.aspx?exec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> --
> Find out how with Windows Live! Want to stay on top of your life 
> online?<http://windowslive.ninemsn.com.au/>
>
> ___
> rules-use

RE: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Shabbir Dhari

Thanks for all you efforts  :) but what is the difference between calling 
function from every rule or putting null check. I give up. I am looking for 
other rule engines.
 


Date: Wed, 13 May 2009 12:19:08 +0200
Subject: Re: [rules-users] NullPointerException with Wrapper objects
From: wolfgang.l...@gmail.com
To: rules-users@lists.jboss.org

Well, I hope you get paid for all the extra work ;-)

Define, in your .drl file,

function float safe( Float v ){
  return v == null ? 0 : v;
}

and wrap all references to the "dangerous" field(s) in your LHS pattern 
expressions with this call, except, of course, in the rule where you fix and 
log the field.

-W




2009/5/13 Shabbir Dhari 



Well I cant explain you all the issues and requirements here. Simply we dont 
have provision to do so. We have to check the null in the rules and log the 
message plus other evaluation and arithmetic.
 


Date: Wed, 13 May 2009 10:36:59 +0200



Subject: Re: [rules-users] NullPointerException with Wrapper objects
From: wolfgang.l...@gmail.com
To: rules-users@lists.jboss.org

But you do control the insertion of your facts. Rather than cluttering rules 
with conditions dealing with irregular values, preprocess the object. And you 
should be able to log from there, just as well.
-W


2009/5/13 Shabbir Dhari 


I can not initialize property as need to log the message. The bean comes from 
outside our application scope. We do not have control to make them menodatory. 
And we need to log the message. You mean there is no solution of this problem? 
And remember my second rule does not compare propery but it performs some 
calculations. 
 


Date: Wed, 13 May 2009 09:01:05 +0200 

Subject: Re: [rules-users] NullPointerException with Wrapper objects
From: wolfgang.l...@gmail.com 

To: rules-users@lists.jboss.org

What about setting the field to 0 in the constructor of Salary?
Or using float (not java.lang.Float)?
-W


2009/5/13 Shabbir Dhari 


I know this work around. But I have more than 50 rules using that attribute and 
it looks very ugly to put null on every rule and its not single attribute. 
There are more than 30 attributes in the bean and using them in LHS. Any other 
sophisticated way?

> Date: Tue, 12 May 2009 23:15:54 -0700
> From: greg_bar...@yahoo.com
> Subject: Re: [rules-users] NullPointerException with Wrapper objects 

> To: rules-users@lists.jboss.org
> 
> 

> All conditions of all applicable rules are evaluated when you insert an 
> object into working memory. This decides which rule actions can go on the 
> agenda. Only when a rule action is on the agenda is the salience used to 
> determine the order of action firing. So doing the null check in the way 
> you're doing it will not work.
> 
> You must put the null check in the same rule, before the potentially null 
> property is used.
> 
> rule "Nett Salary" salience 70
> when
> Salary ( loanDeduction != null, nett != ( gross – loanDeduction – pf) )
> then
> log("Invalid nett salary amount");
> end
> 




Check out the new Windows Live Messenger Looking for a fresh way to share your 
photos?
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users





Click Here View photos of singles in your area
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users





Find out how with Windows Live! Want to stay on top of your life online?
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



_
Want to stay on top of your life online? Find out how with Windows Live!
http://windowslive.ninemsn.com.au/___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Wolfgang Laun
Well, I hope you get paid for all the extra work ;-)

Define, in your .drl file,

function float safe( Float v ){
  return v == null ? 0 : v;
}

and wrap all references to the "dangerous" field(s) in your LHS pattern
expressions with this call, except, of course, in the rule where you fix and
log the field.

-W



2009/5/13 Shabbir Dhari 

>  Well I cant explain you all the issues and requirements here. Simply we
> dont have provision to do so. We have to check the null in the rules and log
> the message plus other evaluation and arithmetic.
>
> --
> Date: Wed, 13 May 2009 10:36:59 +0200
>
> Subject: Re: [rules-users] NullPointerException with Wrapper objects
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
>
> But you do control the insertion of your facts. Rather than cluttering
> rules with conditions dealing with irregular values, preprocess the object.
> And you should be able to log from there, just as well.
> -W
>
> 2009/5/13 Shabbir Dhari 
>
> I can not initialize property as need to log the message. The bean comes
> from outside our application scope. We do not have control to make them
> menodatory. And we need to log the message. You mean there is no solution of
> this problem? And remember my second rule does not compare propery but
> it performs some calculations.
>
> ----------
> Date: Wed, 13 May 2009 09:01:05 +0200
> Subject: Re: [rules-users] NullPointerException with Wrapper objects
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
>
> What about setting the field to 0 in the constructor of Salary?
> Or using float (not java.lang.Float)?
> -W
>
> 2009/5/13 Shabbir Dhari 
>
> I know this work around. But I have more than 50 rules using that attribute
> and it looks very ugly to put null on every rule and its not single
> attribute. There are more than 30 attributes in the bean and using them in
> LHS. Any other sophisticated way?
>
> > Date: Tue, 12 May 2009 23:15:54 -0700
> > From: greg_bar...@yahoo.com
> > Subject: Re: [rules-users] NullPointerException with Wrapper objects
> > To: rules-users@lists.jboss.org
> >
> >
> > All conditions of all applicable rules are evaluated when you insert an
> object into working memory. This decides which rule actions can go on the
> agenda. Only when a rule action is on the agenda is the salience used to
> determine the order of action firing. So doing the null check in the way
> you're doing it will not work.
> >
> > You must put the null check in the same rule, before the potentially null
> property is used.
> >
> > rule "Nett Salary" salience 70
> > when
> > Salary ( loanDeduction != null, nett != ( gross – loanDeduction – pf) )
> > then
> > log("Invalid nett salary amount");
> > end
> >
>
>
> --
> Check out the new Windows Live Messenger Looking for a fresh way to share
> your photos? <http://windowslive.ninemsn.com.au/article.aspx?id=792335>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> --
> Click Here View photos of singles in your 
> area<http://a.ninemsn.com.au/b.aspx?URL=http://dating.ninemsn.com.au/search/search.aspx?exec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> --
> Find out how with Windows Live! Want to stay on top of your life 
> online?<http://windowslive.ninemsn.com.au/>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Shabbir Dhari

Well I cant explain you all the issues and requirements here. Simply we dont 
have provision to do so. We have to check the null in the rules and log the 
message plus other evaluation and arithmetic.
 

Date: Wed, 13 May 2009 10:36:59 +0200
Subject: Re: [rules-users] NullPointerException with Wrapper objects
From: wolfgang.l...@gmail.com
To: rules-users@lists.jboss.org

But you do control the insertion of your facts. Rather than cluttering rules 
with conditions dealing with irregular values, preprocess the object. And you 
should be able to log from there, just as well.
-W


2009/5/13 Shabbir Dhari 


I can not initialize property as need to log the message. The bean comes from 
outside our application scope. We do not have control to make them menodatory. 
And we need to log the message. You mean there is no solution of this problem? 
And remember my second rule does not compare propery but it performs some 
calculations. 
 


Date: Wed, 13 May 2009 09:01:05 +0200

Subject: Re: [rules-users] NullPointerException with Wrapper objects
From: wolfgang.l...@gmail.com

To: rules-users@lists.jboss.org

What about setting the field to 0 in the constructor of Salary?
Or using float (not java.lang.Float)?
-W


2009/5/13 Shabbir Dhari 


I know this work around. But I have more than 50 rules using that attribute and 
it looks very ugly to put null on every rule and its not single attribute. 
There are more than 30 attributes in the bean and using them in LHS. Any other 
sophisticated way?

> Date: Tue, 12 May 2009 23:15:54 -0700
> From: greg_bar...@yahoo.com
> Subject: Re: [rules-users] NullPointerException with Wrapper objects 

> To: rules-users@lists.jboss.org
> 
> 

> All conditions of all applicable rules are evaluated when you insert an 
> object into working memory. This decides which rule actions can go on the 
> agenda. Only when a rule action is on the agenda is the salience used to 
> determine the order of action firing. So doing the null check in the way 
> you're doing it will not work.
> 
> You must put the null check in the same rule, before the potentially null 
> property is used.
> 
> rule "Nett Salary" salience 70
> when
> Salary ( loanDeduction != null, nett != ( gross – loanDeduction – pf) )
> then
> log("Invalid nett salary amount");
> end
> 




Check out the new Windows Live Messenger Looking for a fresh way to share your 
photos?
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users





Click Here View photos of singles in your area
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



_
Want to stay on top of your life online? Find out how with Windows Live!
http://windowslive.ninemsn.com.au/___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Wolfgang Laun
But you do control the insertion of your facts. Rather than cluttering rules
with conditions dealing with irregular values, preprocess the object. And
you should be able to log from there, just as well.
-W

2009/5/13 Shabbir Dhari 

>  I can not initialize property as need to log the message. The bean comes
> from outside our application scope. We do not have control to make them
> menodatory. And we need to log the message. You mean there is no solution of
> this problem? And remember my second rule does not compare propery but
> it performs some calculations.
>
> --
> Date: Wed, 13 May 2009 09:01:05 +0200
> Subject: Re: [rules-users] NullPointerException with Wrapper objects
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
>
> What about setting the field to 0 in the constructor of Salary?
> Or using float (not java.lang.Float)?
> -W
>
> 2009/5/13 Shabbir Dhari 
>
>  I know this work around. But I have more than 50 rules using that
> attribute and it looks very ugly to put null on every rule and its not
> single attribute. There are more than 30 attributes in the bean and using
> them in LHS. Any other sophisticated way?
>
> > Date: Tue, 12 May 2009 23:15:54 -0700
> > From: greg_bar...@yahoo.com
> > Subject: Re: [rules-users] NullPointerException with Wrapper objects
> > To: rules-users@lists.jboss.org
> >
> >
> > All conditions of all applicable rules are evaluated when you insert an
> object into working memory. This decides which rule actions can go on the
> agenda. Only when a rule action is on the agenda is the salience used to
> determine the order of action firing. So doing the null check in the way
> you're doing it will not work.
> >
> > You must put the null check in the same rule, before the potentially null
> property is used.
> >
> > rule "Nett Salary" salience 70
> > when
> > Salary ( loanDeduction != null, nett != ( gross – loanDeduction – pf) )
> > then
> > log("Invalid nett salary amount");
> > end
> >
>
>
> --
> Check out the new Windows Live Messenger Looking for a fresh way to share
> your photos? <http://windowslive.ninemsn.com.au/article.aspx?id=792335>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> --
> Click Here View photos of singles in your 
> area<http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fdating%2Eninemsn%2Ecom%2Eau%2Fsearch%2Fsearch%2Easpx%3Fexec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Shabbir Dhari

I can not initialize property as need to log the message. The bean comes from 
outside our application scope. We do not have control to make them menodatory. 
And we need to log the message. You mean there is no solution of this problem? 
And remember my second rule does not compare propery but it performs some 
calculations. 
 


Date: Wed, 13 May 2009 09:01:05 +0200
Subject: Re: [rules-users] NullPointerException with Wrapper objects
From: wolfgang.l...@gmail.com
To: rules-users@lists.jboss.org

What about setting the field to 0 in the constructor of Salary?
Or using float (not java.lang.Float)?
-W


2009/5/13 Shabbir Dhari 



I know this work around. But I have more than 50 rules using that attribute and 
it looks very ugly to put null on every rule and its not single attribute. 
There are more than 30 attributes in the bean and using them in LHS. Any other 
sophisticated way?

> Date: Tue, 12 May 2009 23:15:54 -0700
> From: greg_bar...@yahoo.com
> Subject: Re: [rules-users] NullPointerException with Wrapper objects

> To: rules-users@lists.jboss.org
> 
> 

> All conditions of all applicable rules are evaluated when you insert an 
> object into working memory. This decides which rule actions can go on the 
> agenda. Only when a rule action is on the agenda is the salience used to 
> determine the order of action firing. So doing the null check in the way 
> you're doing it will not work.
> 
> You must put the null check in the same rule, before the potentially null 
> property is used.
> 
> rule "Nett Salary" salience 70
> when
> Salary ( loanDeduction != null, nett != ( gross – loanDeduction – pf) )
> then
> log("Invalid nett salary amount");
> end
> 




Check out the new Windows Live Messenger Looking for a fresh way to share your 
photos?
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



_
View photos of singles in your area Click Here
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fdating%2Eninemsn%2Ecom%2Eau%2Fsearch%2Fsearch%2Easpx%3Fexec%3Dgo%26tp%3Dq%26gc%3D2%26tr%3D1%26lage%3D18%26uage%3D55%26cl%3D14%26sl%3D0%26dist%3D50%26po%3D1%26do%3D2%26trackingid%3D1046138%26r2s%3D1&_t=773166090&_r=Hotmail_Endtext&_m=EXT___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] NullPointerException with Wrapper objects

2009-05-13 Thread Wolfgang Laun
What about setting the field to 0 in the constructor of Salary?
Or using float (not java.lang.Float)?
-W

2009/5/13 Shabbir Dhari 

>  I know this work around. But I have more than 50 rules using that
> attribute and it looks very ugly to put null on every rule and its not
> single attribute. There are more than 30 attributes in the bean and using
> them in LHS. Any other sophisticated way?
>
> > Date: Tue, 12 May 2009 23:15:54 -0700
> > From: greg_bar...@yahoo.com
> > Subject: Re: [rules-users] NullPointerException with Wrapper objects
> > To: rules-users@lists.jboss.org
> >
> >
> > All conditions of all applicable rules are evaluated when you insert an
> object into working memory. This decides which rule actions can go on the
> agenda. Only when a rule action is on the agenda is the salience used to
> determine the order of action firing. So doing the null check in the way
> you're doing it will not work.
> >
> > You must put the null check in the same rule, before the potentially null
> property is used.
> >
> > rule "Nett Salary" salience 70
> > when
> > Salary ( loanDeduction != null, nett != ( gross – loanDeduction – pf) )
> > then
> > log("Invalid nett salary amount");
> > end
> >
>
>
> --
> Check out the new Windows Live Messenger Looking for a fresh way to share
> your photos? <http://windowslive.ninemsn.com.au/article.aspx?id=792335>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] NullPointerException with Wrapper objects

2009-05-12 Thread Shabbir Dhari



I know this
work around. But I have more than 50 rules using that attribute and it looks
very ugly to put null on every rule and its not single attribute. There are
more than 30 attributes in the bean and using them in LHS. Any other 
sophisticated
way?


> Date: Tue, 12 May 2009 23:15:54 -0700
> From: greg_bar...@yahoo.com
> Subject: Re: [rules-users] NullPointerException with Wrapper objects
> To: rules-users@lists.jboss.org
> 
> 
> All conditions of all applicable rules are evaluated when you insert an 
> object into working memory.  This decides which rule actions can go on the 
> agenda.  Only when a rule action is on the agenda is the salience used to 
> determine the order of action firing.  So doing the null check in the way 
> you're doing it will not work.
> 
> You must put the null check in the same rule, before the potentially null 
> property is used.
> 
> rule "Nett Salary" salience 70
>   when
> Salary ( loanDeduction != null, nett != ( gross – loanDeduction – pf) )
>   then
> log("Invalid nett salary amount");
> end
> 


_
Looking for a fresh way to share your photos? Check out the new Windows Live 
Messenger
http://windowslive.ninemsn.com.au/article.aspx?id=792335___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] NullPointerException with Wrapper objects

2009-05-12 Thread Greg Barton

All conditions of all applicable rules are evaluated when you insert an object 
into working memory.  This decides which rule actions can go on the agenda.  
Only when a rule action is on the agenda is the salience used to determine the 
order of action firing.  So doing the null check in the way you're doing it 
will not work.

You must put the null check in the same rule, before the potentially null 
property is used.

rule "Nett Salary" salience 70
  when
Salary ( loanDeduction != null, nett != ( gross – loanDeduction – pf) )
  then
log("Invalid nett salary amount");
end


--- On Wed, 5/13/09, dhai  wrote:

> From: dhai 
> Subject: [rules-users] NullPointerException with Wrapper objects
> To: rules-users@lists.jboss.org
> Date: Wednesday, May 13, 2009, 12:14 AM
> I am facing problems which many have encountered in the
> past. I searched
> forums but could not get precise answer. The problem is
> with null values in
> Wrapper objects. See the following code:
> 
> rule "Null Check " salience 100
> when
> Salary ( ld : loanDeduction==null || <
> 0f ) // loanDeduction
> is java.lang.Float
> then
> log("Load return is null");
> //Global function
> ld = 0f;
> end
> 
> rule "Nett Salary" salience 70
> when
> Salary ( nett != ( gross – loanDeduction
> – pf) )
> then
> log("Invalid nett salary
> amount");
> end
> 
> You may have idea what I am trying to do. But I get
> NullPointerException in
> “Nett Salary” rule when I fire the rules having fact
> with null in the
> loanDeduction attribute. I believe my “Null Check”
> exception should execute
> first and it does when I put negative value in
> loadDeduction. What is
> solution in such a case? 
> -- 
> View this message in context:
> http://www.nabble.com/NullPointerException-with-Wrapper-objects-tp23515500p23515500.html
> Sent from the drools - user mailing list archive at
> Nabble.com.
> 
> 
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users


  

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users