On 24/06/2011 21:22, Michael Anstis wrote:
Your test, Mark, is not the same example to which Wolfgang refers.

You'll need to re-test with the DRL at the end of Wolfgang's email (which is what we've included in N&N for 5.2).

It's quite possible one of the ?'s is simply wrong... but I don't understand the subtleties of BC syntax yet.
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"

Mark

With kind regards,

Mike

On 24 June 2011 21:14, Mark Proctor <mproctor@codehaus.org> wrote:
On 23/06/2011 13:20, Wolfgang Laun wrote:
Still not resolved...

I have added a test for all the possible insertion orders for that particular use case and was not able to reproduce a problem:
https://github.com/droolsjbpm/drools/commit/501f2196dcef754eed5a28b066b50665a5bc29a3

MArk
On 22 June 2011 21:40, Mark Proctor <mproctor@codehaus.org> wrote:
heh, I made a mistake with the rule
( Location(z, y;) and ?hasFood(x, z;) )
should be
( Location(z, y;) and hasFood(x, z;) )

Otherwise it's not reactive, and then ordering matters.

With that change I can do the insertions in any order and all is fine.


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:
You are in the table
  You can see []
  You can eat []

Insert Here after the others, and it works.

-W

 import java.util.List

declare Thing
    thing : String @key
end

declare Edible extends Thing
end

declare Location extends Thing
    location : String  @key
end

declare Here
    place : String
end   

rule kickOff
when
then
    System.out.println( "insert Here" );
    insert( new Here( "table" ) );
    System.out.println( "insert Edible" );
    insert( new Edible( "peach" ) );
    System.out.println( "insert Location" );
    insert( new Location( "peach", "table" ) );
end

# 2011-06-22
query isContainedIn( String x, String y )
    Location(x, y;)
    or
    ( Location(z, y;) and /*?*/isContainedIn(x, z;) )
end

query whereFood( String x, String y )
    ( Location(x, y;) and
    Edible(x;) )
    or
    ( Location(z, y;) and /*?*/whereFood(x, z;) )
end

query look(String place, List things, List food)
    Here(place;)
    things := List() from accumulate( Location(thing, place;),
                                      collectList( thing ) )
    food := List() from accumulate( /*?*/whereFood(thing, place;),
                                    collectList( thing ) )
end

rule reactiveLook
when
    Here( $place : place)
    /*?*/look($place, $things; $food := food)
then
    System.out.println( "You are in the " + $place);
    System.out.println( "  You can see " + $things );
    System.out.println( "  You can eat " + $food );
end

_______________________________________________ rules-dev mailing list


_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev


_______________________________________________ rules-dev mailing list rules-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-dev