Generalization relationship between stereotypes [message #1058852] |
Wed, 15 May 2013 08:08  |
Eclipse User |
|
|
|
Hello,
Let's say that I have a UML profile defining a base stereotype called MyBaseStereo; the profile also defines a specialization of it, called MyDerivedStereo.
Now, let's say that I have an UML Model processed by a QVTo transform; in this Model I have a Class which I want to be stereotyped as MyDerivedStereo, because, conceptually, the Class _is_a_ MyDerivedStereo (and in turn is also a MyBaseStereo).
I apply the stereotype as myClass.applyStereotype(MyDerivedStereo) and it is correctly recognized as applied, but if I call myClass.isStereoTypeApplied(MyBaseStereo), this one returns false. Why this? How does the generalization relationship work for stereotypes?
EDIT: I forgot to say that if I apply the stereotype MyDerivedStereo, I'm also able to set values for properties defined in the base stereotype (myClass.setValue(MyBaseStereo, "attribute", attributeValue). Therefore, the base stereotype _is_ applied. But I'm not able to "detect" this fact by using myClass.isStereoTypeApplied(MyBaseStereo), and it becomes a pain when I want to select all the classes from a set that _are_ MyBaseStereo elements (stereotyped, e.g., as MyDerivedStereo1, MyDerivedStereo2, etc., that derive from MyBaseStereo) and that are collected in a set with other classes that are not stereotyped that way. Maybe is isStereoTypeApplied() not the right function to call?
--
Matteo
[Updated on: Thu, 16 May 2013 05:22] by Moderator
|
|
|
|
Re: Generalization relationship between stereotypes [message #1060450 is a reply to message #1058852] |
Fri, 24 May 2013 13:02   |
Eclipse User |
|
|
|
Hi
IMHO Sterteotype generalization should work and the MDT/UML2 library
endeavours to support them and so MMT/QVTo should just work since it
just reuses MDT/UML2.
I suggest doing some Java API experiments with MDT/UML2 to see what
actually happens.
Regards
Ed Willink
On 15/05/2013 13:08, Matteo M. wrote:
> Hello,
>
> Let's say that I have a UML profile defining a base stereotype called
> MyBaseStereo; the profile also defines a specialization of it, called
> MyDerivedStereo.
>
> Now, let's say that I have an UML Model processed by a QVTo transform;
> in this Model I have a Class which I want to be stereotyped as
> MyDerivedStereo, because, conceptually, the Class _is_a_
> MyDerivedStereo (and in turn is also a MyBaseStereo).
>
> I apply the stereotype as myClass.applyStereotype(MyDerivedStereo) and
> it is correctly recognized as applied, but if I call
> myClass.isStereoTypeApplied(MyBaseStereo), this one returns false. Why
> this? How does the generalization relationship work for stereotypes?
>
> --
> Matteo
|
|
|
Re: Generalization relationship between stereotypes [message #1060516 is a reply to message #1060450] |
Sat, 25 May 2013 18:08  |
Eclipse User |
|
|
|
Hi,
Let's consider mentioned hierarchy of stereotypes (MyDerivedStereo extends MyBaseStereo) and given that MyDerivedStereo is applied to myClass with 'myClass.applyStereotype(MyDerivedStereo)' function call.
Code snippet I gave was taken from the 'org.eclipse.uml2.uml_4.1.0' plug-in. It clearly shows that UML implementation doesn't consider stereotypes' hierarchy in method .isStereotypeApplied().
On the other side for property which is defined in MyBaseStereo stereotype the .getValue(MyDerivedStereo, "propertyFromBase") call returns correct value.
The reason is that UML operates on 'eAllStructuralFeatures' in stereotype therefore takes into account properties from the base stereotype.
In other words while .isStereotypeApplied(MyBaseStereo) returns 'false' the method .getValue(MyDerivedStereo, "propertyFromBase") / .setValue(MyDerivedStereo, "propertyFromBase") correctly
operates with the properties from the base stereotype.
Note that in QVT snippet I gave I made typo and method 'getAppliedStereotypes()' should be used instead of 'getApplicableStereotypes()'.
Regards,
Sergey
|
|
|
Powered by
FUDForum. Page generated in 0.06126 seconds