Doh! Thanks Greg, i didn&#39;t realize it was on dev.<br><br>Yes, there should be joins if there are multiple Facts. I am used to people here just asserting one object and reasoning over it;  because you know, rule engines aren&#39;t good at handling many facts ;)<br>
<br><div class="gmail_quote">On Tue, Feb 24, 2009 at 1:34 PM, Greg Barton <span dir="ltr">&lt;<a href="mailto:greg_barton@yahoo.com">greg_barton@yahoo.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
David, please don&#39;t take this to be picking on you, but the rule you wrote wasn&#39;t quite correct. :)<br>
<br>
when<br>
       $f : Fact()<br>
       Detail(fact == $f, name == &quot;END_SET&quot;, value == true)<br>
       Detail(fact == $f, name == &quot;SET&quot;, value = 1)<br>
       Detail(fact == $f, name == &quot;PLAYER1_SCORE&quot;, $score1 : value)<br>
       Detail(fact == $f, name == &quot;PLAYER2_SCORE&#39;, value &lt; $score1)<br>
then<br>
...<br>
end<br>
<br>
Match the Details to their parent Fact.  I just want to make sure the newb doesn&#39;t get a combinatorial explosion and run screaming. :)<br>
<br>
And, not picking on both of you, but this should be on rules-users and not rules-dev.<br>
<br>
--- On Tue, 2/24/09, David Sinclair &lt;<a href="mailto:dsinclair@chariotsolutions.com">dsinclair@chariotsolutions.com</a>&gt; wrote:<br>
<br>
&gt; From: David Sinclair &lt;<a href="mailto:dsinclair@chariotsolutions.com">dsinclair@chariotsolutions.com</a>&gt;<br>
<div class="Ih2E3d">&gt; Subject: Re: [rules-dev] Dealing with null pointer exceptions thrown by  parsing rules<br>
</div>&gt; To: &quot;Rules Dev List&quot; &lt;<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>&gt;<br>
&gt; Date: Tuesday, February 24, 2009, 12:13 PM<br>
<div><div></div><div class="Wj3C7c">&gt; Alex, please don&#39;t take this to be picking on you; this<br>
&gt; is more a post to<br>
&gt; everyone whom reads these forums.<br>
&gt;<br>
&gt; You are not writing procedural, object-oriented, or<br>
&gt; functional code. You are<br>
&gt; writing rules to look for patterns of objects. If<br>
&gt; everything is done in an<br>
&gt; eval you are losing the majority of the benefits of using a<br>
&gt; rule engine, e.g<br>
&gt; node sharing, indexing, etc. Flesh out your object model.<br>
&gt; Assert all of your<br>
&gt; objects into Working Memory. This will allow you to reason<br>
&gt; over anything<br>
&gt; without using evals.<br>
&gt;<br>
&gt; OK -- rant off --<br>
&gt;<br>
&gt; Alex, you may want to try and refactor your model to be<br>
&gt; more &quot;rules<br>
&gt; friendly&quot;. That way your could write rules more like<br>
&gt; the following.<br>
&gt;<br>
&gt; when<br>
&gt;        $f : Fact()<br>
&gt;        Detail(name == &quot;END_SET&quot;, value == true)<br>
&gt;        Detail(name == &quot;SET&quot;, value = 1)<br>
&gt;        Detail(name == &quot;PLAYER1_SCORE&quot;, $score1 :<br>
&gt; value)<br>
&gt;        Detail(name == &quot;PLAYER2_SCORE&#39;, value &lt;<br>
&gt; $score1)<br>
&gt;<br>
&gt; On Tue, Feb 24, 2009 at 12:39 PM, Zevenbergen, Alex &lt;<br>
&gt; <a href="mailto:azevenbergen@paddypower.com">azevenbergen@paddypower.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt;  Thanks for replying.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; rule &quot;Player 1 wins first set &quot;<br>
&gt; &gt;<br>
&gt; &gt;     when<br>
&gt; &gt;<br>
&gt; &gt;       $f : Fact()<br>
&gt; &gt;<br>
&gt; &gt; eval<br>
&gt; ($f.getDetails().get(&quot;END_SET&quot;).toString() ==<br>
&gt; &quot;true&quot; &amp;&amp;<br>
&gt; Integer.valueOf($f.getDetails().get(&quot;SET&quot;).toString())<br>
&gt; &gt; == 1 &amp;&amp;<br>
&gt; Integer.valueOf($f.getDetails().get(&quot;PLAYER1_SCORE&quot;).toString())<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; Integer.valueOf($f.getDetails().get(&quot;PLAYER2_SCORE&quot;).toString()))<br>
&gt; &gt;<br>
&gt; &gt;     then<br>
&gt; &gt;<br>
&gt; &gt;       //then settle selection;<br>
&gt; &gt;<br>
&gt; &gt; end<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; this rules runs perfectly as long as the hashmap<br>
&gt; contained in the ‘fact’<br>
&gt; &gt; object has all the required keys and their values are<br>
&gt; not null. For the time<br>
&gt; &gt; being I have just changed any null values to a value<br>
&gt; of ‘DEFAULT’ but it<br>
&gt; &gt; would be preferable to be able to look for<br>
&gt; f.getDetails().get(&quot;END_SET&quot;) (for<br>
&gt; &gt; example) knowing that the engine that sent it might<br>
&gt; not be in an end_set<br>
&gt; &gt; state so may not have added that key.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; That example is very basic but as I create more rules<br>
&gt; for more sports it<br>
&gt; &gt; could become very cumbersome to have to ensure that<br>
&gt; every key referenced in<br>
&gt; &gt; the rules is in the hashmap each time!<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Alex<br>
&gt; &gt;  ------------------------------<br>
&gt; &gt;<br>
&gt; &gt; *From:* <a href="mailto:rules-dev-bounces@lists.jboss.org">rules-dev-bounces@lists.jboss.org</a> [mailto:<br>
&gt; &gt; <a href="mailto:rules-dev-bounces@lists.jboss.org">rules-dev-bounces@lists.jboss.org</a>] *On Behalf Of<br>
&gt; *David Sinclair<br>
&gt; &gt; *Sent:* 24 February 2009 17:27<br>
&gt; &gt; *To:* Rules Dev List<br>
&gt; &gt; *Subject:* Re: [rules-dev] Dealing with null pointer<br>
&gt; exceptions thrown by<br>
&gt; &gt; parsing rules<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; I understand what you are saying Alex, but could you<br>
&gt; post an example rule<br>
&gt; &gt; to see exactly how you are doing it? It may be that<br>
&gt; you could simply rewrite<br>
&gt; &gt; the rule so you don&#39;t get the NPE.<br>
&gt; &gt;<br>
&gt; &gt; On Tue, Feb 24, 2009 at 4:24 AM, Zevenbergen, Alex<br>
&gt; &lt;<br>
&gt; &gt; <a href="mailto:azevenbergen@paddypower.com">azevenbergen@paddypower.com</a>&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt; Hi all,<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; I have started writing my rules packages and so have<br>
&gt; had a decent amount of<br>
&gt; &gt; success. However all my rules are based on value pairs<br>
&gt; from a hashmap object<br>
&gt; &gt; that is contained within my fact object. This approach<br>
&gt; works fine if the<br>
&gt; &gt; parameter the rule is looking for is in the map and<br>
&gt; has a value.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; But I will need to be able to pass null values to the<br>
&gt; rules (and expect<br>
&gt; &gt; them to just not fire any rule that looks for that<br>
&gt; param), however this<br>
&gt; &gt; always throws a null pointer exception.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; So my question is: Is there any mechanism to deal with<br>
&gt; this in drools.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Simply setting all nulls to a default value isn’t<br>
&gt; preferable in this<br>
&gt; &gt; situation as the app is going to be used by several<br>
&gt; different sources and<br>
&gt; &gt; has to be able to take in many different types of<br>
&gt; info.<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Thanking you,<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Alex<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; ________________________________________________________________________<br>
&gt; &gt; Privileged, confidential and/or copyright information<br>
&gt; may be contained in<br>
&gt; &gt; this communication. This e-mail and any files<br>
&gt; transmitted with it are<br>
&gt; &gt; confidential and intended solely for the use of the<br>
&gt; individual or entity to<br>
&gt; &gt; whom they are addressed. If you are not the intended<br>
&gt; addressee, you may not<br>
&gt; &gt; copy, forward, disclose or otherwise use this e-mail<br>
&gt; or any part of it in<br>
&gt; &gt; any way whatsoever. To do so is prohibited and may be<br>
&gt; unlawful. If you have<br>
&gt; &gt; received this email in error<br>
&gt; &gt; please notify the sender immediately.<br>
&gt; &gt;<br>
&gt; &gt; Paddy Power PLC may monitor the content of e-mail sent<br>
&gt; and received for the<br>
&gt; &gt; purpose of ensuring compliance with its policies and<br>
&gt; procedures.<br>
&gt; &gt;<br>
&gt; &gt; Paddy Power plc, Airton House, Airton Road, Tallaght,<br>
&gt; Dublin 24 Registered<br>
&gt; &gt; in Ireland: 16956<br>
&gt; &gt;<br>
&gt; ________________________________________________________________________<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; rules-dev mailing list<br>
&gt; &gt; <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; ________________________________________________________________________<br>
&gt; &gt; Privileged, confidential and/or copyright information<br>
&gt; may be contained in<br>
&gt; &gt; this communication. This e-mail and any files<br>
&gt; transmitted with it are<br>
&gt; &gt; confidential and intended solely for the use of the<br>
&gt; individual or entity to<br>
&gt; &gt; whom they are addressed. If you are not the intended<br>
&gt; addressee, you may not<br>
&gt; &gt; copy, forward, disclose or otherwise use this e-mail<br>
&gt; or any part of it in<br>
&gt; &gt; any way whatsoever. To do so is prohibited and may be<br>
&gt; unlawful. If you have<br>
&gt; &gt; received this email in error<br>
&gt; &gt; please notify the sender immediately.<br>
&gt; &gt;<br>
&gt; &gt; Paddy Power PLC may monitor the content of e-mail sent<br>
&gt; and received for the<br>
&gt; &gt; purpose of ensuring compliance with its policies and<br>
&gt; procedures.<br>
&gt; &gt;<br>
&gt; &gt; Paddy Power plc, Airton House, Airton Road, Tallaght,<br>
&gt; Dublin 24 Registered<br>
&gt; &gt; in Ireland: 16956<br>
&gt; &gt;<br>
&gt; ________________________________________________________________________<br>
&gt; &gt;<br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; rules-dev mailing list<br>
&gt; &gt; <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; _______________________________________________<br>
&gt; rules-dev mailing list<br>
&gt; <a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</div></div></blockquote></div><br>