5 Replies Latest reply: Apr 4, 2013 5:52 PM by Frank.Hampshire-Oracle RSS

    EnityInstance from an InferencingEvent

    Rajan.Panchal
      hi,
      there is a statement in developer help:

      Example: Handle rulebase events with an inferencing event listener
      --------------------------------------------------------------------------------
      The ruleInferenced() method receives an InferencingEvent object through which various properties are available, including the EntityInstance in which the event occurred.



      how can I come to know which entityInstance I would recieve from the InferencingEvent object?
      please help.

      Thanks,
        • 1. Re: EnityInstance from an InferencingEvent
          Frank.Hampshire-Oracle
          Rajan.Panchal wrote:
          hi,
          there is a statement in developer help:

          Example: Handle rulebase events with an inferencing event listener
          --------------------------------------------------------------------------------
          The ruleInferenced() method receives an InferencingEvent object through which various properties are available, including the EntityInstance in which the event occurred.



          how can I come to know which entityInstance I would recieve from the InferencingEvent object?
          please help.

          Thanks,
          A rule is always for an attribute (or relationship) which belongs to a entity. At run time these rules run against all existing instances of that entity.

          For example:

          the rule the person's age = the person's date of birth - the current date

          would infer the attribute "the person's age" on each person entity instance which exists.

          An InferencingEvent sent to an InferencingListener will have the entity instance context in which the rule is currently executing.

          In the example above, if there was 3 person entities, when the attribute "the person's age" is determined. You would expect an inferencing event for each entity instance.

          Typically these events fire during a think, when information that causes a rule to recalculate the value has changed.

          Back to the example; if person 2's DOB was previously unknown and becomes known, an event would fire with person 2 as the entity instance. If no other data had changed, we would not expect an event for person 1 or person 3.

          Hope this helps

          Cheers
          Frank

          Edited by: frank.hampshire on Jan 25, 2013 2:54 PM
          • 2. Re: EnityInstance from an InferencingEvent
            Rajan.Panchal
            Hi Frank!
            Thanks for the answer. Actually, I am using a custom event and its implementation is implementing the inferenceListerner. Can you please let me know how a custom event is called? IWhat i know is that a custom event can be called as below:

            RaiseEvent customEventName (attribute1,attribute2,..)
            the person's date of birth is known


            In this case what triggers the inferenceListner? Also, if there are cross entity conditions, then what would be the inferenceEvent entity?

            2. How can a customevent can be called in a loop?



            thanks,
            Rajan
            • 3. Re: EnityInstance from an InferencingEvent
              Frank.Hampshire-Oracle
              Rajan.Panchal wrote:
              Hi Frank!
              Thanks for the answer. Actually, I am using a custom event and its implementation is implementing the inferenceListerner. Can you please let me know how a custom event is called? IWhat i know is that a custom event can be called as below:

              RaiseEvent customEventName (attribute1,attribute2,..)
              the person's date of birth is known


              In this case what triggers the inferenceListner? Also, if there are cross entity conditions, then what would be the inferenceEvent entity?

              2. How can a customevent can be called in a loop?



              thanks,
              Rajan
              RaiseEvent customEventName (attribute1,attribute2,..)
              the person's date of birth is known


              In this case what triggers the inferenceListner? Also, if there are cross entity conditions, then what would be the inferenceEvent entity?
              I'm a little rusty on custom events, but from memory, the raiseevent will be triggered during a think cycle when the conditions evaluate to true.

              The entity associated with the event is established by the attributes (attribute1, attribute2...), which also forms the context for the event conditions. Cross entity conditions should not make a difference to the entity context of the event.

              In the case of your example event above for "the person" this event will fire for every person instance when its conditions first become true.

              I'm not sure how events interact with rule loops, but I can't think of where this would be useful, so I would avoid it.
              • 4. Re: EnityInstance from an InferencingEvent
                Rajan.Panchal
                what if there are two attributes of two different entity in the raiseveent..
                like..
                RaiseEvent customEventName (attribute1 of 1st entity,attribute2 of second entity,..)

                will both entites will be avaible in the implementation of this event..
                • 5. Re: EnityInstance from an InferencingEvent
                  Frank.Hampshire-Oracle
                  Because the raiseevent is a conclusion, you can only really reference one entity in the call (that event will be fired for all instances of the entity if the conditions are correct).

                  However in your event handler you have access to all the session information, so you should be able to access any information you want provided that you can navigate to it (using the engine API) from the instance which is the subject of the raise event.

                  Cheers
                  Frank