Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Find Multiplicity of association in acceleo(Find Multiplicity of association in acceleo)
Find Multiplicity of association in acceleo [message #1808713] Sat, 29 June 2019 18:19 Go to next message
Mohammad Inayatullah is currently offline Mohammad InayatullahFriend
Messages: 21
Registered: May 2019
Junior Member
I have the UML diagram given below. i want to find out the multiplicity of association in acceleo. can you please guide me that how can i do this.
index.php/fa/35845/0/

My code is given below

[comment encoding = UTF-8 /]
[module generate('http://www.eclipse.org/uml2/5.0.0/UML')]


[template public generateElement(aClass : Class)]
[comment @main/]
[file (aClass.name + '.cs', false, 'UTF-8')]
public class [aClass.name.toUpperFirst()/] {
[for (a: Association | aClass.getAssociations())]

[if a.ownedEnd.type = a.ownedEnd.getOtherEnd().type]
[a.visibility/] [a.endType.name/] [a.endType.name.toLowerFirst()/];
[else]

[for (p: Property | a.ownedEnd -> select (type <> aClass))]
[p.visibility/] [p.type.name/] [p.type.name.toLowerFirst()/];
[/for]
[/if]

[/for]

[for (p: Property | aClass.attribute) separator('\n')]
private [p.type.name.toLowerFirst()/] [p.name.toLowerFirst()/];
[/for]

public [aClass.name/] ()
{
}

[for (p: Property | aClass.attribute) separator('\n')]
[p.getClassPropertyAttribute(p, p.getApplicableStereotype('PropertiesProfile::dbtypes').qualifiedName)/]

public [p.type.name/] [p.name.toUpperFirst()/] {
get
{
return this.[p.name.toLowerFirst()/];
}

set
{
this.[p.name.toLowerFirst()/] = value;
}
}
[/for]

[for (o: Operation | aClass.ownedOperation) separator('\n')]
public [o.type/] [o.name/]() {
//TODO: should be implemented
}
[/for]
}
[/file]
[/template]

[query public getTaggedValue(stereotypedElement : Element, stereotypeName : String, propertyName : String) : OclAny =
let stereotype : Stereotype = stereotypedElement.getAppliedStereotype(stereotypeName) in
if not stereotype.oclIsUndefined() then
if propertyName ='datatype' then
stereotypedElement.getValue(stereotype, propertyName).oclAsType(EnumerationLiteral).name
else
stereotypedElement.getValue(stereotype, propertyName)
endif
else
null
endif/]

[query public getClassPropertyAttribute(stereotypedElement : Element, stereotypeName : String) : OclAny =
let stereotype : Stereotype = stereotypedElement.getAppliedStereotype(stereotypeName) in
if not stereotype.oclIsUndefined() then
'[Column(TypeName = "'+ stereotypedElement.getValue(stereotype, 'datatype').oclAsType(EnumerationLiteral).name+'('+stereotypedElement.getValue(stereotype, 'length')+')"]'
else
null
endif/]
Re: Find Multiplicity of association in acceleo [message #1808716 is a reply to message #1808713] Sat, 29 June 2019 21:47 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You really ought to be able to sort this out for yourself.

How can you have found getOtherEnd() but not seen lower/upper?

Use the UML 2.5 specification. It's very usable compared to its predecessors.

Regards

Ed Willink

[Updated on: Sun, 30 June 2019 05:10]

Report message to a moderator

Previous Topic:Read the value of properties of stereotype in Acceleo
Next Topic:Comparison for upperbound is not working
Goto Forum:
  


Current Time: Tue Apr 23 13:26:54 GMT 2024

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

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

Back to the top