Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Transform multiple elements in one
Transform multiple elements in one [message #1844053] Mon, 30 August 2021 11:21 Go to next message
Tomas Wall is currently offline Tomas WallFriend
Messages: 53
Registered: April 2021
Member
Hi all,

I have the following scenario available in this link: https://www.eclipse.org/epsilon/live/?f32e2091

What I am trying to do is to transform the Area and Tree from the source model to a single Location in the target metamodel.

So if I have Forest(Forest1) -> Area(Area1) -> Tree(Tree1) in the source model, I want Forest(Forest1) -> Location (Area1 . Tree1) in the target metamodel.

Is there any way to do this and the reverse transformation of this one (meaning go from Forest(Forest1) -> Location (Area1 . Tree1) to orest(Forest1) -> Area(Area1) -> Tree(Tree1) ) with ETL?

Many thanks,
Tomas
Re: Transform multiple elements in one [message #1844100 is a reply to message #1844053] Wed, 01 September 2021 10:21 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Tomas,

I'm afraid I can't see a Location type in the target metamodel.

Best,
Dimitris
Re: Transform multiple elements in one [message #1844404 is a reply to message #1844100] Mon, 13 September 2021 09:04 Go to previous messageGo to next message
Tomas Wall is currently offline Tomas WallFriend
Messages: 53
Registered: April 2021
Member
Hi Dimitris,

Sorry for that. Here goes the right link: https://www.eclipse.org/epsilon/live/?8fe19286

The source metamodel is actually generated from Xtext, while the target metamodel is create in EMF.

Now in Xtext, the grammar is as follows:
________________________________________
Forest:
name=ID "{"
areas += Area;
"}"

Area:
name=ID "." trees+=Tree;

Tree:
name=ID;
________________________________________
And an instance model of this grammar is this:

Forest F1 {
area1.tree1;
}
_________________________________________

Now when I write the transformation I want area1.tree1 to be transformed into one single location, so the target model should be something like this:

ForestF1
---> Location area1.tree1

_______________________________________

However, I also want to be able to write the reverse transformation so that:

Location area1.tree1

can be transformed into

Area area1
---> Tree tree1
So a rule that would somehow check where the period is and would transform the element before the period in an area and the element after the period in a tree
Thank you in advance,
Tomas

[Updated on: Mon, 13 September 2021 11:08]

Report message to a moderator

Re: Transform multiple elements in one [message #1844492 is a reply to message #1844404] Wed, 15 September 2021 08:11 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

How should the transformation behave if there's a second tree under Area1?

Best,
Dimitris
Re: Transform multiple elements in one [message #1844510 is a reply to message #1844492] Wed, 15 September 2021 15:49 Go to previous messageGo to next message
Tomas Wall is currently offline Tomas WallFriend
Messages: 53
Registered: April 2021
Member
Actually, it should only have one tree, so I changed the metamodel to reflect that.

You can find it in the following link: https://www.eclipse.org/epsilon/live/?e208ceb8

Thank you in advance!

Best,
Tomas
Re: Transform multiple elements in one [message #1844521 is a reply to message #1844510] Wed, 15 September 2021 20:41 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

OK - the transformation in https://www.eclipse.org/epsilon/live/?fad971fa should do the trick.

Best,
Dimitris
Re: Transform multiple elements in one [message #1844610 is a reply to message #1844521] Fri, 17 September 2021 14:37 Go to previous messageGo to next message
Tomas Wall is currently offline Tomas WallFriend
Messages: 53
Registered: April 2021
Member
Hi Dimitris,

Thank you for that. I am working on the reverse transformation and I was able to create the Area and Tree from the Location but I am having two issues:

1. I am trying to add an "if" condition using matches() method so that if the name of the location matches("\\.") then the part before the period should be transformed into an area and the part after the period will be transformed into a tree. However, the if condition is not working correctly. Is the matches() method not the correct one to use in this case or is there another issue?

2. Second issue is that the tree should be contained into an area not into a forest.

These are the transformations so far: https://www.eclipse.org/epsilon/live/?418ac620

Many thanks,
Tomas
Re: Transform multiple elements in one [message #1844613 is a reply to message #1844610] Fri, 17 September 2021 14:46 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Tomas,

Both fixed in https://www.eclipse.org/epsilon/live/?3f4e92fb

Best,
Dimitris
Previous Topic:Mapping model for transformation with Epsilon
Next Topic:P2: Building on Epsilon Components
Goto Forum:
  


Current Time: Thu Apr 25 10:23:37 GMT 2024

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

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

Back to the top