Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [EOL] Model objects manipulation (copying...)
[EOL] Model objects manipulation (copying...) [message #1065765] Thu, 27 June 2013 12:31 Go to next message
Gaëtan Pruvost is currently offline Gaëtan PruvostFriend
Messages: 19
Registered: June 2013
Junior Member
Hi guys,

I'm trying to make some operations upon models inside an EOL script and I need some guidance here. My problem should be common but I haven't seen anything in book/articles/forum about it.

A little background
I'm trying to copy a model IN to a model OUT. My eol script is run with both model described correctly in the eclipse run configuration.

Problem:
I can't find a proper way of copying model instances. I tried the following Native tools:

- ECoreUtil.copy
EmfTool.getECoreUtil().copy(...my root in IN...);

I get a copy of instances but they still relate to the IN model (via owningModel()) and I can't change it.

- EmfTool.createModel2
System.context.getModelRepository().removeModel(OUT);
var m = EmfTool.createModel2(...my root in IN..., "OUT", fileURI);
m.readOnLoad = false;
m.storedOnDisposal = true;

This one works to make the copy, the stored file is valid. However I can't navigate the model in the rest of the script. For instance, if I write OUT!A.all, I get zero instances even though my model has some.


Is my approach to the problem wrong, or have I missed a trivial solution to the problem?


Subsidiary questions
- Could you give me pointers for java native tools? The article that introduces them doesn't give any doc of them and looking at the sources only lead me to uncertain guesses.
- I don't understand the behaviour of the OUT variable. How does the script engine resolve model names? It looks like it is dynamically resolved to an IModel instance based on the model repository. However, I checked in debug, my context seems to be ok.
Moreover, I don't get why the script crashes if I try to write m!A when m is an IModel variable and A a concept name.

Thanks a lot
Cheers

[Updated on: Thu, 27 June 2013 12:35]

Report message to a moderator

Re: [EOL] Model objects manipulation (copying...) [message #1065888 is a reply to message #1065765] Fri, 28 June 2013 07:22 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi Gaëtan,

The following might work:

var root = EmfTool.getECoreUtil().copy(...my root in IN...);
OUT.resource.contents.add(root);

> - Could you give me pointers for java native tools? The article that introduces them doesn't give any doc of them and looking at the sources only lead me to uncertain guesses.

There's no additional documentation for native tools I'm afraid - mostly because I can't think of what else we should add. Any thoughts?

> - I don't understand the behaviour of the OUT variable. How does the script engine resolve model names? It looks like it is dynamically resolved to an IModel instance based on the model repository.

That is correct.

> However, I checked in debug, my context seems to be ok.

> Moreover, I don't get why the script crashes if I try to write m!A when m is an IModel variable and A a concept name.

Could you please attach some code so that I can test?

Cheers,
Dimitris
Re: [EOL] Model objects manipulation (copying...) [message #1065937 is a reply to message #1065888] Fri, 28 June 2013 12:08 Go to previous messageGo to next message
Gaëtan Pruvost is currently offline Gaëtan PruvostFriend
Messages: 19
Registered: June 2013
Junior Member
Hi Dimitris,

Your solution partly works: the copy is done properly (the stored file has the instances) but I still can't access my data in the following of the script
OUT!A.all returns an empty sequence.


On the other hand, I can create a new model with
emfTool.createModel2(IN!Root.all.first()
     , "OUT2"
     , "/epsilon.ztests/forum/gen-model2.model");
var m = System.context.getModelRepository().getModelByName("OUT2");
m.readOnLoad = false;
m.storedOnDisposal = true;

But then it works only if I give the model a different name than the one defined in the "run configuration".

Attached is a minimal example where both solutions are tested.
Please, setup the "run configuration" with IN and OUT before running the script.

[Updated on: Wed, 03 July 2013 09:10]

Report message to a moderator

Re: [EOL] Model objects manipulation (copying...) [message #1066772 is a reply to message #1065937] Thu, 04 July 2013 10:17 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi Gaëtan,

Apologies for the slow response - I'll have a look at this within the next couple of days and get back to you.

Cheers,
Dimitris
Re: [EOL] Model objects manipulation (copying...) [message #1066795 is a reply to message #1066772] Thu, 04 July 2013 12:23 Go to previous messageGo to next message
Gaëtan Pruvost is currently offline Gaëtan PruvostFriend
Messages: 19
Registered: June 2013
Junior Member
Hi Dimitris,

No worries, I'm sure you have a lot to do, the forum is pretty active.
Are you alone to manage the users community?

BR,
Gaëtan
Re: [EOL] Model objects manipulation (copying...) [message #1067239 is a reply to message #1066795] Sun, 07 July 2013 20:58 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi Gaëtan,

Since you are modifying the contents of the underlying resource of OUT using the EMF API, you should un-tick the "Cache model elements ..." option in the configuration of your OUT model. If you do that, OUT!A.all.size() will return 3 as expected.

Cheers,
Dimitris
Re: [EOL] Model objects manipulation (copying...) [message #1067297 is a reply to message #1067239] Mon, 08 July 2013 08:49 Go to previous message
Gaëtan Pruvost is currently offline Gaëtan PruvostFriend
Messages: 19
Registered: June 2013
Junior Member
Great, this one works as expected.

Thanks a lot,
BR
Previous Topic:Import of ecore
Next Topic:Create gmf tools, etc with Eugenia
Goto Forum:
  


Current Time: Thu Mar 28 10:27:54 GMT 2024

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

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

Back to the top