Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Retrieve a Class : from an association in a property / from her name in the model
icon5.gif  [Acceleo] Retrieve a Class : from an association in a property / from her name in the model [message #687999] Thu, 23 June 2011 12:45 Go to next message
David P is currently offline David P
Messages: 2
Registered: June 2011
Junior Member
Hi,

I'm a beginner with Acceleo, and I have a little question to improve my PHP class file generation from the model.

I have two class "A" and "B" linked by a "one to many" association in the UML model, and I would like to know how to retrieve a "Class" object from the end of the association.

On the property of my class "A", I can retrieve the name of the class "B" which is at the end of the association :
[p.association.endType->last().name/]


But in my class A, I would like to read information about my class B pointed by the association like this :

[getValue(myClassB.getAppliedStereotype('default::Classifier'), 'persistence').toString()/]


How can I do that?
Or, How can I retrieve a "Class" object from her String name?
I haven't see a getClass('String') method or something like this Sad

Thanks for your help,

David

[Updated on: Thu, 23 June 2011 12:46]

Report message to a moderator

Re: [Acceleo] Retrieve a Class : from an association in a property / from her name in the model [message #689234 is a reply to message #687999] Mon, 27 June 2011 04:06 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 406
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

I think that the "inverse()" operation may help you in your case. It will allow you to find out the elements that are linked to a given element, it should allow you to find your association and then your class "b" from an "a" element.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo



Re: [Acceleo] Retrieve a Class : from an association in a property / from her name in the model [message #693412 is a reply to message #689234] Wed, 06 July 2011 08:29 Go to previous message
David P is currently offline David P
Messages: 2
Registered: June 2011
Junior Member
Hi,

Thank you for your help. I suppose you talk about "eInverse()" operation in fact? (instead of inverse())
I have tried this one but, from my association, I can find only the property and the class A, but not the class B.

But the solution was more simple in fact! Smile
p.association.endType->last().oclAsType(Class)


I understand now the "oclAsType" usage Smile


Previous Topic:[Acceleo 3.1.0] Module file (.mtl) is not built into a .java file
Next Topic:let expression for a set in XPand and Xtend
Goto Forum:
  


Current Time: Thu Apr 17 23:45:28 EDT 2014

Powered by FUDForum. Page generated in 0.15306 seconds