Compose Business Rules
You use the Rule Composer to define a business rule written in plain text within a Business Rule element or Class operation. The Rule Composer enables you to model conceptual-level business rules at a logical level in tabulated format, which assists in transforming the rules to technology-specific rules (code).
Access The Rule Composer
To access the Rule Composer, right click on a Rule Task element and select the Rule Composer context menu option. The Rule Composer displays in the central work area on its own tab.
The Rule Composer consists of:
- a Rule Statements list
- a Decision Table and
- a Computation Rule Table.
To assist with traceability, as the Rule Composer is completed, selections in one table automatically highlight the corresponding rows and columns of the other tables. For example, If a Rule Statement is selected, the related rule column in the Decision Table and row in the Computation Rule Table are highlighted. Similarly, if a Computational Rule is selected, the corresponding column in the Decision Table and row in the Rule Statements list are highlighted.
Rule Statements Table
The Rule Statements table lists the rules associated with the selected Rule Task. You add a rule to the table by dragging an existing Business Rule element from the Project Browser onto an empty row in the Rule Statements table. You cannot create new rules within the table.
To define a business rule associated with the selected Rule Task, follow the steps below:
- For the first rule, select the text within the Business Rule element and drag it onto the empty row.
- For a subsequent rule, click on the No column and select the Add Row context menu option. An empty row is added to the Rule Statements table.
- Drag the required Business Rule element from the Project Browser onto the new row. If the Business Rule element is not already on the diagram, this adds the element to the diagram and creates a Dependency relationship between the Business Rule and Rule Task elements.
To remove a rule that is no longer required in the Rule Composer, right-click on the appropriate No field and select the Remove Rule context menu option.
This removes the rule from the Rule Composer and deletes the Dependency relationship with the Rule Task element. However, it does not remove the Business Rule element from either the diagram or the Project Browser (where, in either case, it might be in use with other Rule Task elements).
The Decision Table enables you to model conditional rules (for example: Cars must not be rented to customers of age less than 18).
The table has three sections:
- Rule Conditions – to model condition variables
- Rule Actions – to model action variables
- Rule Bindings – to link the rule in the rule table.
Rule Conditions Section
To model Rule Conditions, follow the steps below:
- The Business Domain model defines the business terms (such as Customer) and their associated attributes. From the appropriate Class element in the Project Browser, drag and drop the required condition attribute (such as age) or operation (such as IsValidLicense()) onto the Rule Conditions column.
- Define a range of accepted values for the Rule Condition.
- Right-click on the Allowable Values column and select the Edit Allowable Values context menu option. The Edit Allowable Values dialog displays.
Type each required value or range of values in the Value field, and click on the Save button to display the value in the Allowable Values list box; for example:
age could have the values:
>18 and <50
IsValidLicense() could return:
- Click on the OK button to save the values and close the dialog. A new constraint AllowableValues is created for the attribute.
- If the Rule Condition is an operation, you can pass parameters to it. Right click on the Allowable Values field, and select the Edit Parameters context menu option. The Edit Parameters dialog displays. Select the parameters and type their values into the Value text box. Click on the OK button to cancel the dialog.
You can add an operation as a Rule Condition more than once, to allow calling the operation with different sets of parameters.
To add another Rule Condition, right-click on the No column and select the Add Row context menu option. An empty row is added to the table.
To remove a Rule Condition from the table, right-click on the appropriate No field and select the Delete Row context menu option. This does not affect the original attribute or the new constraint in the model. You can either re-use the attribute with its constraint, or use the attribute Properties dialog to remove the constraint.
Rule Actions Section
In the Rule Actions section, when a specific value of a Rule Condition calls an operation (such as post error) or decision attribute (such as Eligible - Yes/No), you assign the operation or attribute as an action. To model Rule Actions, follow the steps below:
- From a business term Class element in the Project Browser, drag and drop the required attribute or operation onto the Rule Actions field.
The Rule Actions field enables you to use intellisense to display a list of possible entries for the field. Press [Ctrl]+[Spacebar] in the field to display the list of entries.
- For an attribute, double-click on the Allowable Values/Parameters field. The Edit Allowable Values dialog displays; type the range of values in the text box (such as Yes, No; or Accept, Reject), click on the Save button and close the dialog. Select the appropriate response in the Result column fields.
If the dropped action variable is of type enum, the Allowable Values/Parameters fields are automatically set with the enum literals.
- For an operation, a checkbox displays in each of the Result column fields. To call the operation, select the checkbox in the appropriate column.
To pass parameters to the operation, double-click on the Allowable Values/Parameters field. The Edit Parameters dialog displays. Select the parameters and type the values into the Value text box. Click on the Save button and close the dialog.
You can add an operation as a Rule Action more than once, to allow calling the operation with different sets of parameters.
- Click on the Save button in the Rule Composer toolbar to save the values.
Alternatively, you can right-click on an Allowable Values/Parameters field to display a context menu with two options:
To add another Rule Action, right-click on the No column and select the Add Row context menu option. An empty row is added to the table.
To remove a Rule Action from the table, right-click on the appropriate No field and select the Delete Row context menu option. This does not affect the original attribute or operation in the model.
Rule Bindings Section
The Rule Bindings section lies on top of the Rule Conditions section. It binds the Rule Condition and Rule Action values to the appropriate rule in the Rule Table. To bind a rule, follow the steps below.
- Select the rule number in the Rule Bindings field over one of the Value<n> or Result<n> columns.
- Ensure that the values set in the Value<n> or Result<n> field for the Rule Condition or Rule Action, underneath the rule number, all satisfy the rule.
- Click on the Save icon in the Rule Composer toolbar.
For example, (referring to the screen diagram at the top of this Rule Composer topic) if rule 2 is Car must not be rented to Customers of age less than 18:
- Select 2 in the Rule field over the Value1 column
- Select < 18 against Customer.age in the Value1 column in the Rule Conditions table
- Select No against Customer.Eligible in the Result1 column in the Rule Action table
- Select Reject against Application.Status in the Result1 column in the Rule Action table.
Computation Rule Table
The Computation Rule table enables you to model rules involving computations.
The table has the following columns:
- Computation Rule Actions
- Rule Bindings
- Rule Dependency.
To define a computation rule, follow the steps below:
- From the Project Browser, drag and drop the appropriate attribute from a Class in the Fact model into the Computation Rule Actions field.
Both the Computation Rule Actions field and the Expression field enable you to use intellisense to display a list of possible entries for the fields. Press [Ctrl]+[Spacebar] in the field to display the list of entries.
- In the Expression field, type the expression to be evaluated.
- In the Rule Bindings field, type the rule number from the Rule table of the rule being modeled, to link the table data to the rule.
- If the rule depends on another rule being satisfied first, type the number of that rule in the Rule Dependency field.
- Click on the Save icon in the Rule Composer toolbar to save the computation rule.
If the computation rule is also a Rule Conditions rule, add the condition variable in the Decision table and bind the appropriate rule in the Rule Bind section.
To export the contents of the Rule Composer to a CSV file, follow the steps below:
- Click on the Export to CSV icon () in the Rule Composer toolbar. The Windows Browser dialog displays.
- Browse to the required file location and type in a .CSV filename to export to.
- Click on the Save button to export the data.