|
|
Re: set stereotype attribute to other stereotype [message #476633 is a reply to message #476631] |
Thu, 15 November 2007 16:21 |
Eclipse User |
|
|
|
Originally posted by: David.Ouagne.spim.jussieu.fr
I define in stereotype a attribute which type is another stereotype. I
want set this attribute but I do not know how. For example, I attempted to
use UMLUtil.setTaggedValue without success.
For information retrieve, I used :
(Property)UMLUtil.getBaseElement((EObject)element.getValue(e lement.getAppliedStereotype(qualifiedNameST),
propertyNameST))
It works well
|
|
|
Re: set stereotype attribute to other stereotype [message #476636 is a reply to message #476633] |
Fri, 16 November 2007 03:08 |
Rafael Chaves Messages: 362 Registered: July 2009 |
Senior Member |
|
|
How do you know how to retrieving the value works if you haven't been
able to set it in the first place?
I had a hard time trying to figure out what your intent with this is, as
it really looks that your final goal should be achieved some other way.
But anyway, you didn't ask for an opinion, so back to your question.
When you say the type of a property is X, when setting the value of the
property, you must specify a value of type X. If the type of the
property is a stereotype, you will need an instance of that stereotype
to set the property value. A stereotype is a special kind of class in a
sense that it can only be instantiated by applying the stereotype to a
target element.
For instance, consider the profile MyProfile and the model MyModel below
(specified in TextUML, a textual notation you probably never heard of,
but you should get the idea):
profile MyProfile;
stereotype bar extends uml::Operation
property b1 : String;
property b2 : Integer;
end;
stereotype foo extends uml::Class
property p1 : bar;
end;
end.
model MyModel
class First
[bar(b1 = "test", b2 = 10)]
operation o1();
end;
class Second
end;
end.
Let's say you start with MyModel as described above and now you want to
apply "foo" to the class "Second" and set the value of "p1" to be the
instance of "bar" applied to First.o1. You could do this (omiting code
for obtaining the elements):
Class first = ...
Operation o1 = first.getOwnedOperation("o1", null, null);
Class second = ...
Stereotype foo = ...
Stereotype bar = ...
EObject barOnO1 = o1.getStereotypeApplication(bar);
UMLUtil.setTaggedValue(second, foo, "p1", barOnO1);
Does that work for you?
Rafael
David Ouagne wrote:
> I define in stereotype a attribute which type is another stereotype. I
> want set this attribute but I do not know how. For example, I attempted
> to use UMLUtil.setTaggedValue without success.
>
> For information retrieve, I used :
> (Property)UMLUtil.getBaseElement((EObject)element.getValue(e lement.getAppliedStereotype(qualifiedNameST),
> propertyNameST))
>
> It works well
>
|
|
|
Re: set stereotype attribute to other stereotype [message #476637 is a reply to message #476636] |
Fri, 16 November 2007 09:18 |
Eclipse User |
|
|
|
Originally posted by: David.Ouagne.spim.jussieu.fr
Well done.
In my solution, I missed this line "EObject barOnO1 =
o1.getStereotypeApplication(bar);"
To answer your question, I use a UML editor (topcased). That's why I can
retrieve value without being able to do it by code.
Thanks again for your help.
|
|
|
|
Re: set stereotype attribute to other stereotype [message #625471 is a reply to message #476631] |
Thu, 15 November 2007 16:21 |
Eclipse User |
|
|
|
Originally posted by: David.Ouagne.spim.jussieu.fr
I define in stereotype a attribute which type is another stereotype. I
want set this attribute but I do not know how. For example, I attempted to
use UMLUtil.setTaggedValue without success.
For information retrieve, I used :
(Property)UMLUtil.getBaseElement((EObject)element.getValue(e lement.getAppliedStereotype(qualifiedNameST),
propertyNameST))
It works well
|
|
|
Re: set stereotype attribute to other stereotype [message #625474 is a reply to message #476633] |
Fri, 16 November 2007 03:08 |
Rafael Chaves Messages: 362 Registered: July 2009 |
Senior Member |
|
|
How do you know how to retrieving the value works if you haven't been
able to set it in the first place?
I had a hard time trying to figure out what your intent with this is, as
it really looks that your final goal should be achieved some other way.
But anyway, you didn't ask for an opinion, so back to your question.
When you say the type of a property is X, when setting the value of the
property, you must specify a value of type X. If the type of the
property is a stereotype, you will need an instance of that stereotype
to set the property value. A stereotype is a special kind of class in a
sense that it can only be instantiated by applying the stereotype to a
target element.
For instance, consider the profile MyProfile and the model MyModel below
(specified in TextUML, a textual notation you probably never heard of,
but you should get the idea):
profile MyProfile;
stereotype bar extends uml::Operation
property b1 : String;
property b2 : Integer;
end;
stereotype foo extends uml::Class
property p1 : bar;
end;
end.
model MyModel
class First
[bar(b1 = "test", b2 = 10)]
operation o1();
end;
class Second
end;
end.
Let's say you start with MyModel as described above and now you want to
apply "foo" to the class "Second" and set the value of "p1" to be the
instance of "bar" applied to First.o1. You could do this (omiting code
for obtaining the elements):
Class first = ...
Operation o1 = first.getOwnedOperation("o1", null, null);
Class second = ...
Stereotype foo = ...
Stereotype bar = ...
EObject barOnO1 = o1.getStereotypeApplication(bar);
UMLUtil.setTaggedValue(second, foo, "p1", barOnO1);
Does that work for you?
Rafael
David Ouagne wrote:
> I define in stereotype a attribute which type is another stereotype. I
> want set this attribute but I do not know how. For example, I attempted
> to use UMLUtil.setTaggedValue without success.
>
> For information retrieve, I used :
> (Property)UMLUtil.getBaseElement((EObject)element.getValue(e lement.getAppliedStereotype(qualifiedNameST),
> propertyNameST))
>
> It works well
>
|
|
|
Re: set stereotype attribute to other stereotype [message #625475 is a reply to message #476636] |
Fri, 16 November 2007 09:18 |
Eclipse User |
|
|
|
Originally posted by: David.Ouagne.spim.jussieu.fr
Well done.
In my solution, I missed this line "EObject barOnO1 =
o1.getStereotypeApplication(bar);"
To answer your question, I use a UML editor (topcased). That's why I can
retrieve value without being able to do it by code.
Thanks again for your help.
|
|
|
Powered by
FUDForum. Page generated in 0.06236 seconds