Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » How to specify in the rule that one element contain another
How to specify in the rule that one element contain another [message #1065398] Tue, 25 June 2013 10:48 Go to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 52
Registered: April 2013
Member
Hello,

I would like to know how to specify in the rule that one element contain another.

My input metamodels are M2 UML2 and the output is a specific Ecore model.

For example, in the code below, I can specify that the element name DocumentRoot contain Model Type element but I don't know how to specify that ModelType element contains PackageType element. See the code below and the snapshot I uploaded.

rule Model2DocumentRoot {
	from
		m : UML!Model
	to 
		dr : XsdEcore!DocumentRoot (
			comment <- 'le modèle que l\'on traite est '+m.name,
			model <- mt		
		),
		mt : XsdEcore!ModelType(	
			package <- m.packagedElement 
		)
}

rule Pack2Pack {
	from
		p : UML!Package
	to 
		pt : XsdEcore!PackageType ()
}


http://img11.hostingpics.net/thumbs/mini_184878modelexample.png

[Updated on: Tue, 25 June 2013 10:57]

Report message to a moderator

Re: How to specify in the rule that one element contain another [message #1065406 is a reply to message #1065398] Tue, 25 June 2013 11:24 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 588
Registered: July 2009
Senior Member
Hello,

ATL as an automated matching mechanism that will automatically link, in a a given rule, the elements of the input model that are matched by another rule.
E.g. in your case, when writing package <- m.packagedElement, ATL will actually assign to the "package" reference the output elements created by other rules matching the "m.packagedElement" input elements (e.g. by your Pack2Pack rule).


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: How to specify in the rule that one element contain another [message #1065413 is a reply to message #1065406] Tue, 25 June 2013 11:39 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 52
Registered: April 2013
Member
Thank you Hugo,

But normally, when the rule
rule Pack2Pack {
	from
		p : UML!Package
	to 
		pt : XsdEcore!PackageType ()
}

will generated all package that I had in the instances of the input Metamodels.
But it is not the case with me, and I don't have any message in the console; actually, the instance of my input metamodel containts a lot classes.

Thank you for your advice.

Do you a ATL forum for a French people?
Re: How to specify in the rule that one element contain another [message #1065421 is a reply to message #1065413] Tue, 25 June 2013 12:07 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 588
Registered: July 2009
Senior Member
Your rule is matching input elements of type "Package", so ATL will create exactly the same number of "PackageType" output elements.
If they are not explicitly assigned in any rule within your transformation, then ATL puts them by default at the root of your model.

Concerning ATL forums, this one is the official one and I'm not aware of any French-specific one Smile


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: How to specify in the rule that one element contain another [message #1065513 is a reply to message #1065421] Wed, 26 June 2013 05:12 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 52
Registered: April 2013
Member
Yes I agree with you.
The problem is that I do not generate any file when I am using that rule in my module?

When I'm using the debug mode with a breakpoint, I cannot see the real execution of the code.
Re: How to specify in the rule that one element contain another [message #1065524 is a reply to message #1065406] Wed, 26 June 2013 06:22 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 52
Registered: April 2013
Member
In my case, ATL does automatically link elements.
I also know that it's possible to do something like this
rule DocumentRoot {
	from
		m : UML!Model
	to 
		dr : XsdEcore!DocumentRoot (
			model <- mt		
		),
		mt : XsdEcore!ModelType()	
}


But if the ModelType() is an target element of another rule with different different input model (UML!Package # UML!Model) what should I do?
Re: How to specify in the rule that one element contain another [message #1065595 is a reply to message #1065524] Wed, 26 June 2013 11:33 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 588
Registered: July 2009
Senior Member
If you have another rule like this:
rule XXXtoModelType {
	from
		m : UML!XXX
	to 
		mt : XsdEcore!ModelType()	
}

Then you need to refer to the corresponding input element in your DocumentRoot rule:
rule DocumentRoot {
	from
		m : UML!Model
	to 
		dr : XsdEcore!DocumentRoot (
			model <- m.referenceToMyXXXModelElement		
		)
}


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Re: How to specify in the rule that one element contain another [message #1065723 is a reply to message #1065595] Thu, 27 June 2013 05:29 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEM
Messages: 52
Registered: April 2013
Member
Does m from m.referenceToMyXXXModelElement is for the rule XXXtoModelType or not?
Re: How to specify in the rule that one element contain another [message #1065751 is a reply to message #1065723] Thu, 27 June 2013 07:34 Go to previous message
Hugo Bruneliere is currently offline Hugo Bruneliere
Messages: 588
Registered: July 2009
Senior Member
No, "m" is the "m : UML!Model" input model element.
Then, as I told before, ATL is going to make automatically the resolution according to the corresponding output elements created by other rules.


------------------------------------------
Hugo Bruneliere - R&D Engineer
AtlanMod research team (Inria, EMN & LINA)
Ecole des Mines de Nantes
Nantes - France
------------------------------------------
Previous Topic:Problem with Helper
Next Topic:No output file (or model) after execution
Goto Forum:
  


Current Time: Wed Apr 16 20:57:19 EDT 2014

Powered by FUDForum. Page generated in 0.02105 seconds