Christoph,
Just to clarify I am by no means a Drools expert so please keep this in mind when you read my advice.

Just to clarify, each Event you have has a bunch of EPC'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?

 rule "Process Event"
     when
         $event: QuantityEventType()
          eval( $event.getEPC() != null )
     then
         insert( EPC ) --- I would insert each EPC into working memory.  This will then fire the rule below

         System.out.println("BizLocation: " +$bizLoc.getId());
   end

rule "Process EPC"
  when
     $epc: EPC()
  then
      //Do your EPC Specific logic here
      //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()
     retract( $epc )
end


Not sure if this helps at all or not.

Shannon


On Thu, May 14, 2009 at 10:06 AM, Christoph Kramer <amrod@gmx.de> wrote:
Hi Shannon,
yes all eventtypes inherit from a base class, but the superclass doesn't include all the attributes I want to acces in the rules. Unfortunately I can't modify the classes since they're part of a  library that i'm using.
Here is my intention:
I get a bunch of different events and have to extract some data.
Every event has a field with EPC's to which all the rest of the data belongs. I want to extract all the single EPC's with its related data.
With pure Java the solution would be somethin like that:

void handleObjectEvent(ObjectEventType p_objEvent){
  List<EPC> epcs = p_objEvent.getEPC();
  if(epc!=null){
     for(EPC e : epcs){
          if(p_objEvent.getBizLocation() !=null){
              doSomething(e, p_objEvent.getBizLocation());
          }
                    if(p_objEvent.getBizStep() !=null){
              doSomething(e, p_objEvent.getBizStep());
          }

          if(p_objEvent.getDisposition() !=null){
              doSomething(e, p_objEvent.getDisposition());
          }

         ...
         ...
     }
  }
}

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.

Greetings,
Christoph


Shannon Lal wrote:
Christoph,
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.

Shannon

On Thu, May 14, 2009 at 6:35 AM, Christoph Kramer <amrod@gmx.de <mailto:amrod@gmx.de>> wrote:

   Hi all,
   i've some problems with a ClassCastException when using the
   "or"-conditional element.
   I have different Java-Beans which all have some string-values. Now
   I want to create one rule which is able to handle every type of my
   classes because it would be a lot of work to create one rule for
   every class.
   Depending on the type of beans in the working memory the programm
   is crashing with an ClassCastException.

   Here is a snippet of my drl-file with the "crashing-rule":

   rule "BizLocation"
     when
         $epc : EPC()
         QuantityEventType(epcClass == $epc.value ,$bizLoc:
   bizLocation !=null ) or AggregationEventType(childEPCs.epc
   contains $epc, $bizLoc : bizLocation != null) or
   ObjectEventType(epcList.epc  contains $epc, $bizLoc : bizLocation
   != null)
     then
         System.out.println("BizLocation: " +$bizLoc.getId());
   end


   There are some EPC's in the working memory and some Events (which
   might be of type QuantityEventType, AggregationEventType or
   ObjectEventType). When there are only ObjectEventType in the
   working memory, everything works fine, but wenn there is an
   QuantityEventType this rule crashes with
   "org.fosstrak.epcis.model.QuantityEventType cannot be cast to
   org.fosstrak.epcis.model.ObjectEventType".
   I've lot of other, similar rules some of them crashing, others don't.


   Can anyone give me a hint where is the error?

   Thanks,
   Christoph

   PS: Sorry for the bad english :(
   _______________________________________________
   rules-users mailing list
   rules-users@lists.jboss.org <mailto:rules-users@lists.jboss.org> ------------------------------------------------------------------------


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
 

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users