Problem – Describing "When Needed" and "When Changed" Actions
Many business processes rely on actions that must take occur when a value from an entity is needed or the state of the entity changes.
Triggers may be defined in the form of business rules by declaring watched attributes that require actions to be taken when accessed or when updated. This rule pattern is declared through a trigger type parameter along with a watched attribute. Define a when needed trigger and/or a when changed trigger.
Example – Benefit Election Change Once an employee's benefit commences payment, no further election changes may be made and all other calculations that had a status of pending election are invalidated. In this example a state change triggers an update to the state of other entities. Key values that trigger the action may also be specified if needed. This rule pattern may be used in conjunction with the State Transition rule pattern to specify the bulk of a state machine in terms of transitions and actions.
|Trigger type||when changed|
|Watched attribute||Benefit status|
|Action||invalidate other calculations|
Example – Accrued Benefit Request When an employee inquires as to the amount of his accrued benefit and the value is not current, then a calculation based on the employee's employment data is run. This type of rule illustrates a when needed type of trigger.
|Trigger type||when needed|
|Watched attribute||accrued benefit amount|
|Action||run benefit calculation|
The Trigger business rule pattern maps to the trigger association between an Event and a Transition model element.