| [news.eclipse.tools.emf] Re: Model Migration |
|
Mike, Comments below. Mike Gering wrote: I've figured out how to use the ecore2xml method for migrating aYou deserve a prize! Now I want to refactor that code so the migration occurs no matter howYes. I created a subclass of XMIResourceFactoryImpl and overrodeYou could have just used the resourceSet's package registry without creating one because it's implemented like this: public EPackage.Registry getPackageRegistry() resourceSet.setPackageRegistry(ePackageRegistry);I see. You're loading that resource for the mapping and ensuring that you've mapped the development time model to the real generated model. It strikes me though that you should only have to do this once ever, not once each time a resource is created. So it's better to do this once and cache the result for reuse with each resource created. ExtendedMetaData extendedMetaData = new Ecore2XMLExtendedMetaData(EPackage.Registry.INSTANCE, ecore2xmlRegistry);So these are the options you want to set on the resource you create, but you've set them on the resource set that's not used again beyond this point in the code. What you'll want to do is create the resource and put these options into the resource's load options. Resource resource = super.createResource(uri);Nope I don't imagine they would. It can be improved a little. :-P Note that in EMF 2.4 it's possible to register against a content type so that you could register this resource factory to apply only for resources that use the old namespace. Unfortunately the docs are non-existent. The XMI plugin shows how the content type for Ecore itself is registered so at least there's one working example and obviously I'll be happy to answer questions about it...
|