[rules-users] Re: Cause(LHS) of rule an query brings different results.

Tomasz Krzywicki tkrzywicki at gmail.com
Wed Aug 20 14:59:48 EDT 2008


Answering to myself but maybe somebody is interested ;)
Based on my experiments query should be rewritten to
encapsulate first order logic operations within one type brackets.

 query "my query"
    i:  Item(  ( x == "A" && q > 0)  ||  ( x == "B"  && q > 1 )  )

    //  ---- Lets forget about this part ;)
    //     $x: Ref( name=="Exp" ) and
    //     Item( x == "A", quantity > 0 ) from $x.items
 end

I still can not find a way to point to items directly inserted
into working memory or referenced as property ( Set of Items )
of other type - at the same time.

So far I am using rule to contribute to some temporary fact
and then retrieving and querying this fact. Not my preferable
solution but works :)

tk.


On Mon, Aug 18, 2008 at 5:15 PM, Tomasz Krzywicki <tkrzywicki at gmail.com> wrote:
> I have query and rule which have identical LHS or "cause"
> for some unknown for me reason my query returns only one Item
> while rule is fired multiple times showing multiple occurences of my
> desired facts.
>
> query "my query"
>    i:  Item( x == "A", q > 0 ) or
>        Item( x == "B", q > 1 ) or
>
>         $x: Ref( name=="Exp" ) and
>         Item( x == "A", quantity > 0 ) from $x.items
> end
>
>
> rule "my query test"
>  when
>    i:  Item( x == "A", q > 0 ) or
>        Item( x == "B", q > 1 ) or
>
>         $x: Ref( name=="Exp" ) and
>        Item( x == "A", quantity > 0 ) from $x.items
>  then
>        System.out.println ("FOUND: "+i);
> end
>
> There must be something fundamentally wrong in the approach I am
> taking ;)
>
> I am using drools 4.0.7
>
> Thanks in advance
>
> tk
>



More information about the rules-users mailing list