<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="ProgId" content="Word.Document"><meta name="Generator" content="Microsoft Word 10"><meta name="Originator" content="Microsoft Word 10"><link rel="File-List" href="file:///C:%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml"><!--[if gte mso 9]><xml>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml><![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
        {mso-style-name:"Table Normal";
        mso-tstyle-rowband-size:0;
        mso-tstyle-colband-size:0;
        mso-style-noshow:yes;
        mso-style-parent:"";
        mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
        mso-para-margin:0cm;
        mso-para-margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:10.0pt;
        font-family:"Times New Roman";}
</style>
<![endif]-->
<p class="OSRBodyText" style="">Guys,<br>
<br>
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.<br>
<br>
Membership ( $regDate : regDate) <br>
Segment ( startDate < $regDate || startDate.time > endDate.time ) <br>
<br>
It solves my problem but makes code bit ugly and lengthy.<br></p>
<br><hr id="stopSpelling">Date: Wed, 24 Feb 2010 07:43:04 -0800<br>From: <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=414223&i=0" target="_top" rel="nofollow">[hidden email]</a><br>To: <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=414223&i=1" target="_top" rel="nofollow">[hidden email]</a><br>Subject: Re: Comparing Date with || OR operator<br><br>
I just read you condition. You are building $endDate to
<br>Segment.endDate and than comparing Segment.startDate with $endDate
<br>what is same as comparing Segment.startDate with Segment.endDate ->
<br>transition principle.
<br><br>Pavel
<br><br><br>2010/2/24 Shabbir Dhari <<a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=0" rel="nofollow" target="_top" link="external">[hidden email]</a>>:
<div class="ecxshrinkable-quote"><div class='shrinkable-quote'><br>> Hi Pavel
<br>>
<br>> I really don’t understand what do you mean. I guess you didn’t read complete
<br>> thread carefully. Assigning endDate attribute in a variable and not using
<br>> that variable in condition make no sense to me.
<br>>
<br>> Shabbir
<br>>
<br>>
<br>>
<br>>> Date: Wed, 24 Feb 2010 10:54:24 +0100
<br>>> From: <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=1" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>>> To: <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=2" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>>> Subject: Re: [rules-users] Comparing Date with || OR operator
<br>>>
<br>>> What about:
<br>>> Membership ( $regDate : regDate)
<br>>> Segment ($endDate : endDate, startDate < $regDate || startDate >
<br>>> endDate )
<br>>>
<br>>> Logically startDate > endDate doesn't make sense but it should work ;-)
<br>>>
<br>>> Pavel
<br>>>
<br>>> 2010/2/24 Shabbir Dhari <<a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=3" rel="nofollow" target="_top" link="external">[hidden email]</a>>:
<br>>> > I tried with some thing different and it worked but I don’t want this as
<br>>> > I
<br>>> > have many collections in my data structure.
<br>>> >
<br>>> > //this works
<br>>> > Membership ( $regDate : regDate)
<br>>> > Segment ( $endDate : endDate )
<br>>> > Segment ( startDate < $regDate || startDate > $endDate )
<br>>> >
<br>>> > //this does NOT work
<br>>> > Membership ( $regDate : regDate)
<br>>> > Segment ($endDate : endDate, startDate < $regDate || startDate >
<br>>> > $endDate )
<br>>> >
<br>>> > ________________________________
<br>>> > From: <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=4" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>>> > To: <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=5" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>>> > Date: Tue, 23 Feb 2010 23:09:50 +0000
<br>>> > Subject: Re: [rules-users] Comparing Date with || OR operator
<br>>> >
<br>>> > Segment ( $endDate : endDate, startDate < $regDate || startDate >
<br>>> > $endDate )
<br>>> > even does not work. I am using verstion 5.0.1. All dates are
<br>>> > java.util.Date
<br>>> > and values in sample fact are:
<br>>> >
<br>>> > regDate = Fri Aug 01 00:00:00 BST 2008
<br>>> > startDate = Tue Sep 01 00:00:00 BST 2009
<br>>> > endDate = Fri Jul 30 00:00:00 BST 2010
<br>>> >
<br>>> > Stack trace:
<br>>> >
<br>>> > java.lang.NullPointerException
<br>>> > at org.drools.reteoo.LeftTuple.get(LeftTuple.java:265)
<br>>> > at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300)
<br>>> > at
<br>>> >
<br>>> > org.drools.rule.VariableRestriction$ObjectVariableContextEntry.updateFromTuple(VariableRestriction.java:320)
<br>>> > at
<br>>> >
<br>>> > org.drools.rule.AbstractCompositeConstraint$MultiFieldConstraintContextEntry.updateFromTuple(AbstractCompositeConstraint.java:305)
<br>>> > at
<br>>> >
<br>>> > org.drools.common.SingleBetaConstraints.updateFromTuple(SingleBetaConstraints.java:119)
<br>>> > at org.drools.reteoo.JoinNode.assertLeftTuple(JoinNode.java:109)
<br>>> > at
<br>>> >
<br>>> > org.drools.reteoo.SingleLeftTupleSinkAdapter.doPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:117)
<br>>> > at
<br>>> >
<br>>> > org.drools.reteoo.SingleLeftTupleSinkAdapter.createAndPropagateAssertLeftTuple(SingleLeftTupleSinkAdapter.java:78)
<br>>> > at
<br>>> >
<br>>> > org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:142)
<br>>> > at
<br>>> >
<br>>> > org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter.java:42)
<br>>> > at
<br>>> > org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:185)
<br>>> > at
<br>>> > org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:146)
<br>>> > at
<br>>> >
<br>>> > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1046)
<br>>> > at
<br>>> >
<br>>> > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1001)
<br>>> > at
<br>>> >
<br>>> > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:788)
<br>>> > at
<br>>> >
<br>>> > org.drools.reteoo.ReteooStatelessSession.execute(ReteooStatelessSession.java:192)
<br>>> > at
<br>>> >
<br>>> > au.gov.nsw.osr.zena.rules.AnnualRulesTester.main(AnnualRulesTester.java:57)
<br>>> >
<br>>> >
<br>>> >> Date: Tue, 23 Feb 2010 12:54:46 +0100
<br>>> >> From: <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=6" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>>> >> To: <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=7" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>>> >> Subject: Re: [rules-users] Comparing Date with || OR operator
<br>>> >>
<br>>> >> Please try this rewrite of the 2nd CE:
<br>>> >> Segment ( $endDate : endDate, startDate < $regDate || startDate >
<br>>> >> $endDate
<br>>> >> )
<br>>> >> and report the outcome to the list, together with the Dools version
<br>>> >> you are using.
<br>>> >> Thank you.
<br>>> >>
<br>>> >>
<br>>> >> 2010/2/23 dhari <<a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=8" rel="nofollow" target="_top" link="external">[hidden email]</a>>:
<br>>> >> > Hi Thomas
<br>>> >> >
<br>>> >> > Thanks your prompt reply. I am sure all three attributes are NOT
<br>>> >> > null. I
<br>>> >> > have tested them before sending question to mailing list. If you
<br>>> >> > want,
<br>>> >> > I can
<br>>> >> > send complete sample code and you can try it at your end.
<br>>> >> >
<br>>> >> > Regards,
<br>>> >> > Dhari
<br>>> >> >
<br>>> >> >
<br>>> >> > ________________________________
<br>>> >> > Date: Tue, 23 Feb 2010 02:50:08 -0800
<br>>> >> > From: [hidden email]
<br>>> >> > To: [hidden email]
<br>>> >> > Subject: Re: Comparing Date with || OR operator
<br>>> >> >
<br>>> >> > If it works fine with an and operator then I’d imagine that startDate
<br>>> >> > <
<br>>> >> > $regDate returns false, with an && this would abort evaluation
<br>>> >> > immediately
<br>>> >> > but with an or it would mean that startDate > endDate is evaluated
<br>>> >> > and
<br>>> >> > so
<br>>> >> > presumably it is this bit that is throwing the NPE. I’d imagine that
<br>>> >> > the
<br>>> >> > most likely reason for this would be that endDate is null.
<br>>> >> >
<br>>> >> >
<br>>> >> >
<br>>> >> > Try changing it too
<br>>> >> >
<br>>> >> > Segment ( startDate < $regDate || (endDate != null && startDate >
<br>>> >> > endDate) )
<br>>> >> >
<br>>> >> > And see whether you loose the NPE.
<br>>> >> >
<br>>> >> >
<br>>> >> >
<br>>> >> > Thomas
<br>>> >> >
<br>>> >> >
<br>>> >> >
<br>>> >> > From: [hidden email] [mailto:[hidden email]] On Behalf Of dhari
<br>>> >> > Sent: 23 February 2010 06:15
<br>>> >> > To: [hidden email]
<br>>> >> > Subject: [rules-users] Comparing Date with || OR operator
<br>>> >> >
<br>>> >> >
<br>>> >> >
<br>>> >> > The following code generates NPE in ReteTuple.java
<br>>> >> >
<br>>> >> > rule
<br>>> >> >
<br>>> >> > when
<br>>> >> >
<br>>> >> > Membership ( $regDate : regDate)
<br>>> >> >
<br>>> >> > Segment ( startDate < $regDate || startDate > endDate )
<br>>> >> >
<br>>> >> > then
<br>>> >> >
<br>>> >> > System.err.print(“Invalid start date”);
<br>>> >> >
<br>>> >> > end
<br>>> >> >
<br>>> >> > I am new in Drools and don’t know much about DRL scripting. It works
<br>>> >> > fine I
<br>>> >> > use && operator instead.
<br>>> >> >
<br>>> >> > ________________________________
<br>>> >> >
<br>>> >> > View this message in context: Comparing Date with || OR operator
<br>>> >> > Sent from the Drools - User mailing list archive at Nabble.com.
<br>>> >> >
<br>>> >> > ________________________________
<br>>> >> >
<br>>> >> >
<br>>> >> > **************************************************************************************
<br>>> >> > This message is confidential and intended only for the addressee. If
<br>>> >> > you
<br>>> >> > have received this message in error, please immediately notify the
<br>>> >> > [hidden
<br>>> >> > email] and delete it from your system as well as any copies. The
<br>>> >> > content
<br>>> >> > of
<br>>> >> > e-mails as well as traffic data may be monitored by NDS for
<br>>> >> > employment
<br>>> >> > and
<br>>> >> > security purposes. To protect the environment please do not print
<br>>> >> > this
<br>>> >> > e-mail unless necessary.
<br>>> >> >
<br>>> >> > NDS Limited. Registered Office: One London Road, Staines, Middlesex,
<br>>> >> > TW18
<br>>> >> > 4EX, United Kingdom. A company registered in England and Wales.
<br>>> >> > Registered
<br>>> >> > no. 3080780. VAT no. GB 603 8808 40-00
<br>>> >> >
<br>>> >> >
<br>>> >> > **************************************************************************************
<br>>> >> >
<br>>> >> > ________________________________
<br>>> >> > This message is confidential and intended only for the addressee. If
<br>>> >> > you
<br>>> >> > have received this message in error, please immediately notify the
<br>>> >> > [hidden
<br>>> >> > email] and delete it from your system as well as any copies. The
<br>>> >> > content
<br>>> >> > of
<br>>> >> > e-mails as well as traffic data may be monitored by NDS for
<br>>> >> > employment
<br>>> >> > and
<br>>> >> > security purposes.
<br>>> >> > To protect the environment please do not print this e-mail unless
<br>>> >> > necessary.
<br>>> >> >
<br>>> >> > An NDS Group Limited company. www.nds.com
<br>>> >> >
<br>>> >> > _______________________________________________
<br>>> >> > rules-users mailing list
<br>>> >> > [hidden email]
<br>>> >> > <a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" target="_top" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>> >> >
<br>>> >> >
<br>>> >> > ________________________________
<br>>> >> > View message @
<br>>> >> >
<br>>> >> >
<br>>> >> > <a href="http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p379447.html" rel="nofollow" target="_top" link="external">http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p379447.html</a><br>>> >> > To unsubscribe from Drools - Java Rules Engine, click here.
<br>>> >> >
<br>>> >> > ________________________________
<br>>> >> > Find your next place with Ninemsn property Looking for a place to
<br>>> >> > rent,
<br>>> >> > share or buy?
<br>>> >> > ________________________________
<br>>> >> > View this message in context: RE: Comparing Date with || OR operator
<br>>> >> > Sent from the Drools - User mailing list archive at Nabble.com.
<br>>> >> >
<br>>> >> > _______________________________________________
<br>>> >> > rules-users mailing list
<br>>> >> > <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=9" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>>> >> > <a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" target="_top" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>> >> >
<br>>> >> >
<br>>> >>
<br>>> >> _______________________________________________
<br>>> >> rules-users mailing list
<br>>> >> <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=10" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>>> >> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" target="_top" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>> >
<br>>> > ________________________________
<br>>> > Browse profiles for free! View photos of singles in your area.
<br>>> > ________________________________
<br>>> > Get straight to the Point Find a great deal on your next car.
<br>>> > _______________________________________________
<br>>> > rules-users mailing list
<br>>> > <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=11" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>>> > <a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" target="_top" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>> >
<br>>> >
<br>>>
<br>>> _______________________________________________
<br>>> rules-users mailing list
<br>>> <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=12" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" target="_top" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>
<br>> ________________________________
<br>> Get straight to the Point Find a great deal on your next car.
<br>> _______________________________________________
<br>> rules-users mailing list
<br>> <a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=13" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" target="_top" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>
<br>>
</div></div>_______________________________________________
<br>rules-users mailing list
<br><a href="http://n3.nabble.com/user/SendEmail.jtp?type=node&node=413210&i=14" rel="nofollow" target="_top" link="external">[hidden email]</a>
<br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" rel="nofollow" target="_top" link="external">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br><br>
<hr color="#cccccc" size="1">
<div style="color: rgb(102, 102, 102); font-family: tahoma,geneva,helvetica,arial,sans-serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 11px; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">
View message @ <a href="http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p413210.html" target="_top" rel="nofollow" link="external">http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p413210.html</a>
<br>To unsubscribe from Drools - Java Rules Engine, <a target="_top" rel="nofollow" link="external">click here</a>.
</div>
<br>                                            <br /><hr />Find your next place with Ninemsn property <a href='http://clk.atdmt.com/NMN/go/157631292/direct/01/' target='_new' rel="nofollow" link="external">Looking for a place to rent, share or buy?</a>
<br><hr align="left" width="300">
View this message in context: <a href="http://n3.nabble.com/Comparing-Date-with-OR-operator-tp347656p414223.html">RE: Comparing Date with || OR operator</a><br>
Sent from the <a href="http://n3.nabble.com/Drools-User-f47000.html">Drools - User mailing list archive</a> at Nabble.com.<br>