Mapping Between Target and Canonical Models
Data Hub uses an expression language transformation to map values from canonical items to the target items. The use of expression language enables a much wider spectrum of value transformations as compared to a basic value mapping.
The default implementation uses SpEL (Spring Expression Language) for transformation expressions. The full power of this expression language is available for mapping canonical attributes into the target item type. For more details, refer to the Spring Expression Language
document.
As an example, consider this scenario. The canonical model contains a general Product type and a specific product variant type. The target system does not separate and simply contains an apparel product type. Then assume that the types are defined like the following examples:
| CanonicalProduct |
|---|
| productId (primary key) |
| name |
| CanonicalProductVariant |
|---|
| sku (primary key) |
| productId |
| size |
| ApparelProduct |
|---|
| code |
| name |
| size |
The CanonicalProduct has many records in the CanonicalProductVariant that differ by size. The productId field of CanonicalProductVariant refers to the master record identified by the productId in the CanonicalProduct. The target ApparelProduct type flattens that relationship into a single item. You can expect that the code and size attributes populate from the sku and size attributes of the CanonicalProductVariant. Its name attribute populates from the name attribute of the CanonicalProduct corresponding to the productId value in the CanonicalProductVariant.
To look up a CanonicalProduct referred from the CanonicalProductVariant item, Data Hub sets a convention: all foreign key attribute names must be the same as the corresponding referenced primary key attribute names. The convention is why the CanonicalProduct primary key (productId) and the CanonicalProductVariant foreign key (productId) have the same name. The primary key does not have to consist of a single attribute only. It may be composed from multiple attributes, however the same rule applies: all attribute names of the corresponding foreign key must be the same.