2 Replies Latest reply: Apr 23, 2013 6:08 PM by Frank.Hampshire-Oracle RSS

    Copying instance values from unrelated enitites in a rule table.

    Rajan.Panchal
      How to set values to an attribute of an entity 'C' with the value of an entity 'B' meeting specified conditions of entity 'A' and 'B' in a Rule Table.

      Note: there is no relation ship between A - C and C - B.
      But we use some attribute between 'A' and 'B' and 'c' as common.
      For Example:
      Entity A 'the person'
      Entity B 'the person's living places'

      Entity C 'the benefit'

      relationship A->B (one to Many)
      A->C (No relationship)
      B->C (No Relationship)

      I have instances of C for each instance of B and one instance of entity A which is parent to B

      Although there is not relationship between C and B, I have some identifers in B and C which is common.
      Example: the living places entities will have an distinct identifier (say 101111) for each instance and entity c will also have an identifer which will acts

      as a key(the same 101111) there by we can identify that benefit entity instance corresponds to so and so instance of entity B.

      Now I want to write a rule such that it copy value from intance 'B' into an attribute of an entity instance of 'C' where the identifer is same.
      I tried to write this rule but it gave me an error that the entity is not in scope.



      Can some one help me with this..?
        • 1. Re: Copying instance values from unrelated enitites in a rule table.
          Paul Fowler
          Disclaimer: I don't work for Oracle, and the expert staff at Oracle may have better methods of solving this problem.

          In general, it is my understanding that values are copied via "InstanceValueIf" function when you want a comparison.

          Assuming that the benefit and the person are related to global...
          Assuming that the relationships are the default relationships created (e.i. all instances of the person, and all instances of the person's living places for the person).
          Assuming that we have the following variables:
          the person's living places id, which we want to match to the benefit's living place id
          the person's living places type, which we want to copy into the benefit copied type

          I understand that a challenge is trying to traverse more than one relationship.

          However, the logic could be performed as follows:

          the benefit copied type =InstanceValueIf(all instances of the person, InstanceValueIf(all instances of the person's living places for the person, the person's living places type, the person's living places id = the benefit's living place id), Exists(all instances of the person's living places for the person, the person's living places id = the benefit's living place id))

          There may be a simpler solution, but part of the problem is created by lack of relationships.

          I have to add a few more disclaimers:

          I would caution that this rule is very developer centric and will be very hard for BAs to read. I would not normally write (or even need) this type of rule when writing rules from policy documents.

          Given the developer centric rule, it would be good to have a relationship between B and C (even inferred). This relationship can simplify the rules and readability. Lack of relationships can cause unexpected results applying the above rule when the identifying values are unknown/uncertain or when multiple entities have the same identifying values. Two people might have the same living place or a living place might not have an id. You may have to create a rule table to start handling exceptions when things are unknown, or when there are duplicates, and other situations that are a result of not checking referential integrity.
          • 2. Re: Copying instance values from unrelated enitites in a rule table.
            Frank.Hampshire-Oracle
            Rajan,

            when you want to write a rule to set a value on an instance derived from a value on another instance, you must be able to determine which instance you are talking about. In your example, to set a value on instance "C" (the benefit) based on instances 'A' the person and 'B' the person's living spaces, you need to be able to relate the person to the benefit.



            If there is one benefit (C) in a session and one person (A) then you can write simple rules because there is one person, so the relationship is obvious (there is only one person entity allowed, so this must the person)

            The below rule works because the relationship "all instances of the person" is a one-to-one relationship from the global, so I can write the rule knowing there can only be one person.
            The value of the benefit = For(all instances of the person, the person's value)
            .


            If I allow more than one person. then I have to be able to uniquely identify the person to get the value from. I can do this using the InstanceValueIf rule
            The benefit’s value = InstanceValueIf(all instances of the person, the person’s value, condition)
            The condition in the above statement must uniquely indentify the person so the value can be returned.


            Hope this helps

            Cheers
            Frank