Tuesday, October 23, 2018

#660 - OIC --> using the OPA adapter

OPA = Oracle Policy Automation



Oracle Policy Automation is an end-to-end solution for capturing, managing, and deploying complex legislation and other document-based policies across channels and processes. Oracle Policy Automation is an end-to-end solution for capturing, managing, and deploying complex legislation and other document-based policies across channels and processes.

One creates process models in OPA - these contain the business logic - from the docs -
Oracle Policy Modeling is a desktop application used to build interactive interviews based on business requirements, complex policy and legislation. It can be used for modeling:
  • Policy eligibility
    • For example, determining whether a contact is eligible for a benefit, permit, loan, discount, license, product upgrade or parental leave.
  • Calculations
    • For example, determining a contact’s rate of benefit, allowance, deduction, tax, discount, waiting period or follow-up.

Essentially we will pass in a payload to OPA and it will process it via the policy model I select, then return a result.

As an OPA neophyte, I have worked out that it has two main parts -

1. the Policy Modeling Tool - which you download to a Windows machine.
This is where you design the policies.

2. OPA Hub - for policy model management and deployment.









A colleague has kindly created a simple policy model for me - OIC_test.
The policy is very simple -




















The order will be approved, once I pass in those 3 attributes.




As you can see, he has checked Web Services - Assess - so what is that?

From the docs -

The generic assess service uses supplied data to determine one or more outcomes, 
can work out what additional data is needed to reach a conclusion, 
and provides reports on how decisions were reached.

OIC_test will simply assess an incoming purchase order and return an approval value -
true or false.

Creating the OIC Integration with OPA

I create the following integration in OIC -





































Test is the Invoke of OPA.

The OPA Connection is defined as follows -

































The Access Token URI = OPA Hub URL/opa-hub/api/auth

Note the OAuth requirements - for this, some preparatory steps in OPA are required -























Full setup info -

OPA Adapter Guide here
Supplementary OPA doc for Integration here
OPA REST API here


Now to the mapping -












Let's look at it in detail -



















OPA processes cases, think of a social welfare entitlement case and the complex rules
that need to be applied to it.
As already explained, my simple example processes a purchase order case.
Note the outcomes field - This structure contains the case field(s) which will hold the response from OPA. In my simple example, this is the order_approved field. Again, as already mentioned, OPA will return a value of true or false.
The orderId, order_date and order_value fields are all related to the purchase order I will be validating.

The final field, id, is the case unique id field and needs to be set. I just set it to the orderId.

Now to the response mapping -
















As you can see, I map the order_approved field to my result field.

Now to testing, via Postman -




















Very succinct!

No comments: