<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 24/06/2011 21:22, Michael Anstis wrote:
    <blockquote
      cite="mid:BANLkTinG2cnOcGqQOx4bHUzdYFT2j76izg@mail.gmail.com"
      type="cite">Your test, Mark, is not the same example to which
      Wolfgang refers.<br>
      <br>
      You'll need to re-test with the DRL at the end of Wolfgang's email
      (which is what we've included in N&amp;N for 5.2).<br>
      <br>
      It's quite possible one of the ?'s is simply wrong... but I don't
      understand the subtleties of BC syntax yet.<br>
    </blockquote>
    If the query has "?" in it, then it's pull only. In which case the
    insertion order matters, as the query is triggered when Here or in
    below Person is triggered. Inserting the Location objects after the
    query is triggered will not return a result, unless you use leave
    off the "?" for a reactive "open query"<br>
    <br>
    Mark<br>
    <blockquote
      cite="mid:BANLkTinG2cnOcGqQOx4bHUzdYFT2j76izg@mail.gmail.com"
      type="cite">
      <br>
      With kind regards,<br>
      <br>
      Mike<br>
      <br>
      <div class="gmail_quote">On 24 June 2011 21:14, Mark Proctor <span
          dir="ltr">&lt;<a moz-do-not-send="true"
            href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <div text="#000000" bgcolor="#ffffff"> On 23/06/2011 13:20,
            Wolfgang Laun wrote:
            <blockquote type="cite">Still not resolved...<br>
              <br>
            </blockquote>
            I have added a test for all the possible insertion orders
            for that particular use case and was not able to reproduce a
            problem:<br>
            <a moz-do-not-send="true"
href="https://github.com/droolsjbpm/drools/commit/501f2196dcef754eed5a28b066b50665a5bc29a3"
              target="_blank">https://github.com/droolsjbpm/drools/commit/501f2196dcef754eed5a28b066b50665a5bc29a3</a><br>
            <br>
            MArk<br>
            <blockquote type="cite">
              <div>
                <div class="h5">On 22 June 2011 21:40, Mark Proctor <span
                    dir="ltr">&lt;<a moz-do-not-send="true"
                      href="mailto:mproctor@codehaus.org"
                      target="_blank">mproctor@codehaus.org</a>&gt;</span>
                  wrote:<br>
                  <div class="gmail_quote">
                    <blockquote class="gmail_quote" style="border-left:
                      1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt
                      0.8ex; padding-left: 1ex;"> heh, I made a mistake
                      with the rule<br>
                      <div>( Location(z, y;) and ?hasFood(x, z;) )<br>
                      </div>
                      should be<br>
                      <div>( Location(z, y;) and hasFood(x, z;) )<br>
                        <br>
                      </div>
                      Otherwise it's not reactive, and then ordering
                      matters.<br>
                      <br>
                      With that change I can do the insertions in any
                      order and all is fine.<br>
                      <br>
                    </blockquote>
                    <div><br>
                      This works for the example you gave. But the one
                      taken from the "Introduction" still depends on the
                      order the facts are inserted. Below is the .drl,
                      which does not need any pojos. Rule kickOff
                      contains the order that produces nothing to see
                      and eat:<br>
                      You are in the table<br>
                      &nbsp; You can see []<br>
                      &nbsp; You can eat []<br>
                      <br>
                      Insert Here after the others, and it works.<br>
                      <br>
                      -W<br>
                      <br>
                      &nbsp;import java.util.List<br>
                      <br>
                      declare Thing<br>
                      &nbsp;&nbsp;&nbsp; thing : String @key<br>
                      end<br>
                      <br>
                      declare Edible extends Thing<br>
                      end<br>
                      <br>
                      declare Location extends Thing<br>
                      &nbsp;&nbsp;&nbsp; location : String&nbsp; @key<br>
                      end<br>
                      <br>
                      declare Here<br>
                      &nbsp;&nbsp;&nbsp; place : String<br>
                      end&nbsp;&nbsp;&nbsp; <br>
                      <br>
                      rule kickOff<br>
                      when<br>
                      then<br>
                      &nbsp;&nbsp;&nbsp; System.out.println( "insert Here" );<br>
                      &nbsp;&nbsp;&nbsp; insert( new Here( "table" ) );<br>
                      &nbsp;&nbsp;&nbsp; System.out.println( "insert Edible" );<br>
                      &nbsp;&nbsp;&nbsp; insert( new Edible( "peach" ) );<br>
                      &nbsp;&nbsp;&nbsp; System.out.println( "insert Location" );<br>
                      &nbsp;&nbsp;&nbsp; insert( new Location( "peach", "table" ) );<br>
                      end<br>
                      <br>
                      # 2011-06-22<br>
                      query isContainedIn( String x, String y ) <br>
                      &nbsp;&nbsp;&nbsp; Location(x, y;)<br>
                      &nbsp;&nbsp;&nbsp; or <br>
                      &nbsp;&nbsp;&nbsp; ( Location(z, y;) and /*?*/isContainedIn(x,
                      z;) )<br>
                      end<br>
                      <br>
                      query whereFood( String x, String y )<br>
                      &nbsp;&nbsp;&nbsp; ( Location(x, y;) and<br>
                      &nbsp;&nbsp;&nbsp; Edible(x;) ) <br>
                      &nbsp;&nbsp;&nbsp; or <br>
                      &nbsp;&nbsp;&nbsp; ( Location(z, y;) and /*?*/whereFood(x, z;) )<br>
                      end<br>
                      <br>
                      query look(String place, List things, List food) <br>
                      &nbsp;&nbsp;&nbsp; Here(place;)<br>
                      &nbsp;&nbsp;&nbsp; things := List() from accumulate(
                      Location(thing, place;),<br>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; collectList(
                      thing ) )<br>
                      &nbsp;&nbsp;&nbsp; food := List() from accumulate(
                      /*?*/whereFood(thing, place;),<br>
                      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; collectList(
                      thing ) )<br>
                      end<br>
                      <br>
                      rule reactiveLook<br>
                      when<br>
                      &nbsp;&nbsp;&nbsp; Here( $place : place) <br>
                      &nbsp;&nbsp;&nbsp; /*?*/look($place, $things; $food := food)<br>
                      then<br>
                      &nbsp;&nbsp;&nbsp; System.out.println( "You are in the " +
                      $place);<br>
                      &nbsp;&nbsp;&nbsp; System.out.println( "&nbsp; You can see " + $things
                      );<br>
                      &nbsp;&nbsp;&nbsp; System.out.println( "&nbsp; You can eat " + $food
                      );<br>
                      end<br>
                      <br>
                    </div>
                  </div>
                </div>
              </div>
              <pre><fieldset></fieldset>
_______________________________________________
rules-dev mailing list
<div class="im"><a moz-do-not-send="true" href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a>
<a moz-do-not-send="true" href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
</div></pre>
            </blockquote>
            <br>
          </div>
          <br>
          _______________________________________________<br>
          rules-dev mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
          <a moz-do-not-send="true"
            href="https://lists.jboss.org/mailman/listinfo/rules-dev"
            target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
          <br>
        </blockquote>
      </div>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
rules-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>