The package input and output objects contain a feature called packagedElement. This feature is a collection that contains different types of valid UML objects. The mapping rules that you create in this lesson define how the transformation processes the collection elements that are of type package or class.
Lesson 3: Create and refine a class-to-class mapping declaration showed that for each move mapping rule in a mapping declaration, a rule that copies an attribute value from the source model to the target model is added to the generated transform source code. For each submap mapping rule, an extractor that extracts elements in the specified collection is generated in the transform source code. The submap rule is applied to an object if the current input object is an instance of the input type that is defined in the mapping declaration.
When you run the generated transformation, if the source model contains a package, the Package2PackageTransform transform is invoked and creates a package with the same name in the target model. The Package2PackageTransform transform traverses the collection of the packagedElement feature. For each collection element that is of type package, which means that the source model contains nested packages, the transform invokes the Package2PackageTransform transform. For each collection element that is of type class, the transform invokes the rules to transform the class into a corresponding class and interface in the target output model.
To create a package-to-package mapping declaration in the mapping model:
After you create the mapping declaration, you must add an input object and an output object to it. In this lesson, you specify a UML package as the input and output object.
To add an input object and an output object to the package-to-package mapping declaration:
To create the mapping rules between the attributes of the package input and output objects: