Context
When evaluating a rule Aware IM checks if rule conditions are met and if so executes the action specified by the rule1).
Let us consider the following rule as an example (taken from an application that manages car insurance policies – the rule itself may or may not be very realistic, but it does not matter for the purposes of this example):
IF Driver.Age > 70 Then INCREASE Policy.Excess BY 100
According to this rule the system is supposed to evaluate whether the age of the driver is greater than 70 and if so, increase the excess of the policy by 100 dollars. The question is – which driver and which policy? The system may have details about thousands of drivers and thousands of policies in its database – so, which ones are we talking about? If you ask a businessperson this question, she will probably answer something along the lines of “Of course, I know what I am talking about – the driver here is the person who has asked for a quote and the policy is the policy we are calculating for her”. Judging from this imaginary but quite possible answer, one can draw a conclusion that a businessperson always has a certain context in mind when she talks about business rules. In the example above this context is the fact that someone asked for a quote already - the business rule is therefore evaluated within this context and so “the driver” and “the policy” have a very specific meaning.
The concept of Context therefore is the key to rule evaluation and action execution – when deciding which instances of the business objects to consider when checking rule conditions and executing actions, Aware IM looks for such instances in the Context (with one exception that we will consider later). The Context can be regarded as a special place within Aware IM where it keeps “relevant” instances of the business objects and notifications. Still the question is how this Context is formed – how does Aware IM know which instances are relevant and which ones are not?
There are certain formal events within Aware IM that affect the contents of the Context. The full list of such events is described in the Data Processing section. Here we only mention two of them:
- If rules attached to a business object are being evaluated the instance of the business object, for which rules are being evaluated, is placed in the Context.
Now let us go back to our rule – to get a full picture of what is going on when it is being evaluated we must consider what was happening before and restore the context of rule evaluation. We assume here that the software calculates the details of the requested policy after someone has asked for a quote. It is therefore quite reasonable to assume that there is some process that displays the form with the driver’s details to be filled out by a user and after the form has been filled out calculates the details of the policy. The rules of the process might look something like this:
ENTER NEW Driver CREATE Policy
We assume here that the Driver
and the Policy
business objects are defined and that the Policy
business object has our rule attached to it as well as other rules that calculate all the details of the policy. The first action displays the form of the Driver
business object on the user’s screen. As soon as the user enters all the details the instance of the Driver
object is created and is placed in the Context (if there are any rules attached to the Driver
object they are evaluated as well). Then the instance of the Policy
object is created and placed in the Context and the rules attached to the Policy
business object (including our rule) are evaluated. Therefore when our rule is being evaluated the appropriate instances of the Driver
and Policy
business objects will have been already made available in the Context and the system uses the values of the attributes of these objects to check the rule conditions and execute actions. By the time the system finishes the creation of the Policy
object all the details of the policy will have been calculated!
More detailed information about the Context is given in the Context of Rule Execution section.