Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » GenModel Reload Wizard replaces absolute URI to relative one in ecore files
GenModel Reload Wizard replaces absolute URI to relative one in ecore files [message #1718343] Tue, 22 December 2015 16:47 Go to next message
Dominik Leszyk is currently offline Dominik LeszykFriend
Messages: 22
Registered: December 2013
Junior Member
Recently I've observed that during Reload operation for GenModel model, EMF changes ecore file that is the base of GenModel file. This change concerns replacing absolute paths in ecore files with relative ones. In my specific situation I have ecore model called presentation.ecore that uses instances from other ecore model called common.ecore (URI with the platform scheme). So in the presentation.ecore there are URIs to common.ecore specified like below:
<eClassifiers xsi:type="ecore:EClass" name="Presentation" eSuperTypes="platform:/plugin/configuration.model/model/common.ecore#//Configurable platform:/plugin/configuration.model/model/common.ecore#//ContainedItem">

I have also a presentation.genmodel created out of the presentation.ecore file and common.genmodel created from common.ecore. Each time I choose 'Reload' operation on the presentation.genmodel file, EMF replaces URIs to relative ones:
  <eClassifiers xsi:type="ecore:EClass" name="ClassPresentation" eSuperTypes="../../configuration.model/model/common.ecore#//Configurable ../../configuration.model/model/common.ecore#//ContainedItem">

In the 'Reload' wizard I've choosen common.genmodel in the 'referenced generator models' table.

I have the following questions:
1) Why does EMF change abosolute URI to relative one? I assume it is default behaviour. Is it possible to control it somehow and keep absolute URIs?
2) It's quite unexpected that after performing operation on one file (genmodel) I get changes in the other file (ecore model) as well. It is possible to control it in the Eclipse UI?

Thanks for any answers,
Dominik
Re: GenModel Reload Wizard replaces absolute URI to relative one in ecore files [message #1718369 is a reply to message #1718343] Wed, 23 December 2015 05:50 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Dominik,

Comments below.

On 22/12/2015 5:47 PM, Dominik Leszyk wrote:
> Recently I've observed that during Reload operation for GenModel
> model, EMF changes ecore file that is the base of GenModel file. This
> change concerns replacing absolute paths in ecore files with relative
> ones. In my specific situation I have ecore model called
> presentation.ecore that uses instances from other ecore model called
> common.ecore (URI with the platform scheme). So in the
> presentation.ecore there are URIs to common.ecore specified like below:
>
> <eClassifiers xsi:type="ecore:EClass" name="Presentation"
> eSuperTypes="platform:/plugin/configuration.model/model/common.ecore#//Configurable
> platform:/plugin/configuration.model/model/common.ecore#//ContainedItem">
Is this referenced model actually in the workspace?
>
> I have also a presentation.genmodel created out of the
> presentation.ecore file and common.genmodel created from common.ecore.
> Each time I choose 'Reload' operation on the presentation.genmodel
> file, EMF replaces URIs to relative ones:
>
> <eClassifiers xsi:type="ecore:EClass" name="ClassPresentation"
> eSuperTypes="../../configuration.model/model/common.ecore#//Configurable
> ../../configuration.model/model/common.ecore#//ContainedItem">
>
> In the 'Reload' wizard I've choosen common.genmodel in the 'referenced
> generator models' table.
If the referenced model is in the workspace, it will generate references
to that one, and in general references between workspace resource will
be relative.
> I have the following questions:
> 1) Why does EMF change abosolute URI to relative one? I assume it is
> default behaviour. Is it possible to control it somehow and keep
> absolute URIs?
It sounds like that's what's being specified with the choices you've
made, and yes, relative references are always generated when possible.
There's no control over that, other than the choice of the referenced model.
> 2) It's quite unexpected that after performing operation on one file
> (genmodel) I get changes in the other file (ecore model) as well. It
> is possible to control it in the Eclipse UI?
No, the reload is a general operation that operates on both the Ecore
model and the GenModel (which is more evident if the source model is
something like *.xsd then the reload generates the *.ecore from the *.xsd).
>
> Thanks for any answers,

Why is this is a problem I wonder? I.e., what problem does this cause?
> Dominik


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: GenModel Reload Wizard replaces absolute URI to relative one in ecore files [message #1718411 is a reply to message #1718369] Wed, 23 December 2015 13:27 Go to previous messageGo to next message
Dominik Leszyk is currently offline Dominik LeszykFriend
Messages: 22
Registered: December 2013
Junior Member
Thanks Ed for the quick answer.

Quote:

Is this referenced model actually in the workspace?


Yes, it is. It is only in the workspace, not in the plugins.
Interesting that it is referenced using "platform:/plugin" scheme. Eclipse still finds it in the workspace (which I assumed is only possible when "platform:/resource" scheme is used).

Anyway I tried with different setup and put referenced model plugin (common.ecore) into the plugins. In the new workspace I created my dependent model (i.e. presentation.ecore) with a reference to common model from plugins. It works on ecore model level.
However when I want to create corresponding presentation.genmodel and I am requested to select referenced genmodel (common.genmodel from the plugin) I don't have a possibility to choose plugin after clicking 'Add' button. Only workspace projects are available for generator models.

Quote:

If the referenced model is in the workspace, it will generate references
to that one, and in general references between workspace resource will
be relative.


Ok.

Quote:

It sounds like that's what's being specified with the choices you've
made, and yes, relative references are always generated when possible.
There's no control over that, other than the choice of the referenced model.


I think it is correct for ecore models. But with genmodels it seems it is only possible to select generator models from workspace (as described above). Or maybe I have some issue with my plugin.

Quote:

No, the reload is a general operation that operates on both the Ecore
model and the GenModel (which is more evident if the source model is
something like *.xsd then the reload generates the *.ecore from the *.xsd).


Ok. Noted.

Quote:

Why is this is a problem I wonder? I.e., what problem does this cause?


Well, we're trying to come up with a workflow for our users to edit models (in Eclipse). We thought that usage of 'platform:/plugin' scheme (i.e. absolute paths) in our models will be the best choice. In our application we're using URIConverter to provide correct location of the referenced model file in the runtime (depending on the environment like client or server). But sometimes we need to use 'genmodel' and it was surprise that Eclipse changes paths then.

Correct me if I am wrong here: we should rather use relative paths in models and Eclipse still resolves depended models regardless of their location (plugins directory or workspace)?

Cheers,
Dominik


Re: GenModel Reload Wizard replaces absolute URI to relative one in ecore files [message #1718426 is a reply to message #1718411] Wed, 23 December 2015 14:48 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Dominik,

Comments below.

On 23/12/2015 2:27 PM, Dominik Leszyk wrote:
> Thanks Ed for the quick answer.
>
> Quote:
>> Is this referenced model actually in the workspace?
>
>
> Yes, it is. It is only in the workspace, not in the plugins.
> Interesting that it is referenced using "platform:/plugin" scheme.
> Eclipse still finds it in the workspace (which I assumed is only
> possible when "platform:/resource" scheme is used).
Yes, the Ecore and GenModel editors use
org.eclipse.emf.ecore.plugin.EcorePlugin.computePlatformURIMap(boolean)
to build a map so that you can reference plugins in the target platform
as if they are in the workspace.
>
> Anyway I tried with different setup and put referenced model plugin
> (common.ecore) into the plugins. In the new workspace I created my
> dependent model (i.e. presentation.ecore) with a reference to common
> model from plugins.
What is in the target platform in this new workspace?
> It works on ecore model level. However when I want to create
> corresponding presentation.genmodel and I am requested to select
> referenced genmodel (common.genmodel from the plugin) I don't have a
> possibility to choose plugin after clicking 'Add' button. Only
> workspace projects are available for generator models.
This depends on what's available in the target platform. And that
depends on the registrations in the plugin.xml. In this common.ecore's
project's plugin.xml, is the genModel="..." present for the
"org.eclipse.emf.ecore.generated_package" extension point?

As long as the models you want to reference are in the target platform
and they've registered the *.genmodel in their plugin.xml, they should
automatically be available as choices, and the references should all be
relative as if those were projects in the workspace.
>
> Quote:
>> If the referenced model is in the workspace, it will generate
>> references to that one, and in general references between workspace
>> resource will be relative.
>
>
> Ok.
> Quote:
>> It sounds like that's what's being specified with the choices you've
>> made, and yes, relative references are always generated when
>> possible. There's no control over that, other than the choice of the
>> referenced model.
>
>
> I think it is correct for ecore models. But with genmodels it seems it
> is only possible to select generator models from workspace (as
> described above). Or maybe I have some issue with my plugin.
> Quote:
>> No, the reload is a general operation that operates on both the Ecore
>> model and the GenModel (which is more evident if the source model is
>> something like *.xsd then the reload generates the *.ecore from the
>> *.xsd).
>
>
> Ok. Noted.
>
> Quote:
>> Why is this is a problem I wonder? I.e., what problem does this cause?
>
>
> Well, we're trying to come up with a workflow for our users to edit
> models (in Eclipse). We thought that usage of 'platform:/plugin'
> scheme (i.e. absolute paths) in our models will be the best choice. In
> our application we're using URIConverter to provide correct location
> of the referenced model file in the runtime (depending on the
> environment like client or server). But sometimes we need to use
> 'genmodel' and it was surprise that Eclipse changes paths then.
>
> Correct me if I am wrong here: we should rather use relative paths in
> models and Eclipse still resolves depended models regardless of their
> location (plugins directory or workspace)?
>
> Cheers,
> Dominik
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: GenModel Reload Wizard replaces absolute URI to relative one in ecore files [message #1718644 is a reply to message #1718426] Mon, 28 December 2015 17:19 Go to previous messageGo to next message
Dominik Leszyk is currently offline Dominik LeszykFriend
Messages: 22
Registered: December 2013
Junior Member
Quote:

Quote:

> Anyway I tried with different setup and put referenced model plugin
> (common.ecore) into the plugins. In the new workspace I created my
> dependent model (i.e. presentation.ecore) with a reference to common
> model from plugins.

What is in the target platform in this new workspace?


Target platform consists of the whole Eclipse (i.e. in the Run configuration dialog I choose: "All workspace and enabled target plugins"). So target platform includes my common plugin containing common.genmodel file.

Quote:

Quote:

> It works on ecore model level. However when I want to create
> corresponding presentation.genmodel and I am requested to select
> referenced genmodel (common.genmodel from the plugin) I don't have a
> possibility to choose plugin after clicking 'Add' button. Only
> workspace projects are available for generator models.

This depends on what's available in the target platform. And that
depends on the registrations in the plugin.xml. In this common.ecore's
project's plugin.xml, is the genModel="..." present for the
"org.eclipse.emf.ecore.generated_package" extension point?


Yes, genModel is present for the mentioned extension point in plugin.xml file for common plugin, i.e.:

   <extension point="org.eclipse.emf.ecore.generated_package">
      <!-- @generated common -->
      <package
            uri="http://www.example.org/sample/2_0/common"
            class="org.example.model.common.impl.CommonPackage"
            genModel="model/common.genmodel"/>
   </extension>


The thing is that in the genmodel wizard (opened for presentation.ecore in new workspace), only common.ecore is found (from the target platform) and presented as Root Object (top table). The genmodel is not found as 'referenced' generator model. (i.e. in the bottom table). Also the dialog that appears after clicking on the "Add" button doesn't have possibility to choose plugin (i.e. in similar way as Load Resource in Ecore editor). Please see the below picture.
http://s14.postimg.org/qqkyvcr3h/generate_model_no_references.jpg

Quote:

As long as the models you want to reference are in the target platform
and they've registered the *.genmodel in their plugin.xml, they should
automatically be available as choices, and the references should all be
relative as if those were projects in the workspace.


Hmm.. I can only confirm it for ecore models. Genmodel is not present for me.

Aside of this problem with the genmodel wizard: shouldn't I always user relative paths instead of absolute in my models. Then I would avoid problems described in the first post (i.e. EMF would not overwrite relative addresses). Am I right?
Re: GenModel Reload Wizard replaces absolute URI to relative one in ecore files [message #1718673 is a reply to message #1718644] Tue, 29 December 2015 05:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Dominik,

Comments below.

On 28/12/2015 6:19 PM, Dominik Leszyk wrote:
> Quote:
>> Quote:
>> > > Anyway I tried with different setup and put referenced model
>> plugin > > (common.ecore) into the plugins. In the new workspace I
>> created my > > dependent model (i.e. presentation.ecore) with a
>> reference to common > > model from plugins.
>>
>> What is in the target platform in this new workspace?
>
>
> Target platform consists of the whole Eclipse (i.e. in the Run
> configuration dialog I choose: "All workspace and enabled target
> plugins"). So target platform includes my common plugin containing
> common.genmodel file.
Unless you've taken steps to populate the target platform, Window ->
Preferences -> Plug-in Development -> Target Platform will be using
"Running Platform", i.e., all those plugins that are installed in the
running IDE itself.
>
> Quote:
>> Quote:
>> > > It works on ecore model level. However when I want to create > >
>> corresponding presentation.genmodel and I am requested to select > >
>> referenced genmodel (common.genmodel from the plugin) I don't have a
>> > > possibility to choose plugin after clicking 'Add' button. Only >
>> > workspace projects are available for generator models.
>>
>> This depends on what's available in the target platform. And that
>> depends on the registrations in the plugin.xml. In this
>> common.ecore's project's plugin.xml, is the genModel="..." present
>> for the "org.eclipse.emf.ecore.generated_package" extension point?
>
>
> Yes, genModel is present for the mentioned extension point in
> plugin.xml file for common plugin, i.e.:
>
>
> <extension point="org.eclipse.emf.ecore.generated_package">
> <!-- @generated common -->
> <package
> uri="http://www.example.org/sample/2_0/common"
> class="org.example.model.common.impl.CommonPackage"
> genModel="model/common.genmodel"/>
> </extension>
>
I see. But now that I think of it, when you created the Ecore model
itself, you probably didn't use "Browse Target Platform Packages" nor
"Browse Workspace..." to load the common.ecore, but rather used "Browse
Registered Packages". If you had used the former, the registered
GenModel would have been found automatically.
>
> The thing is that in the genmodel wizard (opened for
> presentation.ecore in new workspace), only common.ecore is found (from
> the target platform) and presented as Root Object (top table).
You mentioned it has a platform:/plugin URI. But note that this is not
the target platform but rather than running IDE itself. What's in the
target platform and what's installed in the running IDE are completely
independent; of course when the Target Platform itself is set to
"Running Platform" they have identical content, but the URI used to
refer to it is different.
> The genmodel is not found as 'referenced' generator model. (i.e. in
> the bottom table).
What's found automatically there will depend on how your Ecore model
references the other Ecore models. I tried it just now to be sure and
even if my Ecore model uses platform:/plugin to refer to another model,
the Reload find the GenModel in the target platform automatically.
> Also the dialog that appears after clicking on the "Add" button
> doesn't have possibility to choose plugin (i.e. in similar way as Load
> Resource in Ecore editor). Please see the below picture.
> http://postimg.org/image/qqkyvcr3h/
Yes, that's a good point I'd overlooked. It only suggests workspace
plugins. The ones needed from the target platform should be found
automatically.
>
> Quote:
>> As long as the models you want to reference are in the target
>> platform and they've registered the *.genmodel in their plugin.xml,
>> they should automatically be available as choices, and the references
>> should all be relative as if those were projects in the workspace.
>
>
> Hmm.. I can only confirm it for ecore models. Genmodel is not present
> for me.
No, but I have to wonder, how is the common.ecore available in this new
workspace at all? If it's not a workspace plugin, then you've built and
installed it's plug-in into that running IDE or provisioned the target
platform with a built version of it's plugin?
> Aside of this problem with the genmodel wizard: shouldn't I always
> user relative paths instead of absolute in my models.
Generally yes, the relative paths should make it appear at development
time as if they are all projects in the workspace. This ensures that at
runtime, when the URI used to load the resource is actually
platform:/plugin, they will all appear if if they are in the running IDE
and at development time, regardless of whether the referenced model is
actually in the workspace (when it is, that one will be used), or in the
target platform (when not actually in the workspace that one will be
used). This gives consistent behavior across the development time and
runtime scenarios and ensures that at development time you don't
actually have to install the models to reference them and that you can
provision a target platform with versions of the model that might be
newer than the one, if any, installed in the IDE itself.
> Then I would avoid problems described in the first post (i.e. EMF
> would not overwrite relative addresses). Am I right?
Yes, generally I expect relative URIs to be used


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: GenModel Reload Wizard replaces absolute URI to relative one in ecore files [message #1718786 is a reply to message #1718673] Wed, 30 December 2015 09:49 Go to previous message
Dominik Leszyk is currently offline Dominik LeszykFriend
Messages: 22
Registered: December 2013
Junior Member
Ed, thanks for help. I've switched to relative URIs and it works perfectly, i.e.:

  • in my wokspace I have two plugins (common and presentation) with two model files (presentation model refers to common model using relative URI); everything is resolved in workspace for ecore models and generator models as well;
  • after generating model code for common model I run common plugin (i.e. right click on the project, run as a Eclipse Application); then I import only presentation plugin to the new workspace in this child Eclipse; relative references to common.ecore are resolved against running Eclipse; similarly with genmodel (finally it is recognized as referenced generator model in the wizard);
  • in the runtime we use URIConverter and replace relative URIs to absolute that use jar: protocol.

I've also checked again the above scenario but with platform:/plugin URIs expressing dependency between models (BTW: I specify it in Load Resource dialog; after clicking Browse Target Platform Packages it is still possible to edit address field, so I replace 'resource' with 'plugin'). It didn't work in the child Eclipse. However after learning from you about Target Platform, I've checked it in the child Eclipse (in Preferences dialog) and it occurred that it is somehow broken and can't be 'computed'. After running child Eclipse with the new workspace (which has Target Platform in the correct state) everything works as you described.

Thanks again,
Dominik

Previous Topic:[CDO] Resource Transfer Framework - Registering Models
Next Topic:reference ecore model path of a different ecore model
Goto Forum:
  


Current Time: Thu Mar 28 13:28:44 GMT 2024

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

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

Back to the top