I agree - my mistake, Because of tests I&#39;ve forgotten to delete &#39;X&#39;... So it&#39;s not the case... Sorry...<br>But did another try and when I&#39;ve used<br><br>rule &quot;Check Object A and Set Default&quot;<br>

dialect &quot;mvel&quot;<br><br>It was not working correctly. Then I moved to:<br><br>
rule &quot;Check Object A and Set Default&quot;<br>
dialect &quot;java&quot;<br><br>and it works fine. So it is ok if we will change Mike&#39;s &#39;NOT WORKING&#39; example to:<br><br>--------------------------------------------------<br>package com.sample<br><br>import com.sample.ObjectA<br>
import org.drools.WorkingMemory<br><br>function void insertDefault(WorkingMemory workingMemory) {<br>  SomeDefault someDefault = new SomeDefault();<br>  someDefault.setMinValueA(100);<br>  someDefault.setMinValueB(20.0);<br>
  someDefault.setMaxValueB(20000.0);<br>  workingMemory.insert(someDefault);<br>}<br><br>declare SomeDefault<br>  minValueA : Integer<br>  minValueB : Double<br>  maxValueB : Double<br>end<br><br>rule &quot;Check Object A and Set Default&quot;<br>
  dialect &quot;java&quot;<br>  agenda-group &quot;Foo&quot;<br>  salience 100<br>  when<br>    $a : ObjectA()<br>  then<br>    insertDefault(drools.getWorkingMemory());<br>end<br><br>rule &quot;Use the defaults&quot;<br>
  dialect &quot;mvel&quot;<br>  agenda-group &quot;Foo&quot;<br>  salience 90<br>  when<br>    $default : SomeDefault()<br>  then<br>    System.out.println(&quot;Default minA=&quot; + $default.minValueA)<br>end<br>--------------------------------------------------<br>
<br>Any ideas why?<br><br><div class="gmail_quote">2011/12/30 Mauricio Salatino <span dir="ltr">&lt;<a href="mailto:salaboy@gmail.com" target="_blank">salaboy@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
One is SomeDefault and the other one is SomeDefaultX.<br>
The Declared type, as far as I remember overrides the to string with<br>
the representation that you are seeing there:<br>
<div>SomeDefault( minValueA=100, minValueB=20.0, maxValueB=20000.0 )<br>
</div>What is SomeDefaultX??<br>
Cheers<br>
2011/12/29 Maciej Gowin &lt;<a href="mailto:maciej.abacus.gowin@gmail.com" target="_blank">maciej.abacus.gowin@gmail.com</a>&gt;:<br>
<div><div>&gt; I did some debbuging with &#39;declare SomeDefault&#39;. This is what I found:<br>
&gt;<br>
&gt; CASE1: RHS = drools.getWorkingMemory().insert(new SomeDefaultX())<br>
&gt; Working memory objects:<br>
&gt; Object[fact<br>
&gt; 0:2:<a href="tel:2082419441" value="+12082419441" target="_blank">2082419441</a>:<a href="tel:2082419441" value="+12082419441" target="_blank">2082419441</a>:2:DEFAULT:com.sample.SomeDefaultX@7c1f32f1]<br>
&gt; Object[fact 0:1:140683595:140683595:1:DEFAULT:com.sample.ObjectA@862a94b]<br>
&gt;<br>
&gt; CASE2: RHS = insertDefault(drools.getWorkingMemory())<br>
&gt; Working memory objects:<br>
&gt; Object[fact 0:2:176338845:1:2:DEFAULT:SomeDefault( minValueA=100,<br>
&gt; minValueB=20.0, maxValueB=20000.0 )]<br>
&gt; Object[fact 0:1:1125048577:1125048577:1:DEFAULT:com.sample.ObjectA@430ee101]<br>
&gt;<br>
&gt; Please note the difference between DEFAULT:com.sample.SomeDefault and<br>
&gt; DEFAULT:SomeDefault.<br>
&gt; So when inserting an object to WorkingMemory inside function insertDefault<br>
&gt; which is declared in DRL file<br>
&gt; something strange is going on... It seems like it is a bug. It is worth<br>
&gt; mentioning that I get following result<br>
&gt; inside insertDefault:<br>
&gt; System.out.println(SomeDefault.class.getName());<br>
&gt; ---&gt; com.sample.SomeDefault<br>
&gt;<br>
&gt; Hope it will help :)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; 2011/12/30 Maciej Gowin &lt;<a href="mailto:maciej.abacus.gowin@gmail.com" target="_blank">maciej.abacus.gowin@gmail.com</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; Of course it&#39;s only my guess. I&#39;m not an expert. Please correct me if I&#39;m<br>
&gt;&gt; wrong :)<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; 2011/12/30 Maciej Gowin &lt;<a href="mailto:maciej.abacus.gowin@gmail.com" target="_blank">maciej.abacus.gowin@gmail.com</a>&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; It&#39;s not the different WorkingMemory. It&#39;s all about class name<br>
&gt;&gt;&gt; confusion. It looks like the class type does not match.<br>
&gt;&gt;&gt; Please try to create SomeDefault in standard way, not with &#39;declare&#39;<br>
&gt;&gt;&gt; statement. It works ok.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; 2011/12/30 Mike Key &lt;<a href="mailto:mikey@zenbitz.com" target="_blank">mikey@zenbitz.com</a>&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I guess that is exactly my confusion :)  Why would it be that doing the<br>
&gt;&gt;&gt;&gt; exact same thing, one inserting into working memory from a function and the<br>
&gt;&gt;&gt;&gt; other simply doing it within the RHS of the rule cause downstream rules not<br>
&gt;&gt;&gt;&gt; to fire in the function call case?  The rules are both in the same<br>
&gt;&gt;&gt;&gt; agenda-group, both the function example and the insert from the RHS of the<br>
&gt;&gt;&gt;&gt; rule example are simply inserting a new fact into working memory.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; It makes it seem like the function call is somehow inserting into a<br>
&gt;&gt;&gt;&gt; *different* working memory, which I&#39;m sure is not the case, but the<br>
&gt;&gt;&gt;&gt; downstream rule does not fire none-the-less.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Thanks for any clarity.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On Thu, Dec 29, 2011 at 3:59 PM, Mauricio Salatino &lt;<a href="mailto:salaboy@gmail.com" target="_blank">salaboy@gmail.com</a>&gt;<br>
&gt;&gt;&gt;&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Agenda-groups segment the agenda and not the working memory :)<br>
&gt;&gt;&gt;&gt;&gt; Probably that is part of your confusion.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; 2011/12/29 Mike Key &lt;<a href="mailto:mikey@zenbitz.com" target="_blank">mikey@zenbitz.com</a>&gt;:<br>
&gt;&gt;&gt;&gt;&gt; &gt; I am a fairly new Drools user and am trying to understand how working<br>
&gt;&gt;&gt;&gt;&gt; &gt; memory<br>
&gt;&gt;&gt;&gt;&gt; &gt; is segmented when using agenda groups.  I have an agenda-group that<br>
&gt;&gt;&gt;&gt;&gt; &gt; has<br>
&gt;&gt;&gt;&gt;&gt; &gt; focus set immediately from the session as follows with a few objects<br>
&gt;&gt;&gt;&gt;&gt; &gt; being<br>
&gt;&gt;&gt;&gt;&gt; &gt; inserted:<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; ksession.insert(objectA);<br>
&gt;&gt;&gt;&gt;&gt; &gt; ksession.insert(objectB);<br>
&gt;&gt;&gt;&gt;&gt; &gt; ksession.getAgenda().getAgendaGroup(&quot;Foo&quot;).setFocus();<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; I have 2 rules simplified down to illustrate my confusion.  The first<br>
&gt;&gt;&gt;&gt;&gt; &gt; rule<br>
&gt;&gt;&gt;&gt;&gt; &gt; simply sets some default values evaluated in the second rule if<br>
&gt;&gt;&gt;&gt;&gt; &gt; objectA<br>
&gt;&gt;&gt;&gt;&gt; &gt; exists.  In the example that works I set the defaults in the RHS<br>
&gt;&gt;&gt;&gt;&gt; &gt; explicitly.<br>
&gt;&gt;&gt;&gt;&gt; &gt;  However I want to use these defaults from different agenda-groups,<br>
&gt;&gt;&gt;&gt;&gt; &gt; so when<br>
&gt;&gt;&gt;&gt;&gt; &gt; I put them in a function, the second rule never fires, the activation<br>
&gt;&gt;&gt;&gt;&gt; &gt; is<br>
&gt;&gt;&gt;&gt;&gt; &gt; created for the first rule but never the second.  Can someone tell me<br>
&gt;&gt;&gt;&gt;&gt; &gt; why<br>
&gt;&gt;&gt;&gt;&gt; &gt; the use of a function seems to alter the truth of the rule?<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; THIS WORKS:<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; declare SomeDefault<br>
&gt;&gt;&gt;&gt;&gt; &gt;   minValueA : Integer<br>
&gt;&gt;&gt;&gt;&gt; &gt;   minValueB : Double<br>
&gt;&gt;&gt;&gt;&gt; &gt;   maxValueB : Double<br>
&gt;&gt;&gt;&gt;&gt; &gt; end<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; rule &quot;Check Object A and Set Default&quot;<br>
&gt;&gt;&gt;&gt;&gt; &gt;   agenda-group &quot;Foo&quot;<br>
&gt;&gt;&gt;&gt;&gt; &gt;   salience 100<br>
&gt;&gt;&gt;&gt;&gt; &gt;   when<br>
&gt;&gt;&gt;&gt;&gt; &gt;     $a : ObjectA()<br>
&gt;&gt;&gt;&gt;&gt; &gt;   then<br>
&gt;&gt;&gt;&gt;&gt; &gt;     default = new SomeDefault()<br>
&gt;&gt;&gt;&gt;&gt; &gt;     default.minValueA = 100<br>
&gt;&gt;&gt;&gt;&gt; &gt;     default.minValueB = 20.0<br>
&gt;&gt;&gt;&gt;&gt; &gt;     default.maxValueB = 20000.0<br>
&gt;&gt;&gt;&gt;&gt; &gt;     insert(default)<br>
&gt;&gt;&gt;&gt;&gt; &gt; end<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; rule &quot;Use the defaults&quot;<br>
&gt;&gt;&gt;&gt;&gt; &gt;   agenda-group &quot;Foo&quot;<br>
&gt;&gt;&gt;&gt;&gt; &gt;   salience 100<br>
&gt;&gt;&gt;&gt;&gt; &gt;   when<br>
&gt;&gt;&gt;&gt;&gt; &gt;     $default : SomeDefault()<br>
&gt;&gt;&gt;&gt;&gt; &gt;   then<br>
&gt;&gt;&gt;&gt;&gt; &gt;     System.out.println(&quot;Default minA=&quot; + $default.minValueA)<br>
&gt;&gt;&gt;&gt;&gt; &gt; end<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; THIS DOES NOT WORK:<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; declare SomeDefault<br>
&gt;&gt;&gt;&gt;&gt; &gt;   minValueA : Integer<br>
&gt;&gt;&gt;&gt;&gt; &gt;   minValueB : Double<br>
&gt;&gt;&gt;&gt;&gt; &gt;   maxValueB : Double<br>
&gt;&gt;&gt;&gt;&gt; &gt; end<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; rule &quot;Check Object A and Set Default&quot;<br>
&gt;&gt;&gt;&gt;&gt; &gt;   agenda-group &quot;Foo&quot;<br>
&gt;&gt;&gt;&gt;&gt; &gt;   salience 100<br>
&gt;&gt;&gt;&gt;&gt; &gt;   when<br>
&gt;&gt;&gt;&gt;&gt; &gt;     $a : ObjectA()<br>
&gt;&gt;&gt;&gt;&gt; &gt;   then<br>
&gt;&gt;&gt;&gt;&gt; &gt;     insertDefault(drools.getWorkingMemory())<br>
&gt;&gt;&gt;&gt;&gt; &gt; end<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; rule &quot;Use the defaults&quot;<br>
&gt;&gt;&gt;&gt;&gt; &gt;   agenda-group &quot;Foo&quot;<br>
&gt;&gt;&gt;&gt;&gt; &gt;   salience 90<br>
&gt;&gt;&gt;&gt;&gt; &gt;   when<br>
&gt;&gt;&gt;&gt;&gt; &gt;     $default : SomeDefault()<br>
&gt;&gt;&gt;&gt;&gt; &gt;   then<br>
&gt;&gt;&gt;&gt;&gt; &gt;     System.out.println(&quot;Default minA=&quot; + $default.minValueA)<br>
&gt;&gt;&gt;&gt;&gt; &gt; end<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; function void insertDefault(WorkingMemory workingMemory) {<br>
&gt;&gt;&gt;&gt;&gt; &gt;   SomeDefault default = new SomeDefault();<br>
&gt;&gt;&gt;&gt;&gt; &gt;   default.setMinValueA(100);<br>
&gt;&gt;&gt;&gt;&gt; &gt;   default.setMinValueB(20.0);<br>
&gt;&gt;&gt;&gt;&gt; &gt;   default.setMaxValueB(20000.0);<br>
&gt;&gt;&gt;&gt;&gt; &gt;   workingMemory.insert(default);<br>
&gt;&gt;&gt;&gt;&gt; &gt; }<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; In the latter (non-working) example the first rule activates and then<br>
&gt;&gt;&gt;&gt;&gt; &gt; drools<br>
&gt;&gt;&gt;&gt;&gt; &gt; returns, it never even attempts to try to fire the second rule.<br>
&gt;&gt;&gt;&gt;&gt; &gt;  However in<br>
&gt;&gt;&gt;&gt;&gt; &gt; the working example BOTH rules fire as I would expect.  I am guessing<br>
&gt;&gt;&gt;&gt;&gt; &gt; this<br>
&gt;&gt;&gt;&gt;&gt; &gt; is a simple misunderstanding on my part.  Any assistance in<br>
&gt;&gt;&gt;&gt;&gt; &gt; understanding<br>
&gt;&gt;&gt;&gt;&gt; &gt; why this nuance doesn&#39;t seem to work would be greatly appreciated.<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; Thanks.<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; MiKey<br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt; &gt; _______________________________________________<br>
&gt;&gt;&gt;&gt;&gt; &gt; rules-users mailing list<br>
&gt;&gt;&gt;&gt;&gt; &gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt;&gt; &gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; --<br>
&gt;&gt;&gt;&gt;&gt;  - CTO @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a><br>
&gt;&gt;&gt;&gt;&gt;  - MyJourney @ <a href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a><br>
&gt;&gt;&gt;&gt;&gt;  - Co-Founder @ <a href="http://www.jugargentina.org" target="_blank">http://www.jugargentina.org</a><br>
&gt;&gt;&gt;&gt;&gt;  - Co-Founder @ <a href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;  - Salatino &quot;Salaboy&quot; Mauricio -<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt;&gt; rules-users mailing list<br>
&gt;&gt;&gt;&gt;&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; rules-users mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
&gt;<br>
<br>
<br>
<br>
--<br>
 - CTO @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a><br>
 - MyJourney @ <a href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a><br>
 - Co-Founder @ <a href="http://www.jugargentina.org" target="_blank">http://www.jugargentina.org</a><br>
 - Co-Founder @ <a href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br>
<br>
 - Salatino &quot;Salaboy&quot; Mauricio -<br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>