Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [ACCELEO] Associations and attributes
[ACCELEO] Associations and attributes [message #685288] Fri, 17 June 2011 07:30 Go to next message
Harri T. is currently offline Harri T.Friend
Messages: 22
Registered: May 2011
Junior Member

See the attached picture of a UML model. The mtl

// Associations:
[for (p : Property | c.getAssociations().memberEnd)]
// - [p.name/]
[/for]
// Attributes:
[for (p : Property | c.getAllAttributes())]
// - [p.name/]
[/for]

"renders"

for A:
// Associations:
// - a2
// - c
// - a1
// - a
// Attributes:
// - x

for B:
// Associations:
// Attributes:
// - x

for C:
// Associations:
// - c
// - a
// Attributes:


How should I change mtl to make it "render"
- only the other end of associations and
- only the declared attributes, not the inherited ones
? In other words:

for A:
// Associations:
// - a2
// - c
// - a1
// Attributes:
// - x

for B:
// Associations:
// Attributes:

for C:
// Associations:
// - a
// Attributes:

Regards,

Harri
  • Attachment: uml.png
    (Size: 1.92KB, Downloaded 253 times)

[Updated on: Fri, 17 June 2011 08:13]

Report message to a moderator

Re: [ACCELEO] Associations and attributes [message #685383 is a reply to message #685288] Fri, 17 June 2011 12:06 Go to previous messageGo to next message
Harri T. is currently offline Harri T.Friend
Messages: 22
Registered: May 2011
Junior Member

Maybe this is not the most elegant way to do this but at least it works:
    // Associations:
[for (a : Association | c.getAssociations())]
    [let p : Property = a.memberEnd->at(1)]
      [let p2 : Property = a.memberEnd->at(2)]
    // - p.name: [p.name/]
        [if p.type = c and p2.type = c]
    // - p.name: [p2.name/]
        [/if]
      [/let] 
    [/let]
[/for]
    // Attributes:
[for (p : Property | c.getAllAttributes()->select(p | p.type <> self.name and p.class = self))]
    // - [p.name/]
[/for]  
Re: [ACCELEO] Associations and attributes [message #685748 is a reply to message #685383] Sun, 19 June 2011 08:35 Go to previous messageGo to next message
Harri T. is currently offline Harri T.Friend
Messages: 22
Registered: May 2011
Junior Member

Harri T. wrote on Fri, 17 June 2011 08:06
Maybe this is not the most elegant way to do this but at least it works:


Actually the solution above does not resolve the issue because we don't know in which direction the associations are drawn.
Re: [ACCELEO] Associations and attributes [message #685800 is a reply to message #685748] Mon, 20 June 2011 08:04 Go to previous message
Sebastien Roy is currently offline Sebastien RoyFriend
Messages: 51
Registered: November 2009
Member
Hello,
I think that it would be better to check the property source (p.class) instead of the property target (p.type), in order to include it or not into the generated code.

This problem is typically a UML metamodel question. Its solution is in the OMG's UML specifications.

Regards

Sebastien
Previous Topic:xPand strange Problem
Next Topic:[Acceleo] OCL and Query utilisation
Goto Forum:
  


Current Time: Wed Apr 24 22:23:34 GMT 2024

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

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

Back to the top