Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » How to refine a model from another ?
How to refine a model from another ? [message #1808899] Thu, 04 July 2019 09:10 Go to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Hi,

The refining mode in ATL is limited to only ONE to ONE transformation with the same metamodel.

I want to accomplish MANY to ONE refining transformation.

Something like that :
create OUT: MODELA from M1: MODELA, M2 : MODELB

rule rule1 {
	from 
		att1 : MODELA!Att1,
		att2 : MODELB!Att2
	to 
		atout : MODELB!Att1 (
			name <- att2.name
		)
}



Where I want to use element from MODELB to refine MODELA.

How can I achieve that ?

[Updated on: Thu, 04 July 2019 09:13]

Report message to a moderator

Re: How to refine a model from another ? [message #1808942 is a reply to message #1808899] Thu, 04 July 2019 17:43 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

While you can specify multiple input and output models in refining mode, you cannot create elements whose type does not reside in an output model ("atout : MODELB!Att1").

In refining mode, each rule can refine a single element. At runtime, this becomes an in-place transformation of the refined element. See also https://wiki.eclipse.org/ATL/EMFTVM#In-place_transformation


Cheers,
Dennis
Re: How to refine a model from another ? [message #1808944 is a reply to message #1808942] Thu, 04 July 2019 17:53 Go to previous messageGo to next message
Marshall Charron is currently offline Marshall CharronFriend
Messages: 72
Registered: August 2018
Member
Thanks for you reply.

It was a mistake. Here is the right transformation :

create OUT: MODELA from M1: MODELA, M2 : MODELB

rule rule1 {
	from 
		att1 : MODELA!Att1,
		att2 : MODELB!Att2
	to 
		atout : MODELA!Att1 (
			name <- att2.name
		)
}


Basically, just refining an element in MODELA!Att1 with an element from MODELB!Att2.

How can I achieve that ? If possible could you provide a little snippet.

[Updated on: Thu, 04 July 2019 17:54]

Report message to a moderator

Re: How to refine a model from another ? [message #1809040 is a reply to message #1808944] Sun, 07 July 2019 08:38 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

An example transformation module could look like this:

-- @atlcompiler emftvm
-- @path MODELA=/RefiningTest/metamodels/ModelA.ecore
-- @path MODELB=/RefiningTest/metamodels/ModelB.ecore
module RefiningTest;
create OUT: MODELA refining M1: MODELA, M2 : MODELB;

rule rule1 {
	from 
		att1 : MODELA!Att1 in M1,
		att2 : MODELB!Att2 in M2 (
			att1.name = att2.name
		)
	to 
		atout : MODELA!Att1 mapsTo att1 (
			name <- att1.name,
			att2Tag <- att2.tag
		)
}


The transformation above adds an "att2Tag" value to all Att1 elements for which there exists an Att2 element with the same name. I've attached a zipped Eclipse project with the full example.

Note that if you want to specify extra input/output elements for a rule, you must explicitly declare that "atout" maps one-to-one to "att1", using the "mapsTo" keyword. Normally, there is an implicit "mapsTo" in each matched rule, which maps the first output element to the input element in case there is only one input element, or the Sequence of input elements in case there are multiple input elements.

I've also added "in" clauses to the input elements for efficiency reasons: this tells ATL to only search within a single model for matches.


Cheers,
Dennis
Previous Topic:EMFTVM programmatically ?
Next Topic:resolvetemp and Sequence
Goto Forum:
  


Current Time: Sat Nov 11 08:18:26 GMT 2023

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

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

Back to the top