getProfile() and organizing stereotypes in subpackages [message #628040] |
Wed, 11 November 2009 08:02 |
Thomas Neustupny 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.createMetaclassReference(metaclass);
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?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03765 seconds