For mappings between complex type objects it may is easier to draw the mappings only on class level and define the mapping between the attributes by set statements within the mapping rule.

Within the mapping rule it is possible to use the action script language. To refer source and target objects attributes, use the keyword source or target within the action script (see example in class diagram simpleClassMapping above).

  • Associations with multiplicity = 1 can directly be referenced, following the structure, delimited by a dot, e.g.

    set target.childLevel1.childLevel2.Name = source.firstChild.grandChild.name;
  • Associations with multiplicity > 1 cannot directly be referenced.The xUML Compiler will throw an error.

The necessary elements on the target side will be created automatically.

For further examples for using the simple mapping action <<Mapping>> consult the simple Mapping example.

Caveat

In many cases it makes no sense to apply an operation to optional input values if they are NULL. Therefore, if an operation has input parameters only that are optional at the source class, the operation is applied only, if at least one of the input values is not NULL. This is technically implemented by generating an implicit guard. This behavior can be overridden by setting the tagged value callOnlyIfParametersExist on the <<E2ESimpleMapping>> stereotype to false.