<div>Hi,</div><div><br></div><div>Is this what you are looking for?</div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><div>rule &quot;A requires B&quot;</div>

<div><span style="white-space: pre; ">        </span>when</div><div><span style="white-space: pre; ">                </span>$fact1: NodeFact(id == &quot;A&quot;, selected == true, $b: b)</div><div><span style="white-space: pre; ">                </span>$fact2: NodeFact(this == $b, selected == false,  this DESCENDANT-OF $fact1)</div>

<div><span style="white-space: pre; ">        </span>then</div><div><span style="white-space: pre; ">                </span>$fact2.setSelected(true);</div><div>end</div><div><br></div></span></div>Best,<br><br><div class="gmail_quote">2010/5/7 Giovanni Motta <span dir="ltr">&lt;<a href="mailto:mottagio@gmail.com">mottagio@gmail.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi all, i have a question concerning facts hierarchy, i&#39;m looking for some hint as i suppose the same problem could have been faced by someone on the list.
<div><br></div><div>I try to eplain with an example:</div><div><br></div><div>- Suppose to have a tree of facts, each object representing an UI widget.</div><div>   &lt;root&gt;</div><div>    &lt;A id=&quot;1&quot;&gt;</div>


<div>          &lt;B /&gt;</div><div>    &lt;/A&gt;</div><div><div>    &lt;A id=&quot;2&quot;&gt;</div><div>          &lt;B /&gt;</div><div>    &lt;/A&gt;</div><div>  &lt;/root&gt;</div><div><br></div><div>- The individual elements A(1), B, A(2), B are mapped to facts, that are inserted in a KnowledgeStatefulSession</div>


<div>- A rule exists that states that when an object A is selected, the B object is automatically selected</div><div>- An event occurs that causes selection of node A(1)</div><div><br></div><div>The expected result is, obviously, that only the B element that is descendant of A(1) must be automatically selected</div>


<div><br></div><div>I&#39;m trying a way to express the &#39;descendant&#39; relationship in LHS construct.</div><div>The rule will look like:</div><div><br></div><div><div>rule &quot;A requires B&quot;</div><div><span style="white-space:pre">        </span>when</div>


<div><span style="white-space:pre">                </span>$fact1: NodeFact(id == &quot;A&quot;, selected == true)</div><div><span style="white-space:pre">                </span>$fact2: NodeFact(id == &quot;B&quot;, selected == false,  this DESCENDANT-OF $fact1)</div>


<div><span style="white-space:pre">        </span>then</div><div><span style="white-space:pre">                </span>$fact2.setSelected(true);</div><div>end</div><div><br></div><div><br></div><div>
What is, in your opinion, the best way to handle this situation? What should replace the fake &quot;DESCENDANT-OF&quot; match?</div><div>Do i need to use a function that returns the list of descendant nodes of $fact1 and then match $fact2 against that? </div>


<div>Will this be fast when dealing with large trees?</div><div><br></div><div>Any suggestion will be appreciated, thank you.</div><div>Giovanni</div></div></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">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>
<br></blockquote></div><br><br clear="all"><br>-- <br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>