| [news.eclipse.tools.emf] Re: Model Migration |
Ömer,
Comments below.
Hmmm. That doesn't sound good. This suggests to me that if you remove XMLResource.OPTION_RECORD_UNKNOWN_FEATURE it you'll get an package/class not found exception which suggests that the namespace in your instance is not matching the models you are registering.Hi Ed
Thus, the generated model cannot be contacted and a dynamic model should be generated with the assistance of the configured ExtendedMetaData while deserializing, right?In theory. When you load the resource and do resource.getContents().get(0).eClass() and print it out. Is it an instance of your new generated model? Is it a dynamic instance?
It is a dynamic instance (instanceof AnyType)
No, the mapping should be kicking in during loading and you should have an instance of the new model that you can save as normal. As I suggested above, I don't think the namespace in your input is actually matching your old registered model. So look closely at the namespace in the instance and the namespace against which you are registering the new package in the package registry.
The loading of an old-model-resource still works with this approach, immediately saving after load does too, but the model is still serialized in the old format.You've verified that the resource being used to do the loading is really the one configured by your factory. (A breakpoint would help verify that.)
Yes, I'm currently using the factory directly.
When saving the resource, I expect, for example, Ecore2XMLExtendedMetaData.getNamespace(EPackage) to be called when the Resource is about to write the package's NS URI attribute. It actually gets called with an instance of EPackageImpl (nsURI="<the old model version uri>") as parameter. So I expect this method to look it up and return the new model's NS URI, right?
Yep, it should have been mapped by now. You need to investigate why during load the old package is not being found and not being mapped to the new package. Eliminate XMLResource.OPTION_RECORD_UNKNOWN_FEATURE for the time being so you don't mask that problem.But that does not happen.
Ecore2XMLExtendedMetaData.java:
public String getNamespace(EPackage ePackage) { XMLResource.XMLInfo xmlInfo = getInfo(ePackage);
if (xmlInfo != null) { return xmlInfo.getTargetNamespace(); }
return super.getNamespace(ePackage); }
getInfo returns a null reference, leading the method to return the same NS URI as passed in by the parameter.