Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Edapt] Format of resourceURI to get the Releases from the Migrator?
[Edapt] Format of resourceURI to get the Releases from the Migrator? [message #1768177] Fri, 14 July 2017 11:14 Go to next message
Felix Buehler is currently offline Felix BuehlerFriend
Messages: 15
Registered: July 2017
Junior Member
Hi everyone!

We are looking to migrate our Ecore+Graphiti models with the help of edapt. Thanks upfront for this tool!

I have followed the steps provided in the library example and currently am stuck in the checkMigration-Method when getting the Namespace URI.

I suspect that the URI we currently create for our DiagramEditorInput is inappropriate. Heres's what the current URI looks like:
form:46.diagram

When trying to get the NamespaceUri in the checkMigration-method, this
String nsUri = ReleaseUtils.getNamespaceURI(resourceURI);

results in null. So getting the migrator with
final Migrator migrator = MigratorRegistry.getInstance().getMigrator(nsUri);

also results in null.

The form-history is registered via the extension point and a migrator with our namespace is available in the MigratorRegistry.

What I've tried so far is passing our namespace directly to get the migrator which works to get the migrator but when getting the release from the migrator, the line
final String nsURI = ReleaseUtils.getNamespaceURI(modelURI);

in the getRelease-method of the Migrator.class again results in a null string, thus not returning the release (which is contained in the release map).

Our current ecore namespace has the following format:
http:// com/company/product/module/forms
(the space is necessary, otherwise the forum recognizes it as a link to an external site which I'm currently not allowed to include...)

My question is: What does the resourceURI have to look like in order to get the Migrator and the Releases?

I have attached a sample xmi to show what our current combination of ecore and graphiti looks like. Maybe there's something wrong here?

Any answer would be highly appreciated!
Thanks in advance.

Felix

Re: [Edapt] Format of resourceURI to get the Releases from the Migrator? [message #1768384 is a reply to message #1768177] Tue, 18 July 2017 08:17 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 101
Registered: December 2013
Senior Member

Hi,

The following code prints http://eclipse.org/graphiti/mm/pictograms for me
String uri = ReleaseUtils.getNamespaceURI(URI.createFileURI("/home/johannes/Downloads/sample_xmi.xmi"));
System.out.println(uri);


The resource URI has to point to a xml file, because an XML Reader is used to determine the ns uri.
Also the ExtensibleURIConverterImpl is used to create an InputStream from this file. So if you have to do some custom conversion like normalization on your URI, do this manually before calling getNamespaceURI(URI).

2nd option could be to create the inputstream manually and use ReleaseUtils.getNamespaceURI_SAX(InputStream) + Migrator.getReleases() instead.

Cheers
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [Edapt] Format of resourceURI to get the Releases from the Migrator? [message #1768411 is a reply to message #1768384] Tue, 18 July 2017 12:31 Go to previous messageGo to next message
Felix Buehler is currently offline Felix BuehlerFriend
Messages: 15
Registered: July 2017
Junior Member
Hi Johannes!

Thanks for the hints! I'll try them and post the solution that worked for us.

Thanks again and best regards!
Felix
Re: [Edapt] Format of resourceURI to get the Releases from the Migrator? [message #1768871 is a reply to message #1768411] Mon, 24 July 2017 13:57 Go to previous messageGo to next message
Felix Buehler is currently offline Felix BuehlerFriend
Messages: 15
Registered: July 2017
Junior Member
Hi Johannes!

The second option worked for us, thank you! We had to create our own version of the getNamespaceURI_SAX(inputstream) though, because we too got the URI "http://eclipse.org/graphiti/mm/pictograms" which is not our package URI, so we added a check in the startElement() of the ContentHandler to only return our package URI.

When doing the migration, a simple migration like renaming an attribute works. However, when adding an attribute to an existing Class this attribute is not added during the migration (although the change is present in the history and also processed in the ForwardReconstructorBase-doReconstruct()).

EDIT: Deletion of an Attribute also works fine.
EDIT2: wenn using migrateAndLoad() the loaded resource does contain the new attribute but saving the resource with resource.save(null) again results in the new attribute not being persisted (the other changes worked though).

Do you have a suggestion what I could be missing? (I can also open another thread if that's more suitable)

Thanks in advance, I'm really appreciating your help!
Felix

[Updated on: Tue, 25 July 2017 08:19]

Report message to a moderator

Re: [Edapt] Format of resourceURI to get the Releases from the Migrator? [message #1768967 is a reply to message #1768871] Tue, 25 July 2017 08:59 Go to previous message
Felix Buehler is currently offline Felix BuehlerFriend
Messages: 15
Registered: July 2017
Junior Member
Hi!

I found the solution here: https://www.eclipse.org/forums/index.php/t/127619/

Because the value of the new attribute is not set, the attribute seems to not get serialized (which kind of makes sense).
To get the attribute serialized nevertheless a default value has to be set in the model and the save()-method has to be called with
Map options = new HashMap();
options.put(XMLResource.OPTION_KEEP_DEFAULT_CONTENT, Boolean.TRUE);
resource.save(options);


So no problem on the migration side :)

Thanks and have a good day!
Felix

[Updated on: Tue, 25 July 2017 09:00]

Report message to a moderator

Previous Topic:[EMF Forms] Text field active for unsettable features
Next Topic:Resource
Goto Forum:
  


Current Time: Fri Apr 26 06:02:53 GMT 2024

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

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

Back to the top