Model-to-model transformation with rules that ensure that UML profiles
are applied correctly to target models
This sample shows a model-to-model transformation that uses rules
to ensure that UML libraries and profiles are applied correctly to the in-memory
model that a transformation generates when it runs. When you run or rerun
a model-to-model transformation, the structural merge functionality merges
the generated in-memory model with the target model that you specify, which
must be an existing UML model file that has UML profiles, libraries, or both,
applied to it. These rules verify that the models refer to the same in-memory
instance of the applicable UML profiles and libraries.
Time required: 20 minutes
To successfully work
with this sample, you must have the Transformation authoring component
installed.
Note: This sample might require some optionally installable
components. If you encounter errors or cannot find user interface
options when you run a sample, ensure that you installed the appropriate
optional components.
Transformation authors can add one or both of the following
rules to ensure that the transformation applies UML libraries and profiles
correctly to an existing target model to which UML libraries and profiles
are already applied. If the transformation updates an existing target model
instead of completely overwriting one or creating a new target model, the
in-memory model that the transformation generates when it runs and the existing
target model must reference the same instance of each applied UML library
and profile, otherwise the models cannot merge.
- UMLDefaultLibrariesAddRule rule: This rule is added to the main
transform in a model-to-model transformation. The rule adds the default UML
libraries and profiles to the generated in-memory model in a manner that ensures
that each UML profile and library is loaded into memory only one time while
a transformation runs. For example, if multiple objects refer to the same
object in a profile or library, this rule ensures that they refer to the same
in-memory instance of the object in the UML profile or library. This functionality
facilitates the merge of the generated in-memory model and the existing target
model.
- CrossModelReferenceCheckRule rule: This rule is added to the root
transform of a model-to-model transformation. It verifies that a generated
in-memory model does not contain references to models that are loaded in different
resource sets. Such references can prevent the successful merge of models.