Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EDapt] Windows filenames are not URIs(Bug when applying history to model)
icon8.gif  [EDapt] Windows filenames are not URIs [message #1751921] Mon, 16 January 2017 19:35 Go to next message
Steve Hickman is currently offline Steve HickmanFriend
Messages: 4
Registered: January 2017
Junior Member
When Edapt attempts to apply a metamodel change history to a model, the Migrator constructor calls ResourceUtils.loadElement and passes the historyURI. Except under Windows, that value is not a URI because it contains 'c:'. Eventually (about 16 nested calls deeper), this calls PlatformURLPluginConnection.resolve() which calls Bundle::getResource() which returns null because of this isn't a valid URI. This then forces the creation of a fake URI that will cause a FileNoutFoundException. I think you can see the problem from there.

This should be fixed.

And,BTW, if you are wondering why I didn't put this in Bugzilla, its because I tried and your security is too much hassle. I'm giving you a gift by telling you about this bug. I don't have the time or patience to work through your security process. I understand that you don't want spam, but that's your problem not mine. I urge you to find a solution that won't be off-putting to people like me.
Re: [EDapt] Windows filenames are not URIs [message #1751971 is a reply to message #1751921] Tue, 17 January 2017 11:56 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 79
Registered: September 2016
Member
Hi,
thank you for the report.
About the issue with Bugzilla: I think you are right. Please note that the committers on the project are obviously not directly responsible for the infrastructure. However, I fully get your point that you do not really care if you just want to report a bug to us. So in fact, it is obviously in our interest to enable users to report bugs in a reasonable way. I therefore created this bug:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=510563
We will get back to you on the technical issue as well.

Best regards
Jonas

--
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/


--
Jonas Helming
Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EDapt] Windows filenames are not URIs [message #1752153 is a reply to message #1751971] Thu, 19 January 2017 09:47 Go to previous messageGo to next message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 83
Registered: December 2013
Member

Hi Steve,

I just had a look at this and I can't reproduce this.
What I did is the following:
	@Test
	public void run() throws MigrationException {
		final URI historyURI = URI.createFileURI("C:\\Users\\VM\\Desktop\\task.history");
		final URI resourceURI = URI.createFileURI("C:\\Users\\VM\\Desktop\\Task.xmi");
		final Migrator migrator = new Migrator(historyURI, new BundleClassLoader(FrameworkUtil.getBundle(getClass())));
		final Release release = migrator.getRelease(resourceURI).iterator().next();
		migrator.migrateAndSave(Collections.singletonList(resourceURI), release, null, new NullProgressMonitor());
	}

This is working fine. The URIs Edapt is expecting are of type org.eclipse.emf.common.util.URI
In order to create file uris you can use URI.createFileURI(path).

Does this solve your problem? Otherwise please specify which code is creating the Migrator instance.

Regards
Johannes


Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EDapt] Windows filenames are not URIs [message #1752766 is a reply to message #1752153] Thu, 26 January 2017 23:33 Go to previous messageGo to next message
Steve Hickman is currently offline Steve HickmanFriend
Messages: 4
Registered: January 2017
Junior Member
I copied this code from listing 3 on your example site:

private void checkMigration(final URI resourceURI) {
   String nsURI = ReleaseUtils.getNamespaceURI(resourceURI);
   final Migrator migrator = MigratorRegistry.getInstance().getMigrator(nsURI);
   if (migrator != null) {
      final Release release = migrator.getRelease(resourceURI).iterator().next();
      if (!release.isLatestRelease()) {
         if (MessageDialog.openQuestion(Display.getDefault().getActiveShell(),
            "Migration necessary",
            "A migration of the model is necessary. " +
            "Do you want to proceed?")) {
               performMigration(migrator, resourceURI, release);
            }
         }
      } else {
         MessageDialog.openError(Display.getDefault().getActiveShell(),
            "Error", "No migrator found");
      }
   }
}


And call it like this:
public void createModel() {
   URI resourceURI = EditUIUtil.getURI(getEditorInput(),editingDomain.getResourceSet().getURIConverter());
   checkMigration(resourceURI);
   ....
Re: [EDapt] Windows filenames are not URIs [message #1753151 is a reply to message #1752766] Thu, 02 February 2017 09:12 Go to previous message
Johannes Faltermeier is currently offline Johannes FaltermeierFriend
Messages: 83
Registered: December 2013
Member

Hi Steve,

This Editor integration sample creates the Migrator by using the MigratorRegistory. This one is filled from the org.eclipse.emf.edapt.migrators extension point.
At this extension point you have to register your history, which is expected to be contained in the plugin. It is advised to keep the history next to the ecore anyway.
See below example for the extension point.

If you can't keep the history file in your plugin, then you can't use the extension point. You will have to create the Migrator as shown here: https://www.eclipse.org/forums/index.php?t=msg&th=1083743&goto=1752153&#msg_1752153

Cheers
Johannes

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>

   <extension
         name=""
         point="org.eclipse.emf.ecore.generated_package">
      <package
            genModel="model/task.genmodel"
            uri="http://eclipse/org/emf/ecp/makeithappen/model/task"
            class="org.eclipse.emf.ecp.makeithappen.model.task.TaskPackage">
      </package>
   </extension>
   <extension
         point="org.eclipse.emf.edapt.migrators">
      <migrator
            path="model/task.history">
      </migrator>
   </extension>

</plugin>



Johannes Faltermeier

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Previous Topic:emf forms observable updates across threads
Next Topic:[EMF Forms] ViewModels - GenericEditor
Goto Forum:
  


Current Time: Tue Sep 25 05:23:55 GMT 2018

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

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

Back to the top