|
|
Re: [ATL] inverse function of refImmediateComposite() [message #548425 is a reply to message #88085] |
Wed, 21 July 2010 18:50 |
|
What about a function that sets the immediate container of a model element?
What I'm doing is building a .uml file by means of a transformation. My source .uml file contains a <Model> element that, in turn, contains a <Class> element, so I want my .atl file to generate the corresponding <Model> and <Class> elements and to make the <Model> element to contain the <Class> element in the target .uml file. So far both elements seem to be unrelated and placed at the top level in the containment hierarchy of the target .uml file.
Thanks for your help. Kindest regards.
/TB
|
|
|
Re: [ATL] inverse function of refImmediateComposite() [message #548475 is a reply to message #548425] |
Thu, 22 July 2010 03:37 |
|
I found the solution to my problem. Once the transformation has instantiated the Model meta-class in the target .uml file it must instantiate the Class meta-class and set the containment relationship using the following code:
rule models {
from
source: profileA!Model
to
target: profileB!Model (
name <- 'bclass_model'
)
}
rule classes {
from
source: profileA!Class
to
target: profileB!Class (
name <- 'Target',
package <- source.package
)
}
The setting of the package attribute does the trick to establish the containment relationship. Do not try to set either the owner or the namespace attributes of the metaclass because ATL considers this as an error, perhaps because such attributes are derived acording to the documentation,
Kindest regards.
/TB
|
|
|
Re: [ATL] inverse function of refImmediateComposite() [message #548496 is a reply to message #88085] |
Thu, 22 July 2010 07:46 |
Sylvain EVEILLARD Messages: 556 Registered: July 2009 |
Senior Member |
|
|
You can also set the eOpposite reference to package so that you get the binding on the Model element instead of the Class element which is maybe more understandable but both works :
rule models {
from
source: profileA!Model
to
target: profileB!Model (
name <- 'bclass_model',
packagedElement <- source.packagedElement
)
}
rule classes {
from
source: profileA!Class
to
target: profileB!Class (
name <- 'Target'
)
}
[Updated on: Thu, 22 July 2010 07:50] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03730 seconds