Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[uml2-dev] apply stereotype to an attribute

Hello there,

I have following problem with applying UML2 profile stereotype to an
attribute. I defined database profile (attached in mail). There is
stereotype PrimaryKey which I want to assign to my model's attribute
programmatically.
I loaded profile to a variable, created model, applied the profile.
Then I started filling the model with classes and their attributes.
After creating a class and assigning attributes I wanted to apply
PrimaryKey stereotype to that attribute following example in
documentation. It throws exception

java.lang.IllegalArgumentException:
org.eclipse.uml2.uml.internal.impl.StereotypeImpl@b9b538 (name:
PrimaryKey, visibility: <unset>) (isLeaf: false, visibility: public,
isAbstract: false) (isActive: false, isAbstract: false)

I debugged my code and UML2 code and found that in class
ElementOperations in method getExtension an EClassifier is retrieved
through getClassifier method. Input to the getClassifier method is a
ClassImpl. Its toString method returns this (from debugger):

org.eclipse.uml2.uml.internal.impl.ClassImpl@626fd2 (eProxyURI:
pathmap://UML_METAMODELS/UML.metamodel.uml#Property)

getClassifier returns null because this ClassImpl doesn't have name
field defined.

I tried to apply this stereotype through applyStereotype method of
Property element (attribute) which is assigned to class and it is
assigned to package and the package is assigned to the model.

Can you tell me how can I apply stereotype defined in profile file in
model in memory? Am I something missing?

Thanks in advance.
Laco.

Attachment: database.profile.uml
Description: Binary data


Back to the top