Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » [Solved] getProfile() and organizing stereotypes in subpackages(Solution: use profile instances as subpackages and call define for them all)
[Solved] getProfile() and organizing stereotypes in subpackages [message #496726] 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?

Thanks in advance,
Thomas

[Updated on: Sun, 22 November 2009 15:40]

Report message to a moderator

Re: getProfile() and organizing stereotypes in subpackages [message #497560 is a reply to message #496726] Fri, 13 November 2009 09:01 Go to previous messageGo to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
I'll try to programmatically apply such a stereotype to a model element and then report here if it works. Does anyone have a comment/answer?

Thomas
Re: getProfile() and organizing stereotypes in subpackages [message #498476 is a reply to message #496726] 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 #499439 is a reply to message #496726] 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:Extending the UML2 metamodel and customizing the ItemProvider super class
Next Topic:getProfile() and organizing stereotypes in subpackages
Goto Forum:
  


Current Time: Thu Apr 25 19:57:20 GMT 2024

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

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

Back to the top