The Profile Migration Tool is mainly base on the difference between the old profile and the new profile. Base on this difference we can get a list of migration action we will apply in the model.
Globally to do the migration the program is in 4 step:
atomicMigratorList
: this is the list of IAtomiMigrators
. To initialize this list we run into the treeNode and for each node we will test if it is corresponding to a IAtomicMigrator
, to do this we use the MigratorFactory
.Package#applyProfile(Profile)
.atomicMigratorList
and for each IAtomicMigrator
we call the migrationAction()
method.To get differences between the profile V1 and the profile V2 we use
EMF Compare. However the output (Comparison
) of EMF Compare is not really understandable. This output is interpreted by the class org.eclipse.papyrus.profile.migration.internal.utils.DifferenceTreeBuilder(Comparison)
the method buildMatchTree()
get a TreeNode
from the comparison. The treeNode is much understandable since this element represent differences in a tree form and remove every elements which are not changed. For example, here we are in the left the output of EMF Compare, where there is every element of the model even if there are matching. In the right you can see the TreeNode, there is here only modified elements.
After getting the TreeNode corresponding to differences between the profile V1 and V2 we initialize the list of IAtomicMigrator
.
To initialize the atomicMigratorList
we will check for each node of the treeNode if there is a corresponding migrator. To do that we will ask the MigratorFactory
by the method instantiateMigrator(TreeNode)
. This method check for each known migrator if the treeNode in parameter is valid for the migrator.
This way we get a list of IAtomicMigrator
, this list represent every difference between model where the too; have an action to do.
To do the migration, we need the list of IAtomicMigrator
. We run into it and for each IAtomicMigrator
we call the migrationAction()
method.
There is a separate plug-in for the UI part of the tool: org.eclipse.papyrus.profile.migration.ui
. This plug-in manage with preference and pop-up display during the migration.
The preference page control if pop-up are display or not during the migration. During the execution, we keep in memory files that the user select (as profile before modification), and the preference page allow the user to remove which are keep file in cache if he want.
IAtomicMigrator
and shall have a static method like isValid(TreeNode)
this is the method that the migratorFactory will call to determine if the treeNode correspond to this migrator of not. This method should return true if the treeNode correspond to this migrator.MigratorFactory
. When the MigratorFactory
is modified, 3 file should be modified in the same time:
To keep in mind when you are coding the migration action:
The Profile Migration Tool is connected to Papyrus by the extensionPoint: org.eclipse.papyrus.uml.tools.profileApplicationDelegates
. This extension point replace the action of reapplying profile when Papyrus detect a difference of version between the applying profile and the other one.