Situation
I have an RCP Eclipse application that manages application projects in the EMF model.
These projects are saved by serializing them in XMI format. Such files can then be loaded back into the model. To do this, I use standard EMF tools (such as Resource).
Because of model refactoring, the following has changed:
- Old model
- EClass
MyClass with the Name attribute (with a capital letter). - XMI:
<MyClass Name="My Class Name 1" ... />
against.
- New model
- EClass
MyClass inherits from MyBaseClass , with the Name attribute (without a capital letter). - The EClass
MyClass class no longer has a Name attribute, since EMF does not allow both. This makes sense as it will collide, for example, the getName() getter method.
Problem
How to load an old XMI project project into my new model?
Prior to this problem, I was able to:
- avoid model modification
- grow a model containing both old and new structures, and perform a modification after loading the project file: moving information from the old to the new, updating links, ....
In this case, however, I cannot load the XMI file in the first place: the model skips the Name attribute on the one hand and does not recognize (and thus ignores) the Name attribute on the other.
Question
What is the right place to implement this backward compatibility?
I guess I should work on the deserialization process or XML rendering.
Limitations for the solution:
- New projects (containing
<MyClass name="..." ... /> ) must also be loaded correctly. - Saving (i.e. serialization) of the project model should always occur in a new format!
source share