<br><br><div class="gmail_quote">On 2 August 2010 12:14, 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="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Several remarks:<br>(1) Make sure that a parent is asserted after all of its children. Otherwise initial evaluation will not comprise the entire children&#39;s list.<br></blockquote><div><br>What I meant is: after all children have been adder to the parent&#39;s list, and *then* insert the parent.<br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">(2) After changing a child&#39;s state, update the parent.<br>
(3) The rule as you have it now is somewhat circumstantial. A simpler approach would be<br><br>rule NoUpChild<br>when<br>    $p : Device(  $children : <span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">eContents</span>, <span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">eContents</span>.size &gt; 0 )<br>

    not( Device( state == &quot;UP&quot; ) from $children )<br>then<br>    System.out.println( $p.getId() + &quot;: no child up&quot; );<br>end<br><br>(4) If you have a &quot;parent&quot; field, this could even be written:<br>

<br>rule NoUpChild<br>when<br>    $p : Device(   children.size &gt; 0 )<br>    not( Device( parent == $p, state == &quot;UP&quot; ) )<br>then<br>    System.out.println( $p.getId() + &quot;: no child up&quot; );<br>end<br>

<br></blockquote><div><br>And this would make the additional update according to (2) unnecessary.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
-W<br><br><br><br><div class="gmail_quote"><div class="im">2010/8/2 Georg Maier <span dir="ltr">&lt;<a href="mailto:Georg.Maier@cjt.de" target="_blank">Georg.Maier@cjt.de</a>&gt;</span><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">










<div link="blue" vlink="purple" lang="DE">

<div>

<p class="MsoNormal">Hi,</p><div><div></div><div class="h5">

<p class="MsoNormal"> </p>

<p class="MsoNormal"><span lang="EN-US">I’m trying to figure out an issue for
three days now and I’m getting kind of desperate, so I hope someone can
help.</span></p>

<p class="MsoNormal"><span lang="EN-US">I’m using Drools in combination with
an EMF model which is modeling a computer network. On init, I read the whole
structure of the model and insert all elements into the working memory. Some of
the entities share the super class “Device” which has an attribute “state”.</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">Now I’m having the following rule to
change an attribute of one of the model entities:</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">rule</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-US">&quot;Set
received status to model&quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">      </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">when</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            $event
: SomeEvent ( </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                  $hostname
: hostname,</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                  $hoststate
: hoststate,</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                  $timestamp
: timestamp</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            )</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            $device
: Device (</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                  name
== $hostname</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            )</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">      </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">then</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">modify</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">($device)
{</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                  setState($hoststate);</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            }</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            db.commit(</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">false</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">);</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                        </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">retract</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">($event);        </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            System.err.println(</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-US">&quot;Set
status of &quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> + $device + </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-US">&quot; to &quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> +
$hoststate);</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);">end</span></b><span lang="EN-US"></span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><span lang="EN-US">… which works perfectly fine. Anyway,
what I want to do in this test case is to <b>react whenever all child devices
of a mutual parent device</b> (e.g. hosts on one switch) are no longer reachable.
I thought of a rule like the following:</span></p>

<p class="MsoNormal"><span lang="EN-US"> </span></p>

<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">rule</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-US">&quot;Parent
Children Test&quot;</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">      </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">when</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">  </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            $parent
: Device (</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                  $children
: eContents,</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                  eContents.size
&gt; 0</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            )</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">forall</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> (</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                  $child
: Device (</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                        </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US">state ==
&quot;DOWN&quot;</span></p>

<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">                  )
</span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">from</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US"> $children</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            )</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">      </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">then</span></b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">        </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: black;" lang="EN-US">            </span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: olive;" lang="EN-US">…</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-US"></span></p>



<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">end</span></b></p>

<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US"> </span></b></p>

<p class="MsoNormal"><span lang="EN-US">… which by the way worked perfectly fine as long as I was not
using objects from a model. My first idea was that for some strange reason the
object might get copied so that I actually would have two different references
after modifying it, but this is not the case. When I initialize the rule base
with the circumstances that the second rule would fire, it really does. It just
seems as it would not being evaluated after changing the attribute, but this is
not the case either! So all I can think of is some strange caching, maybe in
combination with the </span><b><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: rgb(150, 0, 0);" lang="EN-US">forall </span></b><span lang="EN-US">statement?
Maybe someone has some experience when using Drools with EMF + CDO and
experienced as similar issue? </span></p>

<p class="MsoNormal"><span lang="EN-US">Any help would be very very very much appreciated! </span></p>

<p class="MsoNormal"><span style="font-size: 10pt;" lang="EN-US">Thanks
in advance</span></p>

<p class="MsoNormal"><span style="font-size: 10pt;" lang="EN-US"> </span></p><font color="#888888">

<p class="MsoNormal"><span style="font-size: 10pt;" lang="EN-US">Georg</span></p>

</font></div></div></div>

</div>


<br><div class="im">_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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></div></blockquote></div><br>
</blockquote></div><br>