Description
A package merge is a relationship between two packages, where the contents of the target package (the one pointed at) is
merged with the contents of the source package through specialization and redefinition, where applicable.
This is a mechanism that should be used when elements of the same name are intended to represent the same concept,
regardless of the package in which they are defined. A merging package will take elements of the same kind with the
same name from one or more packages and merge them together into a single element using generalization and
redefinitions.
It should be noted that a package merge can be viewed as a short-hand way of explicitly defining those generalizations
and redefinitions. The merged packages are still available, and the elements in those packages can be separately qualified.
From an XMI point of view, it is either possible to exchange a model with all PackageMerges retained or a model where
all PackageMerges have been transformed away (in which case package imports, generalizations, and redefinitions are
used instead).
Attributes
No additional attributes.
Associations
mergedPackage: Package [1] | References the Package that is to be merged with the source of the PackageMerge. Subsets DirectedRelationship::target. |
mergingPackage: Package [1] | References the Package that is being extended with the contents of the target of the Pack- ageMerge. Subsets Element::owner and DirectedRelationship::source. |
Constraints
No additional constraints.
Semantics
A package merge between two packages implies a set of transformations, where the contents of the merged package is
expanded in the merging package. Each element has its own specific expansion rules. The package merge is transformed
to a package import having the same source and target packages as the package merge.
An element with private visibility in the merged package is not expanded in the merging package. This applies recursively
to all owned elements of the merged package.
A classifier from the target (merged) package is transformed into a classifier with the same name in the source (merging)
package, unless the source package already contains a classifier of the same kind with the same name. In the former case,
the new classifier gets a generalization to the classifier from the target package. In the latter case, the already existing
classifier gets a generalization to the classifier from the target package. In either case, every feature of the general
classifier is redefined in the specific classifier in such a way that all types refer to the transformed classifiers. In addition,
the classifier in the source package gets generalizations to each transformed superclassifier of the classifier from the
target package. This is because the superclassifiers may have merged in additional properties in the source package that
need to be propagated properly to the classifier. Classifiers of the same kind with the same name from multiple target
packages are transformed into a single classifier in the source package, with generalizations to each target classifier.
Nested classifiers are recursively transformed the same way. If features from multiple classifiers are somehow conflicting,
the same rules that apply for multiple inheritance are used to resolve conflicts.
Note that having an explicit generalization from a classifier in a source package to a classifier of the same kind with the
same name in a target package is redundant, since it will be created as part of the transformation.
A subpackage from the target (merged) package is transformed into a subpackage with the same name in the source
(merging) package, unless the source package already contains a subpackage with the same name. In the former case, the
new subpackage gets a package merge to the subpackage from the target package. In the latter case, the already existing
package gets a package merge to the subpackage from the target package. Subpackages with the same name from multiple
target packages are transformed into a single subpackage in the source package, with package merges to each target
subpackage. Nested subpackages are recursively transformed the same way.
A package import owned by the target package is transformed into a corresponding new package import in the source
package. Elements from imported packages are not merged (unless there is also a package merge to the imported
package). The names of merged elements take precedence over the names of imported elements, meaning that names of
imported elements are hidden in case of name conflicts and need to be referred to using qualifiers. An element import
owned by the target package is transformed into a corresponding new element import in the source package. Imported
elements are not merged (unless there is also a package merge to the package owning the imported element or its alias).
A non-generalizable packageable element owned by the target package is copied down to the source package. Any
classifiers referenced as part of the packageable element are redirected at transformed classifiers, if any.
Notation
A PackageMerge is shown using a dashed line with a stick arrowhead pointing from the merging package (the source) to
the merged package (the target). In addition, the keyword Ğmergeğ is shown near the dashed line.
Examples
In Figure 97, packages P and Q are being merged by package R, while package S merges only package Q.
The transformed packages R and Q are shown in Figure 98.While not shown, the package merges have been transformed
into package imports..
In Figure 99, additional package merges are introduced by having the package T merge the packages R and S that were
previously defined. Aside from the package merges, the package T is completely empty.
In Figure 100, the transformed version of the package T is depicted. In this package, the partial definitions of A, B, C, and
D have all been brought together. Again, the package merges have been transformed to package imports. Note that the
types of the ends of the associations that were originally in the packages Q and S have all been updated to refer to the
appropriate types in package T.
It is possible to elide all but the most specific of each classifier, which gives a clearer picture of the end result of the
package merge transformations,as is shown in Figure 101.