Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EDAPT] Use Edapt with binary resources
[EDAPT] Use Edapt with binary resources [message #1714302] Wed, 11 November 2015 15:35 Go to next message
Thomas Zwickl is currently offline Thomas ZwicklFriend
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 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 68
Registered: December 2013
Member
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

Re: [EDAPT] Use Edapt with binary resources [message #1714403 is a reply to message #1714399] Thu, 12 November 2015 12:49 Go to previous messageGo to next message
Thomas Zwickl is currently offline Thomas ZwicklFriend
Messages: 37
Registered: May 2014
Member
Hi Johannes,

thanks for the detailed explanation I've already thought that this will be the case after looking through the code, but I thought maybe I just missed something.
I've already a general idea of how I'm going to implement this, I will give it a try and report back as soon as I've found out more.

Best regards,
Thomas

[Updated on: Thu, 12 November 2015 12:51]

Report message to a moderator

Re: [EDAPT] Use Edapt with binary resources [message #1716566 is a reply to message #1714403] Fri, 04 December 2015 20:37 Go to previous message
Thomas Zwickl is currently offline Thomas ZwicklFriend
Messages: 37
Registered: May 2014
Member
Hi Johannes,

I finally had some time to deal with this problem and so far it actually seems to work. I've created a ZIP-File for all the resource files and added the namespace URI as a comment to each respective ZIP entry.
Through this I can now unzip the resource files before loading and extract the namespace URI which is required for identifying the model version from the ZIP archive. I have chosen to use a ZIP archive because it is easier for the user to handle. In this way the file name stays the same and we don't have a second file which needs always to be copied as well.

The rest worked like a charm. Thanks for the support.

Best regards,
Thomas
Previous Topic:org.eclipse.emf.edapt.history.reconstruction.EcoreForwardReconstructor$EcoreReconstructorSwitch 124
Next Topic:[Edapt] is bidirectional migration possible/planned/feasible?
Goto Forum:
  


Current Time: Sat Sep 23 04:07:11 GMT 2017

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

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