Rule language mapping
You define the rule language mapping by selecting an item in the Outline view and entering the mapping in the BOM to XOM Mapping section of the BOM Editor.
This table shows members of the business class. The table assumes that an execution class name ExecutionClass is used for the business class BusinessClass.
| Member of business class BusinessClass | Case | Scope | A function body in IRL or ARL where... |
|---|---|---|---|
Constructor BusinessClass(MyBizClassB, MyBizClassC) |
Call by new | - | this cannot be used, returning an instance
of ExecutionClass. |
Attribute MyBizClassA attr |
Assignment | static | value can be used and this cannot
be used. |
| instance | value and this can both
be used. |
||
| Access | static | this cannot be used, returning an instance
of MyClassA. |
|
| instance | this can be used, returning an instance of MyClassA. |
||
Method MyBizClassA myBizMethod(MyBizClassB,
MyBizClassC) |
Invocation | static | this cannot be used. |
| instance | this can be used. |
||
| Tester | Use of operator InstanceOf, or cast, or classification
in conditions |
- |
this can be used, returning a Boolean. |
Class tester mapping
You can use a tester to test the instances of the execution class.
For example, you have a business class that is named RichCustomer in your BOM,
and it corresponds to an execution class Customer, which has the attribute
money greater than 100000:
- Set the execution name to
Customer. - Enter the following code in the Tester field:
return this.money > 100000;
Attribute mapping
You can map a BOM attribute to an expression to return an attribute value at run time.
For example, you have a class that is named ShoppingCart in the XOM, and the
class contains two methods that return the number of items in the shopping cart and the total value
of the items:
// Execution class
public class ShoppingCart {
public double getValue() ...
public int getNumberOfItems() ...
}
// BOM class
public class ShoppingCart {
public double averageItemPrice;
...
}if (this.getNumberOfItems() == 0 )
return 0;
retur this.getValue()/this.getNumberOfItems();Method call mapping
You can map a method call to any expression.
Customer in the XOM, and the class contains a
method that returns the age of the
customer:// Execution class
public class Customer {
public int getAge() ...
}public class Customer {
public boolean isOlderThan(int age);return this.getAge() > age;Constructor call mapping
You can map a constructor call to a specified expression.
Customer in the XOM, and the class contains an age
attribute and a constructor that takes the name of the customer
parameter:// Execution class
public class Customer {
public Customer(String name);
public int age;
}public class Customer {
public Customer(String name, int age);
}Customer result = new Customer(name);
result.age = age;
return result;Synthetic object mapping
Instead of regular Java™ objects, you can use synthetic objects as application data. You can then use BOM-to-XOM mapping to implement a complete business object model by using only the synthetic objects.
In the following example, you use the java.util.Map interface to implement synthetic objects, where attributes are stored as pairs of key values. Therefore, only the regular java.util.Map interface exists in the XOM.
In the BOM, you have a business class Customer
defined as follows:
Class Customer {
Customer(String name);
readonly String name;
int money;
}
The execution class for Customer is
java.util.Map. To facilitate the writing of the member mappings, add the following
import:
import java.util.*;
import java.lang.*;
For the name attribute, the getter part of the BOM-to-XOM mapping is expressed as follows:
return (String)this.get("name");
For the money attribute, by using an entry money that contains
an Integer in the Map, the getter part of the BOM-to-XOM mapping
is expressed as follows:
return ((Integer)this.get("money"));
The setter part is expressed as follows:
this.put("money",value);
Because you can use the same execution class, which is java.util.Map in this
example, for more than one business class, you must distinguish which instances belong to which
business class. This information must be stored in the Map when objects are
constructed, and is used by the tester. You express the BOM-to-XOM mapping body for the constructor
as follows:
Map result = new HashMap(3);
result.put("name", name);
result.put("money",0);
// as assumed, it always contains an Integer
result.put("className", "Customer");
return result;
The tester part of the BOM-to-XOM mapping for the class Customer uses the className entry to differentiate instances of
java.util.Map:
return "Customer".equals(this.get("className"));