|
Re: Dealing with model structure changes [message #1778536 is a reply to message #1778535] |
Sat, 16 December 2017 06:01 |
Ed Merks Messages: 33113 Registered: July 2009 |
Senior Member |
|
|
Perhaps better would have been if you made the old attribute transient volatile and derived and implemented the getter and setter to delegate to the new getter and setter, perhaps suppressing the getter and setter from the public interface (using an annotation as created by org.eclipse.emf.ecore.util.EcoreUtil.setSuppressedVisibility(EStructuralFeature, int, boolean)). You could use the org.eclipse.emf.ecore.xmi.XMLResource.OPTION_EXTENDED_META_DATA option in your resource factory implementing a derived subclass of org.eclipse.emf.ecore.util.BasicExtendedMetaData.BasicExtendedMetaData(Registry) that specializes org.eclipse.emf.ecore.util.BasicExtendedMetaData.getLocalAttribute(EClass, String, String) so that for the old attribute name it returns the new EAttribute that replaces it. Note also that the option org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RECORD_UNKNOWN_FEATURE is generally useful for supporting both forward and backward compatibility. It would allow an older runtime to read a newer serialization, ignoring but recording things that are recognized, and writing them back out again on serialization. Post processing that information, perhaps with a org.eclipse.emf.ecore.xmi.XMLResource.OPTION_RESOURCE_HANDLER, would also allow you to transfer the value of the old recorded attribute's value to the new attribute, and removing it from the recorded information so it's not serialized.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04482 seconds