Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [EMF Compare] Detecting supertype changes for the purpose of creating a common Ecore model
|[EMF Compare] Detecting supertype changes for the purpose of creating a common Ecore model [message #667385]
||Thu, 28 April 2011 13:13
Registered: March 2011
I'm processing a Diff of n Ecore models (I have extended EMF Compare so I can compare more than 2 or 3 and display results of all pairwise comparisons under the original model element). The idea behind this is to create a model which will contain data that is common to all compared models.
The classes of the common model are copies (EcoreUtil.copy) of classes from the oldest model, stripped of any class contents. The supertypes are references to the "real" classes in the oldest model and then later exchanged through classes from the common model, so that the common model has no references to any other models.
Right now processing superclasses of a class is giving me some headache. From what I figured out so far, three things can happen.
1) A superclass has been added if the supertypes list of the class from the old model is a subset of the supertype list of the class from the new model. Since in this case new information is added later than in the oldest model, I can just use the oldest models class' supertypes as the common ones.
2) A superclass has been deleted if the supertypes list of the new model class is a subset of the supertypes list of the old model class. In this case, if this change has occured later than in the second oldest model, I cannot directly take the rightTarget, which is the superclass in question, but I have to match the class from this model all the way back to the same class in the oldest model and then delete it from it's superclass list (I have implemented a mechanism that does that, otherwise the references don't match because eventhough the same class is meant semantically, they are in two different models and hence two different objects).
3) Now the one causing some trouble. Say a class only has one supertype. If this supertype is deleted and at the same time another supertype is added, this can be seen as a supertype change. In this case, instead of stripping the class from it's original supertype, I could use the nearest common supertype as the new one. So far so good.
But, what if I have a whole bunch of new classes that are not present in the other one? If I have a situation like this:
ST1 (X, C, B, A)
ST2 (Y, Z, C, B, A)
ST1 (X, W, C, B, A)
ST2 (Y, Z, C, B, A)
how can I tell if X/W has changed to Y/Z (latter example) or if Y or Z has been added (former example)? One possible solution I thought of is to count the supertype depth between all classes that don't appear in both models and then say for the closest pair they have "changed", and that the further one was "added".
Thanks for any thoughts and suggestions on this!
Current Time: Sun Apr 26 19:44:46 GMT 2015
Powered by FUDForum
. Page generated in 0.03732 seconds