Skip to main content



      Home
Home » Modeling » EMF » Convert http://... to platform:/plugin/... URI
Convert http://... to platform:/plugin/... URI [message #1827243] Mon, 11 May 2020 07:04 Go to next message
Eclipse UserFriend
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 07:46 Go to previous messageGo to next message
Eclipse UserFriend
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,.
Re: Convert http://... to platform:/plugin/... URI [message #1827245 is a reply to message #1827244] Mon, 11 May 2020 07:59 Go to previous messageGo to next message
Eclipse UserFriend
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 11:16 Go to previous message
Eclipse UserFriend
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: Fri Jul 04 23:43:51 EDT 2025

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

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

Back to the top