[Acceleo] Cast between two metamodels [message #529628] |
Mon, 26 April 2010 15:11 |
Nicolas Guyomar Messages: 29 Registered: February 2010 Location: Nantes (France) |
Junior Member |
|
|
Hi everyone
I'm trying to generate code from two metamodels, MA and MB.
The problem I'm facing is the following:
I have a class B in MB, which inherits from class A in MA.
I'd like to access some attributes in B, while I'm browsing classes A and B, like a basic Cast in java
Unfortunately, oclAsType() method works fine while I'm using classes from the same Metamodel, not if I want to use it with A and B like :
a.oclAsType(B), I get "Unrecognized variable: (B)" in
[template public write(a : A)]
[for (n : Node | a.children)]
[if (n.oclIsKindOf(Attribute))]
[n.oclAsType(B).write()/]
[/if]
[/for]
[/template]
Is there another way I'm not aware of to do this? maybe not using OCL ?
Regards
Nicolas
Nicolas Guyomar
http://www.eclipse.org/MoDisco/
http://www.eclipse.org/modeling/emft/facet/
|
|
|
Re: [Acceleo] Cast between two metamodels [message #529782 is a reply to message #529628] |
Tue, 27 April 2010 08:24 |
|
This is a multi-part message in MIME format.
--------------040204020007060002080507
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi Nicolas,
I believe OCL is just confused between your metamodels. Would
"a.oclAsType(MB::B)" do the trick?
(I recently made some tweaks in Acceleo so that the use of qualified
names for types will be useless in most cases ... but these changes
haven't been built yet)
Laurent Goubet
Obeo
Nicolas Guyomar wrote:
> Hi everyone
>
> I'm trying to generate code from two metamodels, MA and MB.
> The problem I'm facing is the following:
>
> I have a class B in MB, which inherits from class A in MA.
>
> I'd like to access some attributes in B, while I'm browsing classes A
> and B, like a basic Cast in java
> Unfortunately, oclAsType() method works fine while I'm using classes
> from the same Metamodel, not if I want to use it with A and B like :
> a.oclAsType(B), I get "Unrecognized variable: (B)" in
>
> [template public write(a : A)]
> [for (n : Node | a.children)]
> [if (n.oclIsKindOf(Attribute))]
> [n.oclAsType(B).write()/]
> [/if] [/for]
> [/template]
>
>
> Is there another way I'm not aware of to do this? maybe not using OCL ?
>
> Regards
>
> Nicolas
>
>
>
--------------040204020007060002080507
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------040204020007060002080507--
|
|
|
|
Re: [Solved] [Acceleo] Cast between two metamodels [message #529832 is a reply to message #529799] |
Tue, 27 April 2010 12:03 |
|
This is a multi-part message in MIME format.
--------------040806090006080500040407
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Nicolas,
It is a common syntax in OCL ... but I doubt many people know all of the
different things we can do with OCL :p.
Laurent Goubet
Obeo
Nicolas Guyomar wrote:
> Hi Laurent,
>
> Thank you for your quick answer
>
> The solution you proposed works perfectly, I assume this syntax is
> pretty common in OCL .. shame on me
>
> Thank you again
>
> Nicolas
>
>
--------------040806090006080500040407
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------040806090006080500040407--
|
|
|
Powered by
FUDForum. Page generated in 0.02540 seconds