Find Multiplicity of association in acceleo [message #1808713] |
Sat, 29 June 2019 18:19 |
Mohammad Inayatullah 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.
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/]
|
|
|
|
Powered by
FUDForum. Page generated in 0.03095 seconds