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

2010-02-24 Thread dhari




Guys,



I don’t know if there is a bug in Drools while comparing Date attributes. I am
trying different things. Another finding is the following code works.



Membership ( $regDate : regDate) 

Segment ( startDate < $regDate || startDate.time > endDate.time ) 



It solves my problem but makes code bit ugly and lengthy.



Date: Wed, 24 Feb 2010 07:43:04 -0800
From: ml-node+413210-578640977-80...@n3.nabble.com
To: sdh...@hotmail.com
Subject: Re: Comparing Date with || OR operator



I just read you condition. You are building $endDate to

Segment.endDate and than comparing Segment.startDate with $endDate

what is same as comparing Segment.startDate with Segment.endDate ->

transition principle.


Pavel



2010/2/24 Shabbir Dhari <[hidden email]>:

> 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: [hidden email]

>> To: [hidden email]

>> 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 <[hidden email]>:

>> > 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: [hidden email]

>> > To: [hidden email]

>> > 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)

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

2010-02-24 Thread Pavel Tavoda
I just read you condition. You are building $endDate to
Segment.endDate and than comparing Segment.startDate with $endDate
what is same as comparing Segment.startDate with Segment.endDate ->
transition principle.

Pavel


2010/2/24 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:
>&

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-24 Thread Pavel Tavoda
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 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.
>

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 scri

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 

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

2010-02-23 Thread Wolfgang Laun
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
> **
>
> 
> 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.
>
> An NDS Group Limited company. www.nds.com
>
> ___
> rules-users mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
> 
> View message @
> http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p379447.html
> To unsubscribe from Drools - Java Rules Engine, click here.
>
> 
> Find your next place with Ninemsn property Looking for a place to rent,
> share or buy?
> 
> View this message in context: RE: Comparing Date with || OR operator
> 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] Comparing Date with || OR operator

2010-02-23 Thread Swindells, Thomas
Have you got the stack trace, that may give a clue? Also what are the actual 
values of start date and end date?

Thomas


From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of dhari
Sent: 23 February 2010 11:30
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Comparing Date with || OR operator

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]<http://n3.nabble.com/user/SendEmail.jtp?type=node&node=383423&i=0>
To: [hidden 
email]<http://n3.nabble.com/user/SendEmail.jtp?type=node&node=383423&i=1>
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
**

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.

An NDS Group Limited company. www.nds.com

___
rules-users mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/rules-users


View message @ 
http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p379447.html
To unsubscribe from Drools - Java Rules Engine, click here.


Find your next place with Ninemsn property Looking for a place to rent, share 
or buy?<http://clk.atdmt.com/NMN/go/157631292/direct/01/>

View this message in context: RE: Comparing Date with || OR 
operator<http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p383423.html>
Sent from the Drools - User mailing list 
archive<http://n3.nabble.com/Drools-User-f47000.html> 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 
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 com

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

2010-02-23 Thread 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: ml-node+379447-1511987735-80...@n3.nabble.com
To: sdh...@hotmail.com
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 rulewhen 
 Membership ( $regDate : regDate)  Segment ( startDate < $regDate 
|| startDate > endDate )thenSystem.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
**



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.

An NDS Group Limited company. www.nds.com

___ 
rules-users mailing list 
[hidden email] 
https://lists.jboss.org/mailman/listinfo/rules-users





View message @ 
http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p379447.html 
To unsubscribe from Drools - Java Rules Engine, click here. 
  
_
Looking for a place to rent, share or buy? Find your next place with ninemsn 
Property
http://clk.atdmt.com/NMN/go/157631292/direct/01/
-- 
View this message in context: 
http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p383423.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


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

2010-02-23 Thread Swindells, Thomas
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: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of dhari
Sent: 23 February 2010 06:15
To: rules-users@lists.jboss.org
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<http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p347656.html>
Sent from the Drools - User mailing list 
archive<http://n3.nabble.com/Drools-User-f47000.html> 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 
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 company. www.nds.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


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

2010-02-22 Thread dhari

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: 
http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p347656.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