Advanced Oracle Policy Automation – OPA Access Timeline Pattern
Disclaimer: There will be advanced concepts that require the reader to have a firm foundation in OPA.
OPA patterns show up over and over to solve problems such as the need for the shortest interviews, need for wizards, and need for calculators. In this blog post I will discuss what I refer to as my "OPA Access Timeline Pattern" used when temporal functions get in the way of substantive policy readability.
- Allow temporal attributes to be specified using natural language in substantive rules.
Temporal reasoning often seems complex to the uninitiated. It is the type of logic that grows very rusty with lack of use. Natural language, on the other hand is used in our day to day conversations. Natural language policy has many advantages over temporal functions such as being understood by the uninitiated.
We need a more natural form of temporal reasoning that uses the natural language advantages of Oracle Policy Modeling.
There is a method of creating many attributes temporally in substantive rules without referring to temporal functions. It is a technique known as accessing the temporal timeline. It can greatly reduce temporal function usage and increase readability of rules that rely on temporal logic.
The concept is quite simple. A date attribute is created that contains a change point every day from an earliest start date to a latest end date. In many cases, instead of using temporal functions, rules compare against this temporal date attribute using a natural language syntax.
There is an Oracle Forum Thread from a few years ago that describes this technique along with feedback from users in the community:
The structure adds two necessary components to a project:
1) Definition of the calendar date attribute such as:
the calendar date = AddDays(the global start date, TemporalDaysSince(the global start date, AddDays(the global end date,1)))
2) Rules that utilize the calendar date attribute such as:
the person's age = the number of whole years which the calendar date is after the person birth date
Attached is a project that demonstrates three methods of working with dates.
The first method uses traditional non-temporal logic (putting the word "standard" in each attribute name) such as:
The second method uses this OPA Access Timeline pattern (putting the word "daily" in each attribute name) such as:
The third method uses temporal functions(putting the word "computed" in each attribute name) such as:
Spreadsheets of holidays are included to demonstrate temporal logic differences in Excel.
1) Outside of the substantive rule document, create a calendar attribute.
2) Use the calendar attribute in natural language.
Rules of thumb
- This pattern is most effective when dates are being compared or otherwise manipulated in OPA.
Be careful, as too much use of this pattern can cause OPA to perform very slowly. Be judicious with temporal functions. Everything is an engineering tradeoff. In this case, the primary tradeoff is readability (and simplicity) vs performance.
The OPA development team has "under consideration" methods to provide natural language equivalents of temporal values. There have been several suggestions. However, Oracle is concerned that any added temporal natural-language feature may break existing natural language projects that are not temporal-based.