Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Dealing with model structure changes
Dealing with model structure changes [message #1778535] Fri, 15 December 2017 23:25 Go to next message
Ken Keefe is currently offline Ken KeefeFriend
Messages: 35
Registered: September 2009
Member
I have an EMF model that I have saved using the built-in XMI serialization. I need to change the name of an attribute in my model. Understandably, when I try to load saved models that were saved in v.1, that old field is dumped. What is the best practice for dealing with model changes so I can grab that old named field and put it in the newly named attribute?

Thanks!
Re: Dealing with model structure changes [message #1778536 is a reply to message #1778535] Sat, 16 December 2017 06:01 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 29459
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.
Previous Topic:Attribute with HTML Content
Next Topic:Multiple Ecore models vs multiple ecore packages
Goto Forum:
  


Current Time: Sat Jul 21 15:40:15 GMT 2018

Powered by FUDForum. Page generated in 0.01624 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top