[Edapt] Feature not found [message #1651378] |
Thu, 05 March 2015 09:15 |
Matthias Juchmes Messages: 22 Registered: March 2015 |
Junior Member |
|
|
Hello,
I have a simple ecore model and created a history and a release, then I deleted a field (using the delete feature operation) and released again. I added the extension point for the migrator and wrote the migration code like in the library example
However, when I try to migrate an xml file from the old version, I get a PackageNotFoundException. I need to manually add a custom ResourceSetFactory to manually add the URI to the package registry:
protected class ResourceSetFactoryImplCustom extends ResourceSetFactoryImpl {
@Override
public ResourceSet createResourceSet() {
ResourceSet resourceSet = new ResourceSetImpl();
// manually add package with ns-uri of old version
resourceSet.getPackageRegistry().put(<ns-uri>,
BarPackage.eINSTANCE);
return resourceSet;
}
}
....
private void performMigration(final Migrator migrator, final URI resourceURI, final Release release) {
try {
// use the custom xmlResourceSetFactory
migrator.setResourceSetFactory(new ResourceSetFactoryImplCustom());
migrator.migrateAndSave(Collections.singletonList(resourceURI), release, null, new NullProgressMonitor());
} catch (MigrationException e) {
e.printStackTrace();
}
}
When I do this, migrating a file that doesn't contain the deleted feature works, but some XMI-Attributes are added to the root element:
xmi:version="2.0" xmlns:xmi="<link-to-xmi>"
Is there a way to avoid adding this to the file?
Also, when I try to migrate a file that contains the deleted feature, I get a FeatureNotFoundException. So something clearly isn't working, I'm guessing that it's probably something with the way I manually add the old ns-uri to the package registry.
I added the example code that reproduces this.
Thanks in advance
Matthias
-
Attachment: example.zip
(Size: 61.42KB, Downloaded 118 times)
|
|
|
Re: [Edapt] Feature not found [message #1663127 is a reply to message #1651378] |
Tue, 10 March 2015 09:24 |
|
Hi,
You are registering the generated BarFactoryImpl at the org.eclipse.emf.edapt.factories extension point. This extension point is only needed if you are working with custom EDataTypes and have problems with serializing/deserializing them during migration. Moreover you shouldn't register a generated factory at this extension point.
When you remove the usage of the extension point, you shouldn't get any package- or feature-not-found exceptions any more.
Regarding the problem with additional XMI-Attributes:
You can use the ResourceSetFactoryImpl to control which resource-type is created. Using #migrateAndLoad you get this resource set and cass pass the previsouly used save option to save method. The serialization is pure EMF at this point, so as long as you are performing the migration with the same resourcetypes and load/save options, you will be fine.
Cheers,
Johannes
Johannes Faltermeier
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
|
|
|
|
Powered by
FUDForum. Page generated in 0.02573 seconds