[EDAPT] Use Edapt with binary resources [message #1714302] |
Wed, 11 November 2015 15:35  |
Thomas Zwickl Messages: 37 Registered: May 2014 |
Member |
|
|
Hi,
I'm trying to use Edapt with a binary resource but I always get a null pointer back from this function:
String uri = ReleaseUtils.getNamespaceURI(resourceURI);
Does anyone know if it is even possible to use Edapt in combination with binary resources? I've already read some other forum topics where they discussed a similar problem, but they were all from 2009, so I hoped that this problem might have already been resolved in the meantime.
Thanks in advance for your help.
[Updated on: Thu, 12 November 2015 00:20] Report message to a moderator
|
|
|
Re: [EDAPT] Use Edapt with binary resources [message #1714399 is a reply to message #1714302] |
Thu, 12 November 2015 11:39   |
|
Hi Thomas,
ReleaseUtils.getNamespaceURI(resourceURI) will try to parse the file at the given URI with SAX in order to find the NS-URI of the model. This will only work for XML/XMI-Files.
But identifying the NS-URIs should be the only place where Edapt relies on a XMI-serialization as far as I know.
So you would have to introduce a different way of finding out the NS-URI of the model in the binary file. E.g. you could use the file-extension.
With this information you can get a Migrator instance and you should be able to identify the source release from the migrator.
String nsURI = getURIFromBinaryFile();
final Migrator migrator = MigratorRegistry.getInstance().getMigrator(nsURI);
final Release release = loopThroughReleasesAndFindReleaseWithNSURI(migrator, nsURI);
Furthermore you have to set a custom IResourceSetFactory on the migrator, which will make sure that Binary-Resources are created.
migrator.setResourceSetFactory(new IResourceSetFactory() {
@Override
public ResourceSet createResourceSet() {
ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
resourceSetImpl.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*",
new ResourceFactoryImpl() {
@Override
public Resource createResource(URI uri) {
return new BinaryResourceImpl(uri);
}
});
return resourceSetImpl;
}
});
I am not 100% sure that there are no other problems, but I think that this should work.
Could you share your experiences, if you are giving this a try?
Thanks and regards
Johannes
Johannes Faltermeier
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
[Updated on: Thu, 12 November 2015 12:10] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.01777 seconds