Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » getProfile() and organizing stereotypes in subpackages
getProfile() and organizing stereotypes in subpackages [message #628040] Wed, 11 November 2009 08:02 Go to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
Hi, (3 concrete questions at the end of this posting)

I'm creating a profile with stereotypes, which works well. Now I want to organize my stereotypes a little bit, so I added packages to the profile and then added stereotypes inside those packages (so the profile owns packages, which own stereotypes). No problem so far. Also, creating a metaclass reference works fine, of course:
profile.createMetacl​assReference(metacla​ss);
But then I run into a problem (exception) when I want to create an extension for a stereotype in one of those packages:
stereotype.createExtension(metaclass, false);
The reason is, that inside createExtension the method getProfile() is called for the stereotype, which returns null in this case (and not null for a stereotype that is owned directly by the profile). Then I found the following workaround:
org.eclipse.uml2.uml.Package p = st.getPackage();
stereotype.setPackage(profile);
stereotype.createExtension(metaclass, false);
stereotype.setPackage(p);
This seems to work, but looks like a hack (I've not tried to apply such a stereotype to a model element, this will be my next step). So, I've got these questions:
1. Are packages feasible to organize the stereotypes of a profile, or is there another (or no existing) approach?
2. Is this workaround ok? (shall I post the resulting XMI?)
3. Is the described behavior of getProfile() intended or a bug?
Re: getProfile() and organizing stereotypes in subpackages [message #628070 is a reply to message #628040] Tue, 17 November 2009 08:15 Go to previous messageGo to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
OK, it doesn't work: a stereotype owned by a package cannot be applied, again because stereotype.getProfile() returns null.

Next, I'm trying to build a hierarchy of profiles and see if this is a solution to organize my stereotypes a little bit. I'll get back to you.
Re: getProfile() and organizing stereotypes in subpackages [message #628088 is a reply to message #628040] Sun, 22 November 2009 15:39 Go to previous message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
Just wanted to let you know that building a hierarchy of profiles and adding stereotypes to any of the profile instances works. Just take care that when you want to be able to apply all the stereotypes, then it is not sufficient to just call profile.define() for the top profile. It is needed to iterate through the whole profile tree and call the define method on all profile instances.

Thomas
Previous Topic:[Solved] getProfile() and organizing stereotypes in subpackages
Next Topic:C++ & UML
Goto Forum:
  


Current Time: Thu Apr 25 03:39:51 GMT 2024

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

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

Back to the top