Welcome to the OPA Hub!

Tag Archives: Workshop

OPA – Entities Adventures #8 IsMemberOf()

More Functions

Policy Automation has a vast array of Functions that can be called into service at one time or another. Many of them are very specific and we will try and discover a few more of them before the end of this series.

But we can take this opportunity to share with you a couple of “cheatsheets” that we give out sometimes in the Policy Automation training courses. These are PDF files with examples of lots of useful Functions from Oracle Policy Automation.

If you get Error 500 just click the Back button and try again

[stamper_download_button_for_wp_user file_url=”http://www.theopahub.com/mainfiles/OPAL/STRING/TextFunctions.pdf” button_text=”Download Text Functions Now”]

[stamper_download_button_for_wp_user file_url=”http://www.theopahub.com/mainfiles/OPAL/DATETIME/DateAndTime.pdf” button_text=”Download Date Time Functions Now”]

The Workshop

In this episode we will consider another key function

1) The IsMemberOf Function

This function can be useful in determining membership of a Reference Relationship. It is called “inferred membership”

To begin let us examine the scenario for the IsMemberOf function.


The IsMemberOf function (or “is a member of”) can be used in two different ways. Firstly as a conclusion, but also as a condition. Let us take a look at them both in a practical example.

Back at our Workshop we want to find out which cars are Italian, since they may require expert care and attention. We might be tempted to write something like this almost straight away, so simple this function sounds.

Hopefully you can see there is a problem. The New Attribute dialog box which appears when you click Compile is showing two boolean Attributes. That does not sound like what we need to make this work. In fact we need firstly to create our “Italian cars” – specifically we need a Relationship to hold the cars we are looking for.

When we compile our simple rule after this, there is a difference:-

And likewise, our Word document shows that the IsMemberOf function is now correctly included in our conclusion.

If we build and debug our rulebase, and populate the new Boolean Attribute “The car is serviced weekly” for each car in the workshop, we will be able to see the results as shown below.

Notice the yellow icon and the nature of the relationship – it is inferred and cannot be directly changed. Only by editing the Boolean Attribute can we change the members of the “Italian Cars”.

IsMemberOf as a Condition

The same function can also be used as a Condition. For example :

The syntax is straightforward as you can see.


The IsMemberOf function gives us flexibility to create inferred relationships.

OPA – Entities Adventures #5 Entity Functions…

Entity Functions

Moving forward in our investigation of the Oracle Policy Modelling and the Entities we have created, we can now begin to leverage some of the common Entity Functions. Consider the following requirements

For each car in the garage, indicate if it is

  • Being worked on
  • Requires parts to be ordered

At the same time, indicate the profit expected from each vehicle. Based on this figure

  • Indicate cars worth repairing, for each mechanic

How can we decide if a vehicle is being worked on? In the Policy Automation class which I teach very often, we create an Attribute “the car is being worked on” (Boolean). In the example in this post, we will use another method which may or may not be appropriate for your business requirement.

First let us consider the nature of the relationship. Each car can have 0 or 1 mechanic. A mechanic can have many cars. So our first attempt might be using the Exists function, which can detect at least one of a specific Relationship, and can apply one condition.

OPA - Entity Exists

The initial result is promising since with populated data and Relationships known, the Debugger displays:

OPA - Car Entity Being Worked On

The downsides are that the Attribute value will be “Unknown” if the Relationship is unknown, which can confuse the User. Observe the Debugger showing the result below.

OPA - Car Entity Not being Worked On

So the second attempt might be to use an Intermediate Attribute. Given that the Car can have 0 or 1 mechanic (or be unknown), we could use the InstanceCount function to count the number of Mechanics working on a given Car.

OPA - Car Entity Worked On Part 2

So in the above, the Car’s workforce, a number Attribute, is used to find out the number of Mechanics working on a given Car. The other Conclusion leverages this. The result looks promising, in that the lack of a specified Mechanic gives us a “False” value.

OPA - Car Entity Not Being Worked On Debugger 2

But in the case where a Relationship is known, but there are no Mechanics assigned, such as the example below, which is obviously quite possible in a Workshop:

OPA - Car Entity Relationship Known but no Mechanic

Running our rule gives the following in the Debugger:

OPA - Car Entity Workload False Result

Clearly this is, for this contrived example, not the hoped-for behavior. After all, there is nobody working on the Car instance in this case. So our final approach might be the following:

OPA - Car Entity Relationship Final VersionWhich behaves as we would hope in the Debugger.

OPA - Car Entiity Final Result Relationship

The examples above are designed not to explain how to run a Workshop or repair your Car, rather to make you think about these useful Entity Functions. Let’s move on to another example.

We need to calculate which cars need parts to be ordered. We will base ourselves on the simple idea that cars that are older than 10 years of age, and that have nobody working on them, and that have a repair cost that does not exceed the value of the Car, will need to have parts ordered since they are not kept in the Workshop. Again, this is a spurious example for the sake of this post.

Firstly, let’s add two new Attributes to the Car Entity – the car’s residual value, and the car’s estimated repair cost:

OPA - Car Entity New Attributes

Then we can leverage the all keyword to create the following rule, with InstanceCountIf to count the number of Car instances that meet the condition.

OPA - Car Needs Parts

Finally we will highlight a further interesting example. Having calculated  the total number of cars requiring parts, let us calculate the total number of cars worth repairing per mechanic. InstanceCountIf is used in the training course ,for the purposes of demonstration, with Containment Relationships, but it is usable with a Reference Relationship as well,

OPA - Cars Worth Repairing


In our next chapter we will investigate reasoning across entities and the various functions that you can use, plus we will take a look at the French version which we didn’t have time for in this post.