Christoph,<br>Just to clarify I am by no means a Drools expert so please keep this in mind when you read my advice.<br><br>Just to clarify, each Event you have has a bunch of EPC&#39;s.  Is this correct?  Are the EPC classes standard (i.e. no inheritance)?  If this is the case you could have a rule for processing your events and another rule for processing your EPCs.  Does this make sense?<br>
<br> rule &quot;Process Event&quot;<br>
      when<br>         $event: QuantityEventType()<br>          eval( $event.getEPC() != null )<br><div class="h5">
      then<br>         insert( EPC ) --- <b>I would insert each EPC into working memory.  This will then fire the rule below</b><br><br>
          System.out.println(&quot;BizLocation: &quot; +$bizLoc.getId());<br>
    end<br><br><b>rule</b> &quot;Process EPC&quot;<br>  <b>when</b> <br>     $epc: EPC()<br>  <b>then</b> <br>      //Do your EPC Specific logic here<br><b>      //Once you have done processing the EPC, I would remove it from working memory or it will fire the rule over again for the same EPC()</b><br>
     retract( $epc )<br><b>end</b><br></div><br><br>Not sure if this helps at all or not.<br><br>Shannon<br><br><br><div class="gmail_quote">On Thu, May 14, 2009 at 10:06 AM, Christoph Kramer <span dir="ltr">&lt;<a href="mailto:amrod@gmx.de">amrod@gmx.de</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;">Hi Shannon,<br>
yes all eventtypes inherit from a base class, but the superclass doesn&#39;t include all the attributes I want to acces in the rules. Unfortunately I can&#39;t modify the classes since they&#39;re part of a  library that i&#39;m using.<br>

Here is my intention:<br>
I get a bunch of different events and have to extract some data.<br>
Every event has a field with EPC&#39;s to which all the rest of the data belongs. I want to extract all the single EPC&#39;s with its related data.<br>
With pure Java the solution would be somethin like that:<br>
<br>
void handleObjectEvent(ObjectEventType p_objEvent){<br>
   List&lt;EPC&gt; epcs = p_objEvent.getEPC();<br>
   if(epc!=null){<br>
      for(EPC e : epcs){<br>
           if(p_objEvent.getBizLocation() !=null){<br>
               doSomething(e, p_objEvent.getBizLocation());<br>
           }<br>
                      if(p_objEvent.getBizStep() !=null){<br>
               doSomething(e, p_objEvent.getBizStep());<br>
           }<br>
<br>
           if(p_objEvent.getDisposition() !=null){<br>
               doSomething(e, p_objEvent.getDisposition());<br>
           }<br>
<br>
          ...<br>
          ...<br>
      }<br>
   }<br>
}<br>
<br>
For the other types of Events there would similar functions. Since there are a lot of if-statements in the functions I thougt that it would be nice to use rule engine instead.<br>
<br>
Greetings,<br>
Christoph<br>
<br>
<br>
Shannon Lal wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">
Christoph,<br>
I am not sure that this is a rules problem as it seems to be more of a Java problem.  Do you Event types all inherit from a base class?  Could you not just check to see on the base class is present?  Also, you might want to add in SMALL example of what you are trying to do in pure Java code (outside of Rules) as it might be easy to translate.<br>

<br>
Shannon<br>
<br></div><div><div></div><div class="h5">
On Thu, May 14, 2009 at 6:35 AM, Christoph Kramer &lt;<a href="mailto:amrod@gmx.de" target="_blank">amrod@gmx.de</a> &lt;mailto:<a href="mailto:amrod@gmx.de" target="_blank">amrod@gmx.de</a>&gt;&gt; wrote:<br>
<br>
    Hi all,<br>
    i&#39;ve some problems with a ClassCastException when using the<br>
    &quot;or&quot;-conditional element.<br>
    I have different Java-Beans which all have some string-values. Now<br>
    I want to create one rule which is able to handle every type of my<br>
    classes because it would be a lot of work to create one rule for<br>
    every class.<br>
    Depending on the type of beans in the working memory the programm<br>
    is crashing with an ClassCastException.<br>
<br>
    Here is a snippet of my drl-file with the &quot;crashing-rule&quot;:<br>
<br>
    rule &quot;BizLocation&quot;<br>
      when<br>
          $epc : EPC()<br>
          QuantityEventType(epcClass == $epc.value ,$bizLoc:<br>
    bizLocation !=null ) or AggregationEventType(childEPCs.epc<br>
    contains $epc, $bizLoc : bizLocation != null) or<br>
    ObjectEventType(epcList.epc  contains $epc, $bizLoc : bizLocation<br>
    != null)<br>
      then<br>
          System.out.println(&quot;BizLocation: &quot; +$bizLoc.getId());<br>
    end<br>
<br>
<br>
    There are some EPC&#39;s in the working memory and some Events (which<br>
    might be of type QuantityEventType, AggregationEventType or<br>
    ObjectEventType). When there are only ObjectEventType in the<br>
    working memory, everything works fine, but wenn there is an<br>
    QuantityEventType this rule crashes with<br>
    &quot;org.fosstrak.epcis.model.QuantityEventType cannot be cast to<br>
    org.fosstrak.epcis.model.ObjectEventType&quot;.<br>
    I&#39;ve lot of other, similar rules some of them crashing, others don&#39;t.<br>
<br>
<br>
    Can anyone give me a hint where is the error?<br>
<br>
    Thanks,<br>
    Christoph<br>
<br>
    PS: Sorry for the bad english :(<br>
    _______________________________________________<br>
    rules-users mailing list<br></div></div>
    <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a> &lt;mailto:<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>&gt;<div class="im">
<br>
    <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
<br></div>
------------------------------------------------------------------------<div class="im"><br>
<br>
_______________________________________________<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><div></div><div class="h5">
<br>
_______________________________________________<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>
</div></div></blockquote></div><br>