Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Read the value of properties of stereotype in Acceleo(Read the value of properties of stereotype in Acceleo)
Read the value of properties of stereotype in Acceleo [message #1808548] Wed, 26 June 2019 16:26 Go to next message
Mohammad Inayatullah is currently offline Mohammad InayatullahFriend
Messages: 21
Registered: May 2019
Junior Member
I have Stereotype given below
index.php/fa/35825/0/

I am consuming this stereotype for the property highlighted in given model
index.php/fa/35826/0/

i want to read the value of properties of stereotype in acceleo code generator.
the place where i want to get the values is highlighted in the given code
index.php/fa/35827/0/

Can any one please guide me that how can i do this..

Thanks
  • Attachment: stereotype.PNG
    (Size: 15.46KB, Downloaded 487 times)
  • Attachment: model.PNG
    (Size: 18.61KB, Downloaded 444 times)
  • Attachment: code.PNG
    (Size: 28.48KB, Downloaded 455 times)
Re: Read the value of properties of stereotype in Acceleo [message #1808553 is a reply to message #1808548] Wed, 26 June 2019 17:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

By providing only snapshots, you deny us the opportunity to extend your examples in order to demonstrate solutions.

Acceleo does not use an OCL with typesafe Stereotype navigation so you have to use the Eclipse UML2 getAppliedStereotype() etc Java API.

If you Google "Acceleo getAppliedStereotype", you will find that the first hit is the Getting Started tutorial that you should have already read.

Regards

Ed Willink
Re: Read the value of properties of stereotype in Acceleo [message #1808573 is a reply to message #1808553] Thu, 27 June 2019 02:58 Go to previous messageGo to next message
Mohammad Inayatullah is currently offline Mohammad InayatullahFriend
Messages: 21
Registered: May 2019
Junior Member
Thanks for you help and i am so sorry for only snapshots
Can you please guide me that what code i have to place in the given below code for stereotypes

[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 (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')]


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]
Re: Read the value of properties of stereotype in Acceleo [message #1808575 is a reply to message #1808573] Thu, 27 June 2019 04:49 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Still no repro.

SEe http://devsolstice.blogspot.com/2012/04/acceleo-uml-profiles-papyrus-good.html

Regards

Ed Willink
Re: Read the value of properties of stereotype in Acceleo [message #1808608 is a reply to message #1808575] Thu, 27 June 2019 17:50 Go to previous messageGo to next message
Mohammad Inayatullah is currently offline Mohammad InayatullahFriend
Messages: 21
Registered: May 2019
Junior Member
Thanks Ed Willink you alway help me very well. Your given link help me.
i used the following code and it resolved my problem very well

[ '[' /]Column(TypeName = "[p.getTaggedValue(p, p.getApplicableStereotype('PropertiesProfile::dbtypes').qualifiedName, 'datatype')/]([p.getTaggedValue(p, p.getApplicableStereotype('PropertiesProfile::dbtypes').qualifiedName, 'length')/])")[ ']' /]


[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/]

Thanks again for your help

[Updated on: Thu, 27 June 2019 17:51]

Report message to a moderator

Re: Read the value of properties of stereotype in Acceleo [message #1808618 is a reply to message #1808608] Thu, 27 June 2019 20:19 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

(One day Acceleo may catch up with the first class Stereotype support prototyped in the Pivot-based Eclipse OCL that supports the typesafe [p.extension_dbtypes.datatype/] as hinted at by the UML specification.)

Regards

Ed Willink
Previous Topic:[Acceleo] For loop on Set<Class> is not working
Next Topic:Find Multiplicity of association in acceleo
Goto Forum:
  


Current Time: Fri Apr 19 23:23:59 GMT 2024

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

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

Back to the top