Re: [rules-users] How to traverse the Collection by index

2010-03-08 Thread Shabbir Dhari

Dear Thomas

 

I got the idea. Thanks alot for quick and detailed response.

 

Ragards,

Dhari

 
> From: tswinde...@nds.com
> To: rules-users@lists.jboss.org
> Date: Mon, 8 Mar 2010 08:16:31 +
> Subject: Re: [rules-users] How to traverse the Collection by index
> 
> One of the big challenges of using drools is thinking declaratively and not 
> the iterative method of normal programming. Your first paragraph actually 
> pretty much sums up your rules nicely. One thing to comment on is that 
> working on collections (using the from keyword) isn't a particularly 
> efficient approach as whenever the collection (or fact the collection is in) 
> is updated everything using that collection is re-evaluated. Putting your 
> Segments straight into the knowledge base is more efficient and fits the 
> drools model better, however there are cases where this isn't really an 
> option so you may have to adapt the pseudo code below.
> 
> >From your summary you'd probably want rules similar to the pseudo code here, 
> >I've added a index field into your segment so that your can reason over the 
> >order easily as well:
> 
> //will match segment with index 0
> rule "first segment doesn't start at start of year"
> when
> Segment(index == 0, startDate.month != 1 || startDate.day != 1)
> then
> System.out.println("First segment doesn't start on 1/1");
> End
> 
> //Will match every pair of segments except the last one (as there isn't a 
> last one +1)
> rule "segments aren't consecutive"
> when
> first : Segment()
> second : Segment(index == first.index+1, startDate != first.endDate+1)
> then
> System.out.println("Segments aren't consecutive");
> end
> 
> //if there is a segment without a following segment and whose end date isn't 
> 31/12
> rule "last segment doesn't end at end of year"
> when
> last : Segment(endDate.month != 12 || endDate.day != 31)
> not exist Segment(index == last.index+1)
> then
> System.out.println("Last segment doesn't end at end of year")
> end
> 
> 
> These probably won't compile but will hopefully give you a clue on how you 
> could define your rules, if necessary you could liberally sprinkle from's 
> across them to read the segments out of a particular collection.
> 
> Thomas
> 
> > -Original Message-
> > From: rules-users-boun...@lists.jboss.org [mailto:rules-users-
> > boun...@lists.jboss.org] On Behalf Of dhari
> > Sent: 08 March 2010 06:38
> > To: rules-users@lists.jboss.org
> > Subject: [rules-users] How to traverse the Collection by index
> >
> >
> > Hi all,
> > I want to compare all elements in the collection with other element of the
> > same collection. In my case I have collection of Segment, a Segment contains
> > startDate and endDate. The whole collection of Segment should consists on
> > complete calendar year and every segment in the list must start 1+ from the
> > endDate of last element. Valid fact should be:
> >
> > MemberShip
> > Segment 1: StartDate: 01-01-2010 EndDate: 30-05-2010
> > Segment 2: StartDate: 31-05-2010 EndDate: 08-08-2010
> > Segment 3: StartDate 09-08-2010 EndDate: 31-12-2010
> >
> > Data structure
> > class Segment{
> > java.util.Date startDate;
> > java.util.Date endDate;
> > }
> > class Membership{
> > java.util.ArrayList segments;
> > }
> >
> > I know the date functions. I just want to know how can I traverse the List
> > from get element on Index and Index+1?
> > --
> > View this message in context: http://n3.nabble.com/How-to-traverse-the-
> > Collection-by-index-tp435000p435000.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
> 
> 
> **
> This message is confidential and intended only for the addressee. If you have 
> received this message in error, please immediately notify the 
> postmas...@nds.com and delete it from your system as well as any copies. The 
> content of e-mails as well as traffic data may be monitored by NDS for 
> employment and security purposes. To protect the environment please do not 
> print this e-mail unless necessary.
> 
> NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 
> 4EX, United Kingdom. A company registered in England and Wales. Registered 
> no. 3080780. VAT no. GB 603 8808 40-00
> **
> 
> This message is confidential and intended only for the addressee. If you have 
> received this message in error, please immediately notify the 
> postmas...@nds.com and delete it from your system as well as any copies. The 
> content of e-mails as well as traffic data may be monitored by NDS for 
> employment and security purposes.
> To protect the environment please do not print this e-mail unless necessary.
> 
> An NDS Group Limited comp

Re: [rules-users] Comparing Date with || OR operator

2010-02-24 Thread Shabbir Dhari

Hi Pavel

 

I really don’t understand what do you mean. I guess you didn’t read complete 
thread carefully. Assigning endDate attribute in a variable and not using that 
variable in condition make no sense to me.

 

Shabbir


 
> Date: Wed, 24 Feb 2010 10:54:24 +0100
> From: pavel.tav...@gmail.com
> To: rules-users@lists.jboss.org
> Subject: Re: [rules-users] Comparing Date with || OR operator
> 
> What about:
> Membership ( $regDate : regDate)
> Segment ($endDate : endDate, startDate < $regDate || startDate > endDate )
> 
> Logically startDate > endDate doesn't make sense but it should work ;-)
> 
> Pavel
> 
> 2010/2/24 Shabbir Dhari :
> > I tried with some thing different and it worked but I don’t want this as I
> > have many collections in my data structure.
> >
> > //this works
> > Membership ( $regDate : regDate)
> > Segment ( $endDate : endDate )
> > Segment ( startDate < $regDate || startDate > $endDate )
> >
> > //this does NOT work
> > Membership ( $regDate : regDate)
> > Segment ($endDate : endDate, startDate < $regDate || startDate >
> > $endDate )
> >
> > 
> > From: sdh...@hotmail.com
> > To: rules-users@lists.jboss.org
> > Date: Tue, 23 Feb 2010 23:09:50 +
> > Subject: Re: [rules-users] Comparing Date with || OR operator
> >
> > Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate )
> > even does not work. I am using verstion 5.0.1. All dates are java.util.Date
> > and values in sample fact are:
> >
> > regDate = Fri Aug 01 00:00:00 BST 2008
> > startDate =  Tue Sep 01 00:00:00 BST 2009
> > endDate = Fri Jul 30 00:00:00 BST 2010
> >
> > Stack trace:
> >
> > java.lang.NullPointerException
> > at org.drools.reteoo.LeftTuple.get(LeftTuple.java:265)
> > at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300)
> > at
> > org.drools.rule.VariableRestriction$ObjectVariableContextEntry.updateFromTuple(VariableRestriction.java:320)
> > at
> > org.drools.rule.AbstractCompositeConstraint$MultiFieldConstraintContextEntry.updateFromTuple(AbstractCompositeConstraint.java:305)
> > at
> > org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:119)
> > at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:109)
> > at
> > org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)
> > at
> > org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:78)
> > at
> > org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142)
> > at
> > org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
> > at
> > org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
> > at
> > org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
> > at
> > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
> > at
> > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
> > at
> > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
> > at
> > org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:192)
> > at
> > au.gov.nsw.osr.zena.rules.AnnualRulesTester.main(AnnualRulesTester.java:57)
> >
> >
> >> Date: Tue, 23 Feb 2010 12:54:46 +0100
> >> From: wolfgang.l...@gmail.com
> >> To: rules-users@lists.jboss.org
> >> Subject: Re: [rules-users] Comparing Date with || OR operator
> >>
> >> Please try this rewrite of the 2nd CE:
> >> Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate
> >> )
> >> and report the outcome to the list, together with the Dools version
> >> you are using.
> >> Thank you.
> >>
> >>
> >> 2010/2/23 dhari :
> >> > Hi Thomas
> >> >
> >> > Thanks your prompt reply. I am sure all three attributes are NOT null. I
> >> > have tested them before sending question to mailing list. If you want,
> >> > I can
> >> > send complete sample code and you can try it at your end.
> >> >
> >> > Regards,
> >> > Dhari
> >> >
> >> >
> >> > 
> >> > Date: Tue, 23 Feb

Re: [rules-users] Comparing Date with || OR operator

2010-02-23 Thread Shabbir Dhari



I tried
with some thing different and it worked but I don’t want this as I have many
collections in my data structure.


//this works
Membership ( $regDate : regDate)
Segment ( $endDate : endDate )
Segment ( startDate < $regDate || startDate > $endDate )

//this does NOT work
Membership ( $regDate : regDate)
Segment ($endDate : endDate, startDate < $regDate || startDate > $endDate )

From: sdh...@hotmail.com
To: rules-users@lists.jboss.org
Date: Tue, 23 Feb 2010 23:09:50 +
Subject: Re: [rules-users] Comparing Date with || OR operator








Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate ) 
even does not work. I am using verstion 5.0.1. All dates are java.util.Date and 
values in sample fact are:

regDate = Fri Aug 01 00:00:00 BST 2008
startDate =  Tue Sep 01 00:00:00 BST 2009
endDate = Fri Jul 30 00:00:00 BST 2010

Stack trace: 

java.lang.NullPointerException
at org.drools.reteoo.LeftTuple.get(LeftTuple.java:265)
at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300)
at 
org.drools.rule.VariableRestriction$ObjectVariableContextEntry.updateFromTuple(VariableRestriction.java:320)
at 
org.drools.rule.AbstractCompositeConstraint$MultiFieldConstraintContextEntry.updateFromTuple(AbstractCompositeConstraint.java:305)
at 
org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:119)
at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:109)
at 
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)
at 
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:78)
at 
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142)
at 
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at 
org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:192)
at 
au.gov.nsw.osr.zena.rules.AnnualRulesTester.main(AnnualRulesTester.java:57)


> Date: Tue, 23 Feb 2010 12:54:46 +0100
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
> Subject: Re: [rules-users] Comparing Date with || OR operator
> 
> Please try this rewrite of the 2nd CE:
>Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate 
> )
> and report the outcome to the list, together with the Dools version
> you are using.
> Thank you.
> 
> 
> 2010/2/23 dhari :
> > Hi Thomas
> >
> > Thanks your prompt reply. I am sure all three attributes are NOT null. I
> > have tested them before sending question to mailing list. If you want, I can
> > send complete sample code and you can try it at your end.
> >
> > Regards,
> > Dhari
> >
> >
> > 
> > Date: Tue, 23 Feb 2010 02:50:08 -0800
> > From: [hidden email]
> > To: [hidden email]
> > Subject: Re: Comparing Date with || OR operator
> >
> > If it works fine with an and operator then I’d imagine that startDate <
> > $regDate returns false, with an && this would abort evaluation immediately
> > but with an or it would mean that startDate > endDate is evaluated and so
> > presumably it is this bit that is throwing the NPE.  I’d imagine that the
> > most likely reason for this would be that endDate is null.
> >
> >
> >
> > Try changing it too
> >
> > Segment ( startDate < $regDate || (endDate != null && startDate > endDate) )
> >
> > And see whether you loose the NPE.
> >
> >
> >
> > Thomas
> >
> >
> >
> > From: [hidden email] [mailto:[hidden email]] On Behalf Of dhari
> > Sent: 23 February 2010 06:15
> > To: [hidden email]
> > Subject: [rules-users] Comparing Date with || OR operator
> >
> >
> >
> > The following code generates NPE in ReteTuple.java
> >
> > rule
> >
> >when
> >
> >   Membership ( $regDate : regDate)
> >
> >   Segment ( startDate < $regDate || startDate > endDate )
> >
> > then
> >
> > System.err.print(“Invalid start date”);
> >
> > end
> >
> > I am new in Drools and don’t know much about DRL scripting. It works fine I
> > use && operator instead.
> >
> > 
> >
> > View this message in context: Comparing Date with || OR operator
> > Sent from the Drools - User mailing list archive at Nabble.com.
> >
> > 
> > **
> > This message is confidential and intended only for the addressee. If you
> > have received this

Re: [rules-users] Comparing Date with || OR operator

2010-02-23 Thread Shabbir Dhari

Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate ) 
even does not work. I am using verstion 5.0.1. All dates are java.util.Date and 
values in sample fact are:

regDate = Fri Aug 01 00:00:00 BST 2008
startDate =  Tue Sep 01 00:00:00 BST 2009
endDate = Fri Jul 30 00:00:00 BST 2010

Stack trace: 

java.lang.NullPointerException
at org.drools.reteoo.LeftTuple.get(LeftTuple.java:265)
at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300)
at 
org.drools.rule.VariableRestriction$ObjectVariableContextEntry.updateFromTuple(VariableRestriction.java:320)
at 
org.drools.rule.AbstractCompositeConstraint$MultiFieldConstraintContextEntry.updateFromTuple(AbstractCompositeConstraint.java:305)
at 
org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:119)
at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:109)
at 
org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)
at 
org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:78)
at 
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142)
at 
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
at 
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
at 
org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:192)
at 
au.gov.nsw.osr.zena.rules.AnnualRulesTester.main(AnnualRulesTester.java:57)


> Date: Tue, 23 Feb 2010 12:54:46 +0100
> From: wolfgang.l...@gmail.com
> To: rules-users@lists.jboss.org
> Subject: Re: [rules-users] Comparing Date with || OR operator
> 
> Please try this rewrite of the 2nd CE:
>Segment ( $endDate : endDate, startDate < $regDate || startDate > $endDate 
> )
> and report the outcome to the list, together with the Dools version
> you are using.
> Thank you.
> 
> 
> 2010/2/23 dhari :
> > Hi Thomas
> >
> > Thanks your prompt reply. I am sure all three attributes are NOT null. I
> > have tested them before sending question to mailing list. If you want, I can
> > send complete sample code and you can try it at your end.
> >
> > Regards,
> > Dhari
> >
> >
> > 
> > Date: Tue, 23 Feb 2010 02:50:08 -0800
> > From: [hidden email]
> > To: [hidden email]
> > Subject: Re: Comparing Date with || OR operator
> >
> > If it works fine with an and operator then I’d imagine that startDate <
> > $regDate returns false, with an && this would abort evaluation immediately
> > but with an or it would mean that startDate > endDate is evaluated and so
> > presumably it is this bit that is throwing the NPE.  I’d imagine that the
> > most likely reason for this would be that endDate is null.
> >
> >
> >
> > Try changing it too
> >
> > Segment ( startDate < $regDate || (endDate != null && startDate > endDate) )
> >
> > And see whether you loose the NPE.
> >
> >
> >
> > Thomas
> >
> >
> >
> > From: [hidden email] [mailto:[hidden email]] On Behalf Of dhari
> > Sent: 23 February 2010 06:15
> > To: [hidden email]
> > Subject: [rules-users] Comparing Date with || OR operator
> >
> >
> >
> > The following code generates NPE in ReteTuple.java
> >
> > rule
> >
> >when
> >
> >   Membership ( $regDate : regDate)
> >
> >   Segment ( startDate < $regDate || startDate > endDate )
> >
> > then
> >
> > System.err.print(“Invalid start date”);
> >
> > end
> >
> > I am new in Drools and don’t know much about DRL scripting. It works fine I
> > use && operator instead.
> >
> > 
> >
> > View this message in context: Comparing Date with || OR operator
> > Sent from the Drools - User mailing list archive at Nabble.com.
> >
> > 
> > **
> > This message is confidential and intended only for the addressee. If you
> > have received this message in error, please immediately notify the [hidden
> > email] and delete it from your system as well as any copies. The content of
> > e-mails as well as traffic data may be monitored by NDS for employment and
> > security purposes. To protect the environment please do not print this
> > e-mail unless necessary.
> >
> > NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18
> > 4EX, United Kingdom. A company registered in England and Wales. Registered
> > no. 3080780. VAT no. GB 603 8808 40-00
> > **

Re: [rules-users] Using Collections in LHS

2010-02-23 Thread Shabbir Dhari



Hi W



I know about case sensitivity issue. How can I combine both Order and Item in
one condition. I tried all possibilities but getting syntax error.



For example: 
Order ($items : items, $discount : discount > 10, Item(grade > 3)
from $items) // gives error


Can please code this condition correctly for me?

Dhari



Date: Tue, 23 Feb 2010 13:43:01 +0100
From: wolfgang.l...@gmail.com
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Using Collections in LHS

Discount is a field of Order and must not appear in an Item(...).
Probably you want:
   Order  ( $discount : Discount > 10,...

Also, most likely, all your fields need to be written with a lower case initial 
letter,

   Order  ( $discount : discount > 10, $items : items)

-W

On Tue, Feb 23, 2010 at 1:11 PM, dhari  wrote:



In this scenario I do have typical Order and Items data structure. I want to

implement various business rules where I want to check both Order attributes

and Item attributes together.



Order [ Date, Discount, Amount, Customer, Type, Items]

Item [ Quantity, Rate, ExpiresDate, Grade ]



I am trying to implements following rules but all gives me syntax error. I

wondering if someone can help me in.





rule “one”

when

Order  ( $discount : Discount, $items : Items)

Item ($discount > 10 && Grade > 3) from $items

then

System.err.print(“Discount is not allowed with items having grade 3 or

higher)

end



rule “two”

when

Order  ( $discount : Discount, $items : Items)

Item ($discount  > 20 || Quantity < 5 ) from $items

then

//do some thinge

end

--

View this message in context: 
http://n3.nabble.com/Using-Collections-in-LHS-tp386923p386923.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


  
_
Link all your email accounts and social updates with Hotmail. Find out now
http://windowslive.ninemsn.com.au/oneinbox?ocid=T162MSN05A0710G___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Formula value assginment in LHS

2009-07-02 Thread Shabbir Dhari

Dear all

We are developing a financial business application that contains hundreds of 
business rules for validations and calculations. In the calculation rules we 
change the value of attribute if values past in the request is incorrect e.g.  

rule "TaxCalc"
when
 $i : Invoice()
 Invoice (totalTax != (round(salesTax + (gstRate * salesAmount / 100) + 
importDuty – govtRebate, 2)))
then
 i.setTotalTax(round(salesTax + (gstRate * salesAmount / 100) + 
importDuty – govtRebate, 2));
end

The above code works perfectly fine. Only problem is the perform calculation 
twice. What I was looking if possible I can store calculated tax in a variable 
and simply assign variable to attribute if rule condiation fails. Some thing 
like:

rule "TaxCalc"
when
$i : Invoice() 
Invoice (totalTax != calTax : (round(salesTax + (gstRate * salesAmount 
/ 100)+ importDuty – govtRebate, 2)))
then
i.setTotalTax(calTax);
end

But this does not work - shows system error at calculated value assignment. Is 
there any work around?


_
POP access for Hotmail is here! Click here to find out more
http://windowslive.ninemsn.com.au/article.aspx?id=802246___
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 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 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 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-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] RuleBase deserialization throws NPE

2009-04-21 Thread Shabbir Dhari

Yes - definitely I am using the same version otherwise I'd have exception in 
every transaction. But I am getting this very inconsistently. I doubt there is 
a bug in RuleBase dieselisation.
 
> From: krishna.bham...@qwest.com
> To: rules-users@lists.jboss.org
> Date: Tue, 21 Apr 2009 06:29:05 -0600
> Subject: RE: [rules-users] RuleBase deserialization throws NPE
> 
> Normally I get this when there is a version incompatibility between Guvnor 
> and the clients. Are you using the same Drools jar versions on both sides?
> 
> -Original Message-
> From: rules-users-boun...@lists.jboss.org 
> [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of dhai
> Sent: Monday, April 20, 2009 8:59 PM
> To: rules-users@lists.jboss.org
> Subject: [rules-users] RuleBase deserialization throws NPE
> 
> 
> We have application that has two parts. One is for authoring the rules and 
> deploying RuleBase into database. Second reads that sterilized RuleBase from 
> database and evaluate the rules. I am randomly getting NPE while I 
> desterilize RuleBase. Its very inconsistent. The test data and environment in 
> same. Once I get one NPE while performing 2000 transactions and second time I 
> receive same exception after 500 transactions. The first test was executed in 
> single threaded and second was in multi threaded. 
> 
> I was wondering if some one else had encounter same problem. There trace is:
> 
> at java.lang.Thread.run(Thread.java:595)
> Caused by: java.lang.NullPointerException 
> at
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1820) 
> at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1719) 
> at
> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305) 
> at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348) 
> at
> org.drools.common.AbstractRuleBase.doReadExternal(AbstractRuleBase.java:257) 
> at
> org.drools.reteoo.ReteooRuleBase.readExternal(ReteooRuleBase.java:151) 
> at
> java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1755) 
> at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1717) 
> at
> java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305) 
> at java.io.ObjectInputStream.readObject(ObjectInputStream.java:348) 
> at
> net.dharis.net.rules.RulesResolverImpl.resolveFor(RulesResolverImpl.java:48)
> --
> View this message in context: 
> http://www.nabble.com/RuleBase-deserialization-throws-NPE-tp23147611p23147611.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

_
Looking to change your car this year? Find car news, reviews and more 
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fsecure%2Dau%2Eimrworldwide%2Ecom%2Fcgi%2Dbin%2Fa%2Fci%5F450304%2Fet%5F2%2Fcg%5F801459%2Fpi%5F1004813%2Fai%5F859641&_t=762955845&_r=tig_OCT07&_m=EXT___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users