Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Get applied stereotype from element and access stereotype attribute directly
Get applied stereotype from element and access stereotype attribute directly [message #760314] Thu, 01 December 2011 20:29 Go to next message
Chung-Ling Lin is currently offline Chung-Ling LinFriend
Messages: 39
Registered: December 2011
Member
Hi,

I generated a profile which contains 2 stereotypes: MyBase extends Class and MyAttr extends property. I also create an association connect these two stereotypes therefore MyBase has the attribute MyAttr.
Then I applied this profile to my model so that in my model class Base in an instance of MyBase and owned an attribute a1 which is an instance of MyAttr.

I use the UML2 to load my model and have two questions about it.
1. I try to use below codes to get the applied stereotype of a1 but it get nothing
org.eclipse.uml2.uml.Class Base = (org.eclipse.uml2.uml.Class) it2.next();
//Get a1
Property property = c.getOwnedAttribute("a1", null);
NamedElement NE = (NamedElement)property;
//Get applied stereotype for a1 but get nothing
EList<Stereotype> el= NE.getAppliedStereotypes();
2. In a normal uml model, if I want to access the attribute a1 of class Base, I need to use the UML2 API like Base.getOwnedAttributes(). But since I already build the association for the stereotypes in my profile and applied them to my model. I would like to have such method like Base.getMyAttr() to access the attribute with my own APIs. Is there any way I can do it?

Thanks for your help.
  • Attachment: myprofile.PNG
    (Size: 17.19KB, Downloaded 345 times)
  • Attachment: Mymodel.PNG
    (Size: 17.83KB, Downloaded 302 times)
Re: Get applied stereotype from element and access stereotype attribute directly [message #762340 is a reply to message #760314] Wed, 07 December 2011 22:49 Go to previous messageGo to next message
Chung-Ling Lin is currently offline Chung-Ling LinFriend
Messages: 39
Registered: December 2011
Member
I am sorry that I didn't describe my question clearly. Here is some additional information that about my question.

I followed the "Introduction to UML profiles" tutorial, using the UML editor to generate a profile. To simplify my question, I only create two stereo types within it. MyBase extends class and MyAttr extends property. And I also create an association between MyBase and MyAttr.

Then I followed the "Getting Started with UML2" tutorial to create an instance model and generate class "Base" and an property "Attr" of class Base. After that, I applied my profile to my model, applied Base with stereotype MyBase Attr with stereotype MyAttr and save my model as a .uml file.

Next I write a java program and using UML2 API to read my model and it works well. After I get class Base, I try to use Base.MyAttr() to get its property Attr but there is no such method.

My question is: Is there any setting within my profile I need to check or I need to implement it by myself. If so, could anyone give me some idea how I can do it.
Thanks a lot.
Re: Get applied stereotype from element and access stereotype attribute directly [message #764582 is a reply to message #762340] Mon, 12 December 2011 13:28 Go to previous messageGo to next message
Chung-Ling Lin is currently offline Chung-Ling LinFriend
Messages: 39
Registered: December 2011
Member
I understand that this is a trivial question. But this is the first step of my project.
So any hint or information will be great help for me, thanks.
Re: Get applied stereotype from element and access stereotype attribute directly [message #770344 is a reply to message #764582] Sat, 24 December 2011 00:43 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
To retrieve the value for a tagged value, use Element.getValue(stereotype, propertyName)
Previous Topic:UML 2 3.1.0
Next Topic:Text generation
Goto Forum:
  


Current Time: Thu Apr 18 03:12:36 GMT 2024

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

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

Back to the top