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.
<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> <root></div><div> <A id="1"></div>
<div> <B /></div><div> </A></div><div><div> <A id="2"></div><div> <B /></div><div> </A></div><div> </root></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'm trying a way to express the 'descendant' relationship in LHS construct.</div><div>The rule will look like:</div><div><br></div><div><div>rule "A requires B"</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>when</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>$fact1: NodeFact(id == "A", selected == true)</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>$fact2: NodeFact(id == "B", selected == false, this DESCENDANT-OF $fact1)</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>then</div><div><span class="Apple-tab-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 "DESCENDANT-OF" 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>