Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Accelleo] Access EEnumLiteral's EAnnotation
[Accelleo] Access EEnumLiteral's EAnnotation [message #1699452] Wed, 24 June 2015 12:19 Go to next message
Le Chau Nguyen is currently offline Le Chau NguyenFriend
Messages: 19
Registered: August 2012
Junior Member
Hi Everyone,

This is my model:
https://c1.staticflickr.com/1/386/19081266955_80018ddc08_c.jpg
FootballClub, DancingClub etc are EClass.
FootballClubType, DancingClubType are EENum
And USClub, JapanClub etc. are their EENumLiteral

Normally I can get EAnnotation of EClass like FootballClub, DancingClub by this kind of query:
[self.target.eClass().getEAnnotation('info').details->first().value/]


But, I cannot apply the similar query to get EAnnotation of EENumLiteral or EENum type. This is the query I tried to get EENum's EAnnotation:
[self.target.eGet('clubType').oclAsType(Club::FootballClubType).getEAnnotation('info').details->first().value/]


The error is: "cannot find operation (getEAnnotation(String)) for the type (FootballClubType)"

I believe after casting by oclAsType, I have the FootballClubType which is EENum, so I can get its EAnnotation as I get from EClass. Because both EENum and EClass realizes the interface EModelElement interface that provide "getEAnnotation" operation.

So maybe I have done something wrong?
And how to access to EENumLiteral's EAnnotation? for example I want to read EAnnotation of "USClub".
Is this something like:
[self.target.eGet('clubType').oclAsType(Club::FootballClubType).eGet('USClub').oclAsType(ecore::EENumLiteral).getEAnnotation('info').details->first().value/]
? Are there any way that avoid hard-code "USClub" in the query since clubType already have Literal information?

I have been stuck on this problem for long time and may have to re-design the model to avoid EENum by using EClass only. That's very painful. Please help me if you have any idea, thank you.

[Updated on: Wed, 24 June 2015 12:24]

Report message to a moderator

Re: [Accelleo] Access EEnumLiteral's EAnnotation [message #1699460 is a reply to message #1699452] Wed, 24 June 2015 12:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

There are a variety of complexities regarding EEnumLiterals whose
instances are Enumerator and do not always have a reflective model
content such as eClass(). This may be contributing to your confusion,
but most of your problem seems to be a misunderstanding of meta-levels.

Assuming that by "FootballClubType, DancingClubType are EENum" you mean
that they are modelled by, rather than specialize/derive from.
FootballClubType is therefore a user type and so has no getEAnnotation
method; just as Acceleo shows you.

Similarly FootballClub has no getEAnnotation method until you invoke
eClass() to climb a meta-level

If you want to access the metamodel EAnnotation on FootballClubType you
must use eClass().

(Or if you want to access the model EAnnotation on FootballClubType you
must define FootballClubType as a derivation of EModelElement; this is
usually a bad idea.)

Regards

Ed Willink


On 24/06/2015 13:19, Le Chau Nguyen wrote:
> Hi Everyone,
>
> This is my model:
> FootballClub, DancingClub etc are EClass.
> FootballClubType, DancingClubType are EENum
> And USClub, JapanClub etc. are their EENumLiteral
>
> Normally I can get EAnnotation of EClass like FootballClub,
> DancingClub by this kind of query:
> [self.target.eClass().getEAnnotation('info').details->first().value/]
>
> But, I cannot apply the similar query to get EAnnotation of
> EENumLiteral or EENum type. This is the query I tried to get EENum's
> EAnnotation:
> [self.target.eGet('clubType').oclAsType(Club::FootballClubType).getEAnnotation('info').details->first().value/]
>
>
> The error is: "cannot find operation (getEAnnotation(String)) for the
> type (FootballClubType)"
>
> I believe after casting by oclAsType, I have the FootballClubType
> which is EENum, so I can get its EAnnotation as I get from EClass.
> Because both EENum and EClass realizes the interface EModelElement
> interface that provide "getEAnnotation" operation.
>
> So maybe I have done something wrong?
> And how to access to EENumLiteral's EAnnotation? for example I want to
> read EAnnotation of "USClub".
> Is this something like:
> [self.target.eGet('clubType').oclAsType(Club::FootballClubType).eGet('USClub').oclAsType(ecore::EENumLiteral).getEAnnotation('info').details->first().value/]
> ? Any way that avoid hard-code "USClub" in the query since clubType
> should already have Literal information?
>
> I have been stuck on this problem for long time and may have to
> re-design the model to avoid EENum. That's very painful. Please help
> me if you have any idea, thank you.
Re: [Accelleo] Access EEnumLiteral's EAnnotation [message #1699546 is a reply to message #1699460] Thu, 25 June 2015 01:38 Go to previous message
Le Chau Nguyen is currently offline Le Chau NguyenFriend
Messages: 19
Registered: August 2012
Junior Member
Thanks Ed for your answer.
I see my confusion between meta level and the user class conform the model.
FootballClubType conforms EENum but no way to climb to EENum like EClass by eClass().
So re-design the model to use EClass as your suggestion is the only way.
Previous Topic:Trouble in loading model from Action Handler
Next Topic:Launching Acceleo as plug-in
Goto Forum:
  


Current Time: Fri Apr 26 04:30:40 GMT 2024

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

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

Back to the top