Understand the Use of Aliases In Rules
When you want to reason with more than one instance of the same entity in Policy Modeling rules, it can become ambiguous regarding which entity instances your rules are referring to. For example, consider you have a policy model where "the person" is an entity with the attribute "the person’s age". There is a relationship from "the person" to "the person" called "the person’s partner".
Consider the following rule:
the person is the same age as the person’s partner if
the person has a partner and
ForScope(the person's partner)
the person’s age = the person’s age
This rule is intending to refer to two separate instances of the person entity, the instance that is the first person and the instance that is that person’s partner. The second reference to "the person’s age" in this rule is intending to refer to the partner’s age but without an alternative way to refer to the attribute "the person’s age", this distinction is lost.
Aliasing allows you to use an alternative name to refer to the second entity instance to remove this ambiguity. The rule is correctly written using an alias as:
the person is the same age as the person’s partner if
the person has a partner and
ForScope(the person's partner, the partner)
the person’s age = the partner’s age
Tip: To see these alias rules in action, open the Alias example in Oracle Policy Modeling.
An alias can be defined in a scope entity function (ExistsScope, and so on) and in a relationship conclusion. The alias can then be used in place of a relationship in another rule function, but its use is limited to that particular conclusion or condition. That is, it cannot be used in other rules without again stating the alias. The name of an entity cannot be used as an alias.
Note: There are some language-specific considerations when using aliases in entity rules. For more information, see Write Rules In Other Languages.