Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » set stereotype attribute to other stereotype
set stereotype attribute to other stereotype [message #476628] Thu, 15 November 2007 11:07 Go to next message
Eclipse UserFriend
Originally posted by: David.Ouagne.spim.jussieu.fr

Hi,

I want set stereotype attribute to other stereotype. How to that ?

I can get value by using UMLUtil.

Thanks
Re: set stereotype attribute to other stereotype [message #476631 is a reply to message #476628] Thu, 15 November 2007 16:01 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
Could you clarify? Do you want to have a stereotype property whose type
is another stereotype, or do you want to "stereotype a stereotype"
(apply one stereotype to another)?

If it is the latter, see if this thread helps:

http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2/msg01378.html

Cheers,

Rafael

David Ouagne wrote:
> Hi,
>
> I want set stereotype attribute to other stereotype. How to that ?
>
> I can get value by using UMLUtil.
>
> Thanks
>
Re: set stereotype attribute to other stereotype [message #476633 is a reply to message #476631] Thu, 15 November 2007 16:21 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
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 Go to previous message
Eclipse UserFriend
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 #625469 is a reply to message #476628] Thu, 15 November 2007 16:01 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
Could you clarify? Do you want to have a stereotype property whose type
is another stereotype, or do you want to "stereotype a stereotype"
(apply one stereotype to another)?

If it is the latter, see if this thread helps:

http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.u ml2/msg01378.html

Cheers,

Rafael

David Ouagne wrote:
> Hi,
>
> I want set stereotype attribute to other stereotype. How to that ?
>
> I can get value by using UMLUtil.
>
> Thanks
>
Re: set stereotype attribute to other stereotype [message #625471 is a reply to message #476631] Thu, 15 November 2007 16:21 Go to previous message
Eclipse UserFriend
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 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
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 Go to previous message
Eclipse UserFriend
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.
Previous Topic:How to programmatically add an element as an owned element of another
Next Topic:Generalization of an Aggregation
Goto Forum:
  


Current Time: Fri Apr 26 00:48:17 GMT 2024

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

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

Back to the top