5 Replies Latest reply on Dec 21, 2012 12:49 AM by Matt Sevin-Oracle

    Unable to get value to global for same type of grand child

    Kunal Sharma
      Hi All,

      I have this problem related to requirement where I am unable to create a proper rules. My data modal is
      I have global as a grand parent entity
      global_child as a child entity of global
      grand_Child as a child entity of global_child

      The attribute in grand_child are Type which has preselect value as Typ1 Typ2 Typ3
      I need to write a rule on global to check all the grand_child are of same type or not If they are of same type I want to set the Type value to one of the global variable

      Say if they are of same type i will say in global grand_child are of single request type and there type is Typ1

      Kunal Sharma
        • 1. Re: Unable to get value to global for same type of grand child
          Matt Sevin-Oracle
          It is usually easier to provide guidance on rule specification when provided with the natural language policy that needs to be written. The natural language policies are usually easier to express when the policy model is well conceived. (i.e. the entities, relationships and attributes have well-understood and clear semantic meaning).

          For example, if global represents a household then "the heads of household" may be a 1-1 relationship from global and "the head of household's children" may be a 1 to many relationship from the head of household to the child. A natural language policy in this scenario may be "the household contains only adult children if all of the children are an adult". Such a policy can be expressed in OPM as:

          the household contains only adult children if
          __for all of the heads of household
          _____each of the head of household’s children is an adult
          • 2. Re: Unable to get value to global for same type of grand child
            Kunal Sharma
            Hi Matt,

            Thanks for your reply. Yes I appreciate the fact that we can get the check that all the grandchildren are of the same type to global very easily.

            The difficult part is getting the type of the grand children to the global.

            Considering there are two child's of global say child_a and child_b child_a has one child named as grandchild_a and child_b does not have any child instance getting the type of the grandchild_a to the global level is the most difficult part.

            Considering the fact that type of grandchild_a is selected using a dropdown which fetches the value from database and these type value may change in future.

            We will not like hard coading them or making some rule such as all are type_a instead we want to receive the same selected value which was selected in dropdown by user. specifying the OPA to pick any instance is the most difficult part even if we say select first instance of child_a and select first instance of grandchild_a somehow It leaves us with the fact user may not wish to add any child to child_a. This will give us unknown value for the type considering there is no instance existing from which we are selecting value. and OPA ignores the fact that no matter which instance value it picks it will all be same for all.


            Kunal Sharma
            • 3. Re: Unable to get value to global for same type of grand child
              Matt Sevin-Oracle
              Policies should express a declarative statement of truth, unlike programming languages which describe the steps or process for how to determine something. The former follow the pattern "this is true if .... " which itself declares a statement of fact. The later is more similar to "if ... then ... elseif .... then ... " which assumes conditions are evaluated in order and execution enters, skips and exits portions of the evaluation.

              Do you have the natural language policy or requirement you would like to write? (or are you provided with only the procedural requirement of what is supposed to happen as described in the example scenario?)

              A good approach to capturing policy expressions is to ask:
              - What is to be decided or known (i.e. the conclusion) - capture this as a conclusion using clearly stated descriptive natural language (e.g. the applicant is eligible for the annual benefit)
              - What is one combination of conditions that should lead to that conclusion? (e.g. all of the applicant's children are minors as of the end of the calendar year)
              - Are there other conditions under which that conclusion is also true, If so, what are they, ... repeat until all combination of conditions are known and captured.

              BTW - There is no need to hard code specific values as conditions in order to specify a condition that none, one, more or all, instances of an entity have the same value for the same attribute. (i.e. exists, each, counting of instances with a given condition are all possible within conditions of policies/rules).

              I believe the policy will be much easier to express if following the above approach using natural language entities, relationships and attributes rather than describing desired behavior with psuedo-code. If you try the above approach and still encounter questions, I am sure someone will be able to assist in the process of clarifying the policy using any necessary OPM rule structure and syntax.
              • 4. Re: Unable to get value to global for same type of grand child
                Kunal Sharma
                Ok Since you have asked for a policy I will state the same requirment in natural language policy. Infact this is the requirment which I have allready worked upon and created but the fact is I am not happy with the solution I provided though it works fine.

                So we have a global as an entity this contains case details below global there are client's as for one case ther can be multiple client's against a client there can be many or none request out of all the client there should be one primary client rest all are associated client. there is no restriction to the fact that primary client may or may not have any request associated with it a request may be of Get Credit or Get Debit or Get Mass now a case is said to be single request type if all the requests are of the same type lets just state that case category can be single or multiple request type based on whether all the requests are same or diffrent als the Case name should be the name of the type selected in Single request type for other the case name should be Mixed. Now can you please solve my problem.

                Kunal Sharma
                • 5. Re: Unable to get value to global for same type of grand child
                  Matt Sevin-Oracle
                  When I use the term "natural language policies", I am referring to policies (or rules) as might be written and understood within Oracle Policy Modeling and that follow recommendations for defining policy models, etc.. In other words, natural language policies should follow the "conclusion if conditions" structure, use terms and phrases that have clear semantic meaning, entity, relationship and attributes text should be well-defined, understood and comply with guidance for selecting terms and phrases as covered in both the OPM help and the OPM training courses. A few examples ... entities should be expressed with a leading "the" as in "the person", "the child", "the customer order", etc.; relationships typically use a plural to refer to the set and usually include possessive text for contained entities (i.e. "the customers", "the person's children", "the customer's current orders", etc.); attribute text for non-boolean attributes is ideally possessive (i.e. "the person's last name", "the child's age in years" etc.) When terms and phrases are clear, desired policies(rules) are much easier to capture, express and understand (i.e. "the person is eligible if all of the person's children are minors and ... or both ... and ... etc.).

                  *I believe the following may be similar to the scenario and policy you are attempting:*
                  - Entity global
                  - Entity "the order" contained by global (1->1 relationship from global to order "the orders")
                  - Entity "the line" contained by order (1->many relationship from the order to the line "the order's lines")
                  - Text attribute on "the line" using phrase "the line's text type"
                  - Text attribute on global "the only type of all lines on all orders"

                  *Desired natural language policy:*
                  - the only type of all lines on all orders is equal to the line's text type if all lines have the same value for the line's text type, otherwise the only type of all lines on all orders should be set to "Zero or Multiple"

                  - Define a new entity contained by global "the type" (Many->Many from global to the type "the types")
                  Note: This entity will be an inferred entity that represents the set of unique text type values across all lines of all orders

                  - Define a new relationship from "the line" to "the type" (Many->Many using the phrase "the line's types")
                  Note: This relationship will be inferred

                  - Write the policy: the line’s types (the line’s text type) exists
                  Note: This policy will infer both the existence of "the type" (identified by the "the line's text type") for each unique value of the line's text type
                  and will infer the instances participation in both relationships "the types" (from global to type) and "the line's types" (from the line to the type).

                  - Create a rule table with the conclusion "the only type of all lines on all orders"
                  - The first row, first column (conclusion value) will be "InstanceValueIf(the types, the type, the type = the type)"
                  Note: See documentation for syntax of this function, but essentially we are using the unique text identifier of "the type" to assign to the global text attribute.

                  - the first row second column (condition) will be "the number of the types = 1"
                  Note: See documentation for "InstanceCount" and the natural language form used here. this is important as this condition enforces the policy that the value should only be assigned to the global when there is 1 and only 1 text type for all lines.

                  - the second row, first column (conclusion value) "Zero or Multiple"
                  Note: this is a quoted string which was selected to make clear both remaining possible circumstances - that no lines may exist or more than 1 value may exist across all the line's text types

                  - the second row, second column (condition) "Otherwise"
                  Note: this is the default otherwise row as created when a rule table is added to a document