Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Convert http://... to platform:/plugin/... URI
Convert http://... to platform:/plugin/... URI [message #1827243] Mon, 11 May 2020 11:04 Go to next message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 283
Registered: August 2013
Senior Member
Hi

For example there is a plugin registering an Ecore model with a namespace URI equals http://example.com

How can I locate the Ecore file? In other words, how can I convert the URI to the following form: platform:/plugin/bundle_id/model/example.ecore

(Actually I don't need the Ecore file itself, I need an aird file located near ecore)
Re: Convert http://... to platform:/plugin/... URI [message #1827244 is a reply to message #1827243] Mon, 11 May 2020 11:46 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 31835
Registered: July 2009
Senior Member
Are you wanting to do that programmatically? The closest that comes to this in org.eclipse.emf.ecore.plugin.EcorePlugin.getEPackageNsURIToGenModelLocationMap(boolean) where you can find the *.ecore resource via its *.genmodel,.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Convert http://... to platform:/plugin/... URI [message #1827245 is a reply to message #1827244] Mon, 11 May 2020 11:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7098
Registered: July 2009
Senior Member
Hi

If you want to save some coding you can clone code around
org.eclipse.ocl.pivot.internal.resource.StandaloneProjectMap.PluginReader

A slightly easier but not necessarily reliable approach is to assume that the *.ecore is a sibling of the *.genmodel.

If you want the *.aird file, then you might as well start searching around the *.genmodel rather than the *.ecore since neither are necessarily in the required folder.

Regards

Ed Willink
Re: Convert http://... to platform:/plugin/... URI [message #1827256 is a reply to message #1827245] Mon, 11 May 2020 15:16 Go to previous message
Denis Nikiforov is currently offline Denis NikiforovFriend
Messages: 283
Registered: August 2013
Senior Member
Thanks a lot!

It seems that StandaloneProjectMap is based on getEPackageNsURIToGenModelLocationMap too.

Here is my code:
        URI modelURI = model.eResource().getURI();
        if (!modelURI.isPlatform()) {
            Map<String, URI> locationMap = org.eclipse.emf.ecore.plugin
                   .EcorePlugin.getEPackageNsURIToGenModelLocationMap(true);
            modelURI = locationMap.get(modelURI.toString());
        }
        if (modelURI.isPlatformResource()) {
            modelURI = URI.createPlatformPluginURI(
                    modelURI.toString().replaceFirst("^platform:/resource/", "/"),
                    false);
        }
Previous Topic:Add Property programmatically
Next Topic:How should a derived property fail?
Goto Forum:
  


Current Time: Sat Apr 17 09:24:10 GMT 2021

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

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

Back to the top