7 Replies Latest reply: Apr 23, 2013 5:50 PM by Frank.Hampshire-Oracle RSS

    Creating infered entity instances

    Rajan.Panchal
      How can I create infered entity instances..in opa 10.4.
      When I am trying to write rule using the "exists" keyword.. its not compiling as "Infered
      Instance" but it compiles as normal conclusion.

      and how can I create inferred instances conditionally..
        • 1. Re: Creating infered entity instances
          Frank.Hampshire-Oracle
          You can either use the functional form
          InferInstance(<relationship>, <identity>)  if
             <condition>
          or the verbose version
          <relationship> (<indentity>) exists if
             <condition>
          Probably the easiest trap to fall into is to try to use the entity text instead of the relationship. The relationship to use is the relationship where the entity instances you want to create are the target. Usually this is the containment relationship from the parent to the entity instance.

          For example.

          Global --> all instances of the person --> the person

          The rule below creates an inferred entity with an id of "fred" if the boolean condition "the interview is for fred" is true"

          {code}
          InferInstance(all instances of the person, “fred”) if
          the interview is for fred
          {code}

          Cheers
          Frank
          • 2. Re: Creating infered entity instances
            Fiona Guy
            See help topic "Write rules that infer relationships and entities" (within OPM go to Help | OPM USer's Guide) - it has example rules (including inferring conditionally) and points you at 4 example projects provided with the install that show you how it's done :-)

            Edited by: Fiona Guy on Apr 5, 2013 9:48 AM
            • 3. Re: Creating infered entity instances
              Rajan.Panchal
              Hi,
              i am creating an entity instances using the statement...
              InferInstance(the person's employment,”1”) but I am getting error..
              "Inferred entity instances cannot be manually created"

              my rule base has below relationshiop..
              the person
              the person's employment.

              Now the person entity is created by java code and im trying to create the employment entity using the rulebase but i am getting the above error.
              any workaround or ideas..to achieve this...

              Thanks,
              Rajan

              Edited by: Rajan.Panchal on Apr 6, 2013 4:15 AM
              • 4. Re: Creating infered entity instances
                Frank.Hampshire-Oracle
                Is it possible that you are trying to manually add something to the employment entity after it has been inferred. When an entity is inferred, all its attributes, child entities and relationships including this entity must also be inferred.

                You cannot infer some aspects of an inferred entity and try to set others.

                Creating a instance using an inferencing listener and then inferring child entities of that instance is definitely possible.

                Cheers
                Frank
                • 5. Re: Creating infered entity instances
                  Rajan.Panchal
                  I have some base level attributes in the employment entity which i need to determine in rulebase and send it to java program..
                  and
                  what do you actually mean by
                  "Is it possible that you are trying to manually add something to the employment entity after it has been inferred. When an entity is inferred, all its attributes, child entities and relationships including this entity must also be inferred.

                  You cannot infer some aspects of an inferred entity and try to set others."
                  Can you please elaborate...

                  Edited by: Rajan.Panchal on Apr 7, 2013 8:31 PM
                  • 6. Re: Creating infered entity instances
                    Davin Fifield-Oracle
                    Rajan.Panchal wrote:You cannot infer some aspects of an inferred entity and try to set others. Can you please elaborate...
                    For example, you cannot prompt a user to supply values for an inferred entity instance. And you cannot provide entities in a SOAP API call for an entity that is inferred.
                    • 7. Re: Creating infered entity instances
                      Frank.Hampshire-Oracle
                      Sorry for the long delay in replying Rajan, I missed your request to elaborate.

                      To be specific:

                      When an entity instance is inferred that means that every attribute in it must also be inferred. The rule engine cannot cope with logic like: "this entity might or might not exist, but if it does, we need to ask for more information about it"

                      There are a few ways to deal with setting information in an inferred entity:

                      - most obviously infer any values from other entiy attributes in the session.
                      - set attribute values on related, non-inferred entities and then use rules infer those attributes on the inferred entity.

                      Its worth having a think about what the inferred entity instances means. If you want to use the rules as a convenient way to create an entity instance and you still need to set non-inferred attributes, then you are better off using an inferencing listener to create the instances.

                      If the instances are truly derivable from rules, then any attribute values of those instances are probably also derivable.

                      Cheers
                      Frank