Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WBRIDGE and version 20.1c
Multiexcerpt include
MultiExcerptNamemappingSimple
nopaneltrue
PageWithExcerptINTERNAL:_examples_BRIDGE

The following figure shows a very simple case of mapping a class into another.

Figure: Simple Mapping Defined in Class Diagrams

Image Modified

The most trivial mapping is done by just drawing a dependency between two attributes. For example, lastName is identical in class Input1 and Output1.
Although this situation is common, quite frequently we have the requirement that an attribute must be converted while being mapped. For instance, when id is being mapped to ID with a different data type. Or when street is being mapped to fullAddress2 we prefix the string with 'My Street: '.

This can be achieved by using the tagged value mappingRule on the <<E2ESimpleMapping>> stereotype. This tagged value may contain any valid action script statement. To refer the source or target attribute within the mapping rule, use the keyword source and target.
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 (default is true).

After defining the mapping in class diagrams, the mappings must be invoked in an activity diagram using a <<Mapping>> action.

...

Image Modified

...

Info
iconfalse

This action and the used mapping definitions must be kept in the same model, otherwise the compiler will complain.

This action then will internally translate the declarations defined in class diagrams into activity diagrams. In our simple example it generates the following set of action script statements that actually execute the mappings:

Code Block
create output1;
set output1.ID =convertToString(input1.id);
set output1.lastName = input1.lastName;
set output1.fullAddress =concat( convertToString( input1.zipCode), ' ', input1.city, ', ', input1.street);
set output1.fullAddress2 =concat('My Street: ', input1.street);
set output1.phones = input1.phoneNumbers;

...

The Interactive xUML Debugger allows you to debug all the generated activities.

Rp

Children Display
pageData Mapping

Rde