Ups sorry! I forgot to remove your part from the rule
Hi,Is this what you are looking for?Best,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);end2010/5/7 Giovanni Motta <mottagio@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 selectedI'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);endWhat 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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Esteban Aliverti