Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » [ACCELEO] Associations and attributes
[ACCELEO] Associations and attributes [message #685288] Fri, 17 June 2011 03:30 Go to next message
Eclipse UserFriend
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 289 times)

[Updated on: Fri, 17 June 2011 04:13] by Moderator

Re: [ACCELEO] Associations and attributes [message #685383 is a reply to message #685288] Fri, 17 June 2011 08:06 Go to previous messageGo to next message
Eclipse UserFriend
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 04:35 Go to previous messageGo to next message
Eclipse UserFriend
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 04:04 Go to previous message
Eclipse UserFriend
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: Sun May 11 12:16:48 EDT 2025

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

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

Back to the top