Wolfgang, thanks much. Helps me understand what&#39;s going on under the hood a little better.<div><br></div><div>I&#39;m having a similar issue with the next higher container. I have say, PathElements which contain a collection of Ports. Same problem as before - if one Port goes down then the PathElement goes down. I can&#39;t seem to express it properly in DRL<br>
<br>The only thing that comes to me is:</div><div><br></div><div><div>rule &quot;pe down&quot;</div><div>    when</div><div>        // pe is active </div><div>    <span class="Apple-tab-span" style="white-space:pre">        </span>$pe : PathElement(state == State.UP )</div>
<div>    <span class="Apple-tab-span" style="white-space:pre">        </span>// and any one of the ports are down</div><div>    <span class="Apple-tab-span" style="white-space:pre">        </span>Port ( state == State.DOWN ) from $pe.ports</div>
<div>    then</div><div>    <span class="Apple-tab-span" style="white-space:pre">        </span>System.out.println(&quot;  setting pe down&quot;  + $pe );</div><div>    <span class="Apple-tab-span" style="white-space:pre">        </span>modify($pe) {</div>
<div>    <span class="Apple-tab-span" style="white-space:pre">                </span>setState( State.DOWN);</div><div>    <span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div>end</div><div><br></div><div>However, like my other naive attempts, it is not firing after the Notification is inserted into WM. I tried many variations using a &#39;collect&#39; clause, etc to no avail. Any additional insight would be greatly appreciated.</div>
<div><br></div><div>BTW, once i get a handle on the one-to-many associations I promise I&#39;ll stop :-)</div><div><br></div><div><br></div><div class="gmail_quote">On Mon, Apr 2, 2012 at 11:47 PM, Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">See inline.<br>
<div class="im"><br>
On 02/04/2012, Joe Zendle &lt;<a href="mailto:jzendle@zentechinc.net">jzendle@zentechinc.net</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; Here are my rules:<br>
&gt;<br>
&gt; rule &quot;card going down&quot;<br>
&gt;     when<br>
</div>       // There is a Card in state UP and...<br>
<div class="im">&gt;     $card : Card($name : name , state == State.UP)<br>
</div>      // a matching notification to DOWN<br>
<div class="im">&gt;         $notif : Notification( id == $name, type == NotificationType.CARD ,<br>
&gt; state == State.DOWN )<br>
&gt;     then<br>
&gt;     System.out.println(&quot;  got notification for card down &quot; + $card );<br>
&gt;     modify($card) {<br>
&gt;     setState(State.DOWN);<br>
&gt;     }<br>
&gt;     retract($notif);<br>
&gt; end<br>
&gt;<br>
&gt; // is the following rule correct??<br>
<br>
</div>No.<br>
<div class="im"><br>
&gt;<br>
&gt; rule &quot;port going down&quot;<br>
&gt;     when<br>
<br>
</div>     // There is a Port in State UP and...<br>
<div class="im"><br>
&gt;     $port : Port($name : name , state == State.UP, $card : card)<br>
</div>     // ...take its Card and if this is DOWN<br>
<div class="im"><br>
&gt;         Card ( state == State.DOWN) from $card<br>
&gt;     then<br>
&gt;     System.out.println(&quot;  port down because card is down  port: &quot; + $port +<br>
&gt; &quot; card: &quot; + $card );<br>
&gt;      modify($port) {<br>
&gt;     setState(State.DOWN);<br>
&gt;     }<br>
<br>
</div>The difference between these two rules is that the first one is triggered by<br>
a change in WM - the emergence of a matching Notification. The second,<br>
however, is evaluated when the Port enters WM, presumably with its<br>
Card in working order. Subsequently, Port doesn&#39;t change and so evaluation<br>
is never retried.<br>
<br>
<br>
Two correct versions:<br>
<br>
when<br>
$card : Card( state == State.DOWN )<br>
$port : Port($name : name , state == State.UP, card == $card)<br>
then<br>
<div class="im"><br>
when<br>
$port : Port($name : name , state == State.UP, $card: card )<br>
</div>           Card( this == $card, state == State.DOWN )<br>
then<br>
<br>
Or, assuming that Port must follow Card, for going UP and DOWN:<br>
<br>
when<br>
$card : Card( $stateCard: state )<br>
$port : Port($name : name , state != $stateCard, card == $card)<br>
then<br>
modify($port) {<br>
    setState($stateCard)<br>
<div><div class="h5">}<br>
<br>
<br>
&gt;<br>
&gt; end<br>
&gt;<br>
&gt; Here is the test case in a nutshell:<br>
&gt;<br>
&gt;  Port port1 = new Port();<br>
&gt; Port port2 = new Port();<br>
&gt;                         port1.setName(&quot;port1&quot;);<br>
&gt;  port2.setName(&quot;port2&quot;);<br>
&gt;<br>
&gt;                         Card card1 = new Card();<br>
&gt; card1.setName(&quot;port1 card1&quot;)<br>
&gt;                         port1.setCard(card1);<br>
&gt;                        // stateful session<br>
&gt;                         ksession.insert(port1);<br>
&gt; ksession.insert(port2);<br>
&gt; ksession.insert(card1);<br>
&gt;<br>
&gt; System.out.println(&quot;  firing rules&quot;);<br>
&gt; new Thread(new Runnable() {<br>
&gt; public void run() {<br>
&gt; ksession.fireUntilHalt();<br>
&gt; }<br>
&gt; }).start();<br>
&gt;<br>
&gt; System.out.println(&quot;*** injecting notification down&quot;);<br>
&gt; Notification notif = new Notification();<br>
&gt; notif.setType(NotificationType.CARD);<br>
&gt; notif.setState(State.DOWN);<br>
&gt; notif.setId(&quot;port1 card1&quot;);<br>
&gt; FactHandle notifHandle = ksession.insert(notif);<br>
&gt;<br>
&gt;<br>
&gt;                         ksession.halt();<br>
&gt;                         ksession.dispose()<br>
&gt;<br>
&gt;<br>
&gt; I would expect the card down notification to cause the port to do down by<br>
&gt; the second rule above but it does not fire.<br>
&gt;<br>
&gt; Here is output<br>
&gt;<br>
&gt;   card1: Card [state=UP, name=port1 card1,<br>
&gt; ne=org.plugtree.examples.model.NE@1e2670b]<br>
&gt; OBJECT ASSERTED value:Port [state=UP, name=port1, card=Card [state=UP,<br>
&gt; name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b]] factId: 1<br>
&gt; OBJECT ASSERTED value:Port [state=UP, name=port2, card=Card [state=UP,<br>
&gt; name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b]] factId: 3<br>
&gt; OBJECT ASSERTED value:Card [state=UP, name=port1 card1,<br>
&gt; ne=org.plugtree.examples.model.NE@1e2670b] factId: 5<br>
&gt;   firing rules<br>
&gt; 3<br>
&gt; *** injecting notification down<br>
&gt; ACTIVATION CREATED rule:card going down activationId:card going down [6, 5]<br>
&gt; declarations: $name=port1 card1(5);<br>
&gt; $notif=org.plugtree.examples.model.Notification@4a9a7d(6); $card=Card<br>
&gt; [state=UP, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b](5)<br>
&gt; OBJECT ASSERTED value:org.plugtree.examples.model.Notification@4a9a7dfactId:<br>
&gt; 6<br>
&gt; BEFORE ACTIVATION FIRED rule:card going down activationId:card going down<br>
&gt; [6, 5] declarations: $name=port1 card1(5);<br>
&gt; $notif=org.plugtree.examples.model.Notification@4a9a7d(6); $card=Card<br>
&gt; [state=UP, name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b](5)<br>
&gt;   got notification for card down Card [state=UP, name=port1 card1,<br>
&gt; ne=org.plugtree.examples.model.NE@1e2670b]<br>
&gt; OBJECT MODIFIED value:Card [state=DOWN, name=port1 card1,<br>
&gt; ne=org.plugtree.examples.model.NE@1e2670b] factId: 5<br>
&gt; OBJECT RETRACTED<br>
</div></div>&gt; value:org.plugtree.examples.model.Notification@4a9a7dfactId: 6<br>
<div class="im">&gt; AFTER ACTIVATION FIRED rule:card going down activationId:card going down<br>
&gt; [-1, 5] declarations: $name=port1 card1(5); $card=Card [state=DOWN,<br>
&gt; name=port1 card1, ne=org.plugtree.examples.model.NE@1e2670b](5)<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; Is the second rule written incorrectly? or do i have a gap in my<br>
&gt; expectations of how the engine should work (or both)<br>
&gt;<br>
&gt; Thanks in advance,<br>
&gt;<br>
&gt; Joe.<br>
&gt;<br>
</div>_______________________________________________<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>
</blockquote></div><br></div>