Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » URI Mapper example - resolve proxy: platform:/model
URI Mapper example - resolve proxy: platform:/model [message #645833] Mon, 20 December 2010 17:53 Go to next message
Kirsten M. Z. is currently offline Kirsten M. Z.Friend
Messages: 132
Registered: July 2010
Senior Member
Hi @all,

can someone provide an example, how I can load an EMF with references to another meta model correctly?

My meta model (an UML extension) containst definitions like that:

<eClassifiers xsi:type="ecore:EClass" name="ClassExtension" eSuperTypes="platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore#//Class">


I have the requirement to load my ecore file which contains the line above, and then I have to analyze all contained EClasses:

for ( Iterator<EObject> allIt = getResource().getAllContents(); allIt.hasNext(); ) {
    EObject obj = (EObject) allIt.next();
    if ( obj instanceof EClass ) {
        EClass cl = (EClass) obj;
        // ............
    }
}


Unfortunately, the supertype can only be returned as proxy, e.g.

platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore#//Class


I need to resolve this proxy, and I don't know which is the best way, e.g. registering something before, so that the model is loading differently? Or is it good to resolve the proxy afterwards. However, I am not allowed to add the UML.ecore to any project (so "platform" has to be resolved somewhere).

Thanks in advance!
Re: URI Mapper example - resolve proxy: platform:/model [message #645852 is a reply to message #645833] Mon, 20 December 2010 19:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Comments below.

vultur wrote:
> Hi @all,
>
> can someone provide an example, how I can load an EMF with references
> to another meta model correctly?
Be sure to use an absolute URI to load the initial resource.
>
> My meta model (an UML extension) containst definitions like that:
>
> <eClassifiers xsi:type="ecore:EClass" name="ClassExtension"
> eSuperTypes=" platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore#//Clas s ">
>
>
> I have the requirement to load my ecore file which contains the line
> above, and then I have to analyze all contained EClasses:
>
> for ( Iterator<EObject> allIt = getResource().getAllContents();
> allIt.hasNext(); ) {
> EObject obj = (EObject) allIt.next();
> if ( obj instanceof EClass ) {
> EClass cl = (EClass) obj;
> // ............
> }
> }
>
> Unfortunately, the supertype can only be returned as proxy, e.g.
>
> platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore#//Clas s
Are you running this as an Equinox application? This URI will only work
if UML2 is installed in the running process...
>
> I need to resolve this proxy, and I don't know which is the best way,
> e.g. registering something before, so that the model is loading
> differently? Or is it good to resolve the proxy afterwards. However, I
> am not allowed to add the UML.ecore to any project (so "platform" has
> to be resolved somewhere).
>
> Thanks in advance!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: URI Mapper example - resolve proxy: platform:/model [message #645868 is a reply to message #645852] Mon, 20 December 2010 21:07 Go to previous messageGo to next message
Kirsten M. Z. is currently offline Kirsten M. Z.Friend
Messages: 132
Registered: July 2010
Senior Member
Comments below.

Ed Merks wrote:
> Comments below.
>
> vultur wrote:
> > Hi @all,
> >
> > can someone provide an example, how I can load an EMF with references
> > to another meta model correctly?
>
> Be sure to use an absolute URI to load the initial resource.

The initial ecore model (which then contains references like "eSuperTypes=" platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore#//Clas s ") is loaded by the following code (the user selects an ecore file in a regular file chooser):

URI fileURI = URI.createURI(ecorePath.toURI().toString());
resource = resourceSet.getResource(fileURI, true);
resource.load(null);


> > My meta model (an UML extension) contains definitions like that:
> >
> <eClassifiers xsi:type="ecore:EClass" name="ClassExtension"
> > eSuperTypes=" platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore#//Clas s ">
> >
> >
> > I have the requirement to load my ecore file which contains the line
> > above, and then I have to analyze all contained EClasses:
> >
> > for ( Iterator<EObject> allIt = getResource().getAllContents();
> > allIt.hasNext(); ) {
> > EObject obj = (EObject) allIt.next();
> > if ( obj instanceof EClass ) {
> > EClass cl = (EClass) obj;
> > // ............
> > }
> > }
> >
> > Unfortunately, the supertype can only be returned as proxy, e.g.
> >
> > platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore#//Clas s
> Are you running this as an Equinox application? This URI will only work
> if UML2 is installed in the running process...

No, I don't run an Equinox application.
I know that there is a problem resolving "platform:" then. However, this is the question I have: do I really have to build an equinox application (is this complicated again? I have much trouble anyway, so I want to avoid going further for such a "simple thing")? Or is there a solution with URI mapping, etc.?

> >
> > I need to resolve this proxy, and I don't know which is the best way,
> > e.g. registering something before, so that the model is loading
> > differently? Or is it good to resolve the proxy afterwards. However, I
> > am not allowed to add the UML.ecore to any project (so "platform" has
> > to be resolved somewhere).
> >
> > Thanks in advance!

[Updated on: Mon, 20 December 2010 21:10]

Report message to a moderator

Re: URI Mapper example - resolve proxy: platform:/model [message #645880 is a reply to message #645868] Mon, 20 December 2010 22:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Comments below.

vultur wrote:
> Comments below.
>
> Ed Merks wrote:
>> Comments below.
>>
>> vultur wrote:
>> > Hi @all,
>> >
>> > can someone provide an example, how I can load an EMF with
>> references > to another meta model correctly?
>>
>> Be sure to use an absolute URI to load the initial resource.
>
> The initial resource (my model) is loaded by the following code (the
> user selects an ecore file in a regular file chooser):
What's a regular file? This isn't a workspace relative path for which
URI.createPlatformResourceURI should be used? (See FAQ)
>
> URI fileURI = URI.createURI(ecorePath.toURI().toString());
> resource = resourceSet.getResource(fileURI, true);
> resource.load(null);
>
>> > My meta model (an UML extension) containst definitions like that:
>> >
>> <eClassifiers xsi:type="ecore:EClass" name="ClassExtension" >
>> eSuperTypes="
>> platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore#//Clas s "> >
>> >
>> > I have the requirement to load my ecore file which contains the
>> line > above, and then I have to analyze all contained EClasses:
>> >
>> > for ( Iterator<EObject> allIt = getResource().getAllContents(); >
>> allIt.hasNext(); ) {
>> > EObject obj = (EObject) allIt.next();
>> > if ( obj instanceof EClass ) {
>> > EClass cl = (EClass) obj;
>> > // ............
>> > }
>> > }
>> >
>> > Unfortunately, the supertype can only be returned as proxy, e.g.
>> >
>> > platform:/plugin/org.eclipse.uml2.uml/model/UML.ecore#//Clas s
>> Are you running this as an Equinox application? This URI will only
>> work if UML2 is installed in the running process...
>
> No, I don't run an Equinox application.
So that's not going to work well.
> I know that there is a problem resolving "platform:" then.
Yep.
> However, this is the question I have: do I really have to build an
> equinox application (is this complicated again? I have much trouble
> anyway, so I want to avoid going further for such a "simple thing")?
You'll trade on simplicity for another. When you run an Equinox
application all the plugin.xml registrations kick and to help configure
everything. You'll have to do all that manually others.
> Or is there a solution with URI mapping, etc.?
Yes, you can use URI mappings to redirect these things into the jar
location. Is that sounding simpler?
>
>> >
>> > I need to resolve this proxy, and I don't know which is the best
>> way, > e.g. registering something before, so that the model is
>> loading > differently? Or is it good to resolve the proxy afterwards.
>> However, I > am not allowed to add the UML.ecore to any project (so
>> "platform" has > to be resolved somewhere).
>> >
>> > Thanks in advance!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: URI Mapper example - resolve proxy: platform:/model [message #646005 is a reply to message #645880] Tue, 21 December 2010 14:40 Go to previous messageGo to next message
Kirsten M. Z. is currently offline Kirsten M. Z.Friend
Messages: 132
Registered: July 2010
Senior Member
> > However, this is the question I have: do I really have to build an
> > equinox application (is this complicated again? I have much trouble
> > anyway, so I want to avoid going further for such a "simple thing")?
> You'll trade on simplicity for another. When you run an Equinox
> application all the plugin.xml registrations kick and to help configure
> everything. You'll have to do all that manually others.
> > Or is there a solution with URI mapping, etc.?
> Yes, you can use URI mappings to redirect these things into the jar
> location. Is that sounding simpler?

To be honest, it sounds simpler for my requirements (an application which runs in differenty model modes with/without EMF, with/without Eclipse). I have to configure everything in the plugin.xml correctly using Maven. And, but this is my own disability, sometimes I get stuck configuring the plugin.xml even within Eclipse.

On the other hand, I just have to get some kind of default path and can hopefully set-up a working URI mapping. But again: I have no idea how to get it working. I tested, but failed, so I wanted to ask the community how to resolve proxies correctly (before or after loading my "main" ecore file).
Re: URI Mapper example - resolve proxy: platform:/model [message #646043 is a reply to message #646005] Tue, 21 December 2010 17:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
You can read the URIConverter Javadoc about how to do URI mappings and
the Javadoc for ArchiveURLConnection for how to access archive contents.


vultur wrote:
>> > However, this is the question I have: do I really have to build an
>> > equinox application (is this complicated again? I have much trouble
>> > anyway, so I want to avoid going further for such a "simple
>> thing")? You'll trade on simplicity for another. When you run an
>> Equinox application all the plugin.xml registrations kick and to help
>> configure everything. You'll have to do all that manually others.
>> > Or is there a solution with URI mapping, etc.?
>> Yes, you can use URI mappings to redirect these things into the jar
>> location. Is that sounding simpler?
>
> To be honest, it sounds simpler for my requirements (an application
> which runs in differenty model modes with/without EMF, with/without
> Eclipse). I have to configure everything in the plugin.xml correctly
> using Maven. And, but this is my own disability, sometimes I get stuck
> configuring the plugin.xml even within Eclipse.
>
> On the other hand, I just have to get some kind of default path and
> can hopefully set-up a working URI mapping. But again: I have no idea
> how to get it working. I tested, but failed, so I wanted to ask the
> community how to resolve proxies correctly (before or after loading my
> "main" ecore file).


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EOpposite and Containment Property
Next Topic:XML substitution groups and FeatureMaps
Goto Forum:
  


Current Time: Thu Mar 28 19:07:34 GMT 2024

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

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

Back to the top