This content has been marked as final. Show 1 reply
The simplest way is to use the ExistsScope function.
So for example, imagine two entity sets, "the employee" and "the personnel record" (there can be many instances of employees and many instances personnel records). Assume that both of these entities are contained by global (i.e. they have no direct relationship to each other).
Im not sure why you want to compare the two, so here are a few examples of things you can do, and you can apply whichever is most relevant to you.
Firstly, you can write a boolean that basically confirms if an employee has a record:
the employee has a personnel record if:
..ExistsScope(the personnel records)
....the employee's name = the personnel record name
....the employee's home office = the personnel record office
This is just a simple Boolean that will confirm that there is at least one personnel record instance that matches the employee's name & home office. If that is all you need to do then it's by far the simplest way to achieve it in OPA. Here is a useful article which goes into more detail: http://docs.oracle.com/html/E27987_01/Content/Reference/Rule%20function%20examples/Entity_and_relationship_functions.htm
Often, however, it is useful to "match" one entity instance with another, and then run rules on the "matched instance"...
For example, once the employee's personnel record has been identified, it may be useful to run some more detailed rules. You could create an inferred relationship between the employee and the personnel record, and call it "the employee's personnel record".
the personnel record is a member of the employee's personnel record if:
..the employee's name = the personnel record name
..the employee's home office = the personnel record office
Then once you have this relationship, you can then use it in later rules:
the employee should be promoted if
..ForScope(the employee's personnel record)
....the personnel record's assessment score > 80
This is particularly useful if you have a large number of instances. The comparison will only be done once to create the inferred relationship and not each time you want to reason about "the employee's personnel record".
More about inferred relationships here:
I hope this helps, post back if you have any more questions.