[rules-users] facts hierarchy

Esteban Aliverti esteban.aliverti at gmail.com
Fri May 7 13:16:01 EDT 2010


Ups sorry! I forgot to remove your part from the rule

It should be:

rule "A requires B"
when
$fact1: NodeFact(id == "A", selected == true, $b: b)
 $fact2: NodeFact(this == $b, selected == false)
then
$fact2.setSelected(true);
end

Best

On Fri, May 7, 2010 at 2:14 PM, Esteban Aliverti <esteban.aliverti at gmail.com
> wrote:

> Hi,
>
> Is this what you are looking for?
>
> rule "A requires B"
>  when
> $fact1: NodeFact(id == "A", selected == true, $b: b)
> $fact2: NodeFact(this == $b, selected == false,  this DESCENDANT-OF $fact1)
>  then
> $fact2.setSelected(true);
> end
>
> Best,
>
> 2010/5/7 Giovanni Motta <mottagio at gmail.com>
>
>> Hi all, i have a question concerning facts hierarchy, i'm looking for some
>> hint as i suppose the same problem could have been faced by someone on the
>> list.
>>
>> I try to eplain with an example:
>>
>> - Suppose to have a tree of facts, each object representing an UI widget.
>>    <root>
>>     <A id="1">
>>           <B />
>>     </A>
>>     <A id="2">
>>           <B />
>>     </A>
>>   </root>
>>
>> - The individual elements A(1), B, A(2), B are mapped to facts, that are
>> inserted in a KnowledgeStatefulSession
>> - A rule exists that states that when an object A is selected, the B
>> object is automatically selected
>> - An event occurs that causes selection of node A(1)
>>
>> The expected result is, obviously, that only the B element that is
>> descendant of A(1) must be automatically selected
>>
>> I'm trying a way to express the 'descendant' relationship in LHS
>> construct.
>> The rule will look like:
>>
>> rule "A requires B"
>> when
>>  $fact1: NodeFact(id == "A", selected == true)
>> $fact2: NodeFact(id == "B", selected == false,  this DESCENDANT-OF $fact1)
>>  then
>> $fact2.setSelected(true);
>> end
>>
>>
>> What is, in your opinion, the best way to handle this situation? What
>> should replace the fake "DESCENDANT-OF" match?
>> Do i need to use a function that returns the list of descendant nodes of
>> $fact1 and then match $fact2 against that?
>> Will this be fast when dealing with large trees?
>>
>> Any suggestion will be appreciated, thank you.
>> Giovanni
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
>



-- 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20100507/23df9076/attachment.html 


More information about the rules-users mailing list