Skip to main content


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 14:48 Go to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
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 14: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 15:24 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
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, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
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 15:39 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
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 16:07 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
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, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
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 09:12 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
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 10:22 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
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 15:33 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
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, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
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 09:29 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
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 11:34 Go to previous message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
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, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Previous Topic:Problem with Helper
Next Topic:ATL Metamodel
Goto Forum:
  


Current Time: Fri Mar 29 01:09:34 GMT 2024

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

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

Back to the top