Expressions
A mapping is a set of expressions that tell Integration Composer how to transform source data when it is imported into the target database. For each data instance that you want to import from a source to a target, you define an expression that specifies how to transform the data for that property when it is migrated.
Integration Composer uses Java™ programming language to convert data. Knowledge of this language is helpful for creating expressions, but it is not required.
Integration Composer uses the expressions defined in a mapping to transform data instances when the data is migrated from a source to a target. Any information desired in the target must have an expression that defines how to transform the data in the source. However, expressions are not required for any class properties that will not be transferred from the source into the target.
When expressions are required
Not every class and property requires an expression. Use the following guidelines when creating a mapping:
- If any property of the target class contains an expression, then all primary keys of the class must also contain an expression.
- If a property is a primary key for a class, the value of the primary key (or combination of the primary keys if there are more than one) must be unique.
- If a primary key is a generated value, some or all of the alternate keys must have expressions.
- You do not have to create an expression for every alternate key property.
- Integration Composer ignores alternate key properties without expressions.
- If all alternate key properties contain an expression, then the values that result from alternate key expressions must be unique.
- For every child or reference class that contains an expression, all primary keys in the parent class must contain an expression to ensure that no child or reference class instance is without a parent class instance.
- You do not have to create an expression for every required property. For numeric properties, Integration Composer does not require an expression. For Integers, Integration Composer inserts a default value of zero (0) into the target. For Double and Float, it inserts a default value of 0.0.
Integration Composer highlights property rows that require a value with a yellow background.
The display properties that you set for a computer might affect colors. The color displayed on the computer that you use might vary.
When you have a property row that cannot be null, you can create a target expression for instances where no data is available in the source, as shown in the following example:
{
String str = trim (`Modem.Manufacturer');
if ((str!=null) && (str.length()>0))
return str;
return "UNKNOWN"
}
Syntax of expressions
Expressions can be simple or complex. Simple expressions might take the form of a literal; that is, a value expressed in quotation marks that is inserted into the target as specified. For example, you can specify MB for the property Sizeunit to transform Sizeunit to MB in the target. You can also use a class and property name to create a simple expression; for example, you can use the expression Adapter.AdapterType to insert the value of the property AdapterType from the class Adapter into the target.
To create more complex expressions, you can use predefined functions available in the Integration Composer user interface, or you can create complex expressions using the Java programming language. In the following example, an Integration Composer function is used to change an integer into a string:
intToString (`Mouse.Mouse Port Name')
In the following example, Java programming instructions are used to replace a login name entered in upper case with the literal default, or if the login name is not in upper case, display the first eight characters:
{
if
('Client.SysUserName'.equals('Client.SysUserName'.toUpperCase()))
return "default";
else
return 'Client.SysUserName'.subString(0,7);
}