Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Iterate on classes using associations
Iterate on classes using associations [message #1788395] Wed, 30 May 2018 17:19 Go to next message
Dim Gle is currently offline Dim GleFriend
Messages: 5
Registered: April 2018
Junior Member
Hello,
I need to travel from a class to another using an association and I need to have the 'Class Object' in Acceleo because I have to iterate on its methods.
I am able to obtain the name of the target class of the association but I can't use the same trick to obtain the class object because I have a type 'Type'.

I attach my code to explain better my environment .

[template public getPOSTHandler(c : Class)]
[for (a : Association | c.getAssociations())]
[for (s : Stereotype | a.getAppliedStereotypes())]
[if (s.name.equalsIgnoreCase('ConcreteObjectRef')) and (not a.ownedEnd.getOtherEnd()->at(1).type.name.equalsIgnoreCase(c.name) )]

# Obtain Name
[a.ownedEnd.getOtherEnd()->at(1).type.name/]
# What I need to do:
[a.ownedEnd.getOtherEnd()->at(1).type.findPOSTHandler()/]

[/if]
[/for]
[/for]

[/template] 


[template public findPOSTHandler(c : Class)]
[for (op:Operation | c.getAllOperations()) ]
[for (s : Stereotype | op.getAppliedStereotypes())]
[if s.name.equalsIgnoreCase('POSTHandler')]
[op.name/][/if]
[/for]		
[/for]
[/template]




Thank you in advance.
Dim
Re: Iterate on classes using associations [message #1788632 is a reply to message #1788395] Wed, 30 May 2018 19:17 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

In OCL you use oclAsType(T) to cast to a T,

Regards

Ed Willink
Previous Topic:Problem in selecting SoaML MetaModel Uri while creating Acceleo Project?
Next Topic:Does Acceleo support Break and Continue in for loops ?
Goto Forum:
  


Current Time: Thu Apr 18 08:08:04 GMT 2024

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

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

Back to the top