You add BOM methods to a BOM class to help verbalize your
rules. To keep the XOM synchronized with the BOM, you must map the
new BOM methods to the XOM.
About this task
You use methods to specify conditions and actions in your
rules. You create methods in Rule Designer.
When you add methods to the BOM, you create members in the BOM that are not defined in the XOM.
This mismatch creates errors in your rule project. To avoid this mismatch, you map the new methods
to the XOM by using the BOM Editor.
Note: You must not make any changes directly in the XOM.
In this task, you add the following methods, verbalize them, and then apply BOM-to-XOM
mapping.
| Class |
Method |
Description |
| Loan |
public void addMessage(String msg) |
Defines what is needed to pass information from the rules. |
| Loan |
public void reject |
Identifies whether the loan application was rejected. |
| Borrower |
public long computeIncomeAfterTax |
Computes the income of the borrower, after tax. |
Procedure
To add BOM methods and map them to the XOM, start by adding the
addMessage method:
- On the Class page of the BOM editor,
in the Members section, click New.
- On the Member page of the New
Member dialog, make the following entries.
| Field |
Data entry |
| Type |
Select Method |
| Name |
Type addMessage |
| Method type |
Type void |
- On the same page, click Add and
then complete the Method Argument dialog as follows.
| Field |
Data entry |
| Name |
Type msg |
| Type |
Type java.lang.String |
- Click OK to close the Method
Argument dialog, and then click Finish.
On the Class page of the BOM editor,
the Members list now includes the addMessage method.
- Double-click the addMessage method,
and in the Member Verbalization section of
the BOM Editor, click Create to view the default
verbalization:
add
{0} to the messages of {this}
You are not going to
change this verbalization.
-
Scroll down to the BOM to XOM mapping section of the BOM Editor and then
click the arrow next to the Body field to open the BOM-to-XOM
Mapping editor.
- Type the following Java™ code:
- Save your work.
- Add the reject method to the Loan class
and then save it:
On the Member page
of the New Member dialog, make the following
entries.
| Field |
Data entry |
| Type |
Select Method |
| Name |
Type reject |
| Method type |
Type void |
You do not add parameters for this method.
The following table shows you what to enter for the verbalization and the BOM-to-XOM mapping.
| Verbalization |
BOM-to-XOM mapping |
Accept the default verbalization, reject {this} |
this.approved = false; |
- Add the computeIncomeAfterTax method
to the Borrower class and then save it:
On
the Member page of the New Member dialog,
make the following entries.
| Field |
Data entry |
| Type |
Select Method |
| Name |
Type computeIncomeAfterTax |
| Method type |
Type float |
You do not add parameters to this method.
The following table shows you what to enter for the verbalization and the BOM-to-XOM mapping.
| Verbalization |
BOM-to-XOM mapping |
Change the verbalization to the
income after tax of {this} |
if (this.yearlyIncome < 24000) {
return this.yearlyIncome;
}
else {
return java.lang.Math.round(this.yearlyIncome * 0.9F);
}
|
- In the Outline view, in the model package,
expand the Borrower class to view the computeIncomeAfterTax method,
and then expand the Loan class to view the addMessage and reject methods
you added.