Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Question about stereotype Instance
Question about stereotype Instance [message #1738170] Sat, 16 July 2016 21:26 Go to next message
Chung-Ling Lin is currently offline Chung-Ling LinFriend
Messages: 39
Registered: December 2011
Member
Hi,

The original thread is posted in the OCL forum, but my latest question seems related to the UML than OCL, so I create a new topic and post my question again.

Quote:
Therefore when you define a stereotyped element <<YYY>>XXX at M1, you
define a compound type of XXX (also defined at M1) and YYY (defined in a
profile at M2). However the instance of this compound at M0 is an
instance of XXX with navigation relationships base_XXX/extension_YYY to
an instance of an instance of YYY. UML neglects to reify the
intermediate instance and so when serialized to UML it requires XMI
trickery. The Pivot OCL reifies the intermediate so that if you navigate
using Pivot AS objects rather than UML objects you find that the
instance of ocl::Class namedXXX has navigation relationships base_XXX
and extension_YYY to an instance of ocl::ElementExtension which is an
ocl::Class and an 'instance' of ocl::Stereotype named YYY.


Based on the explaination above, I feel confused about the navigation to the instance of the instance of a stereotype in the following paragraph: "However the instance of this compound at M0 is an instance of XXX with navigation relationships base_XXX/extension_YYY to an instance of an instance of YYY."
Therefore, I draw the models below to illustrate my understanding of the UML spec and the explanation above.

http://i.imgur.com/zGhPIFh.png
Fig 1
http://i.imgur.com/X9Jd8oZ.png
Fig 2

Consider that we have a stereotype Clock extends metaclass Class, based on the UML spec, the notation of the extends relationship is represented as figure 1, and figure 2 shows that the extends relationship is an association between Class and Clock.

http://i.imgur.com/3aYjT7m.png
Fig 3
http://i.imgur.com/yL23qtt.png
Fig 4

Therefore, if I define a stereotyped element <<Clock>>StopWatch, the corresponding class diagram is shown in figure 3. If I use instance diagram notation to represent this M1 model as figure 4, the Extension between the Stereotype and the metaclass Class results in a link between the instance of Stereotype Clock and StopWatch.

http://i.imgur.com/WzBaaKv.png
Fig 5
Based on my understanding of your explanation, I draw the M0 diagram shown as figure 5. Therefore, the instance of this compound type, MyWatch, is an instance of StopWatch with navigation relationships base_Class/extension_Clock to an instance of an instance of Clock.

But what I don't understand is, since the extends relationship is defined as an association in M2, I understand that we have a link between the StopWatch and the instance of Clock in M1. Since MyWatch:StopWatch is an instance of StopWatch in M0, why this object still have a link to navigate the instance of instance of Clock?

Best Regards,
Chung-Ling Lin
Re: Question about stereotype Instance [message #1738175 is a reply to message #1738170] Sun, 17 July 2016 11:25 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Chung-Ling Lin,

I see what look like figure titles in your post, but no images.

In any case, you can think of stereotype instances (the UML2 API refers
to them as 'stereotype applications') as looking and feeling much like
any other element in the model that is defined by UML. In fact, as far
as EMF/Ecore and Java are concerned, stereotypes are just user-defined
metaclasses that happen to have required associations (references) to
UML elements. If you generate a Java API for your profile, this is
even more clear.

So, in the UML2 implementation based on Ecore and Java, the metaclass
extensions are associations (realized as EReferences) like any of the
associations/references in UML. The 'base_Xyz' extension-ends (for
example, 'base_Package' for a <<library>> stereotype of the Package
metaclass) in Ecore and/or generated Java API are navigable: they
produce EReferences and Java accessor methods. The 'extension_Abc'
ends (e.g., 'extension_Library' for a <<library>> stereotype of
package) are not realized in Ecore nor in Java. But, the UML2
CacheAdapter API provides for inverse navigation of the 'base_Xyz'
references, so this should not be an obstacle.

HTH,

Christian


On 2016-07-16 21:26:56 +0000, Chung-Ling Lin said:

> Hi,
>
> The original thread is posted in the OCL forum, but my latest question
> seems related to the UML than OCL, so I create a new topic and post my
> question again.
>
> Quote:
>> Therefore when you define a stereotyped element <<YYY>>XXX at M1, you
>> define a compound type of XXX (also defined at M1) and YYY (defined in
>> a profile at M2). However the instance of this compound at M0 is an
>> instance of XXX with navigation relationships base_XXX/extension_YYY to
>> an instance of an instance of YYY. UML neglects to reify the
>> intermediate instance and so when serialized to UML it requires XMI
>> trickery. The Pivot OCL reifies the intermediate so that if you
>> navigate using Pivot AS objects rather than UML objects you find that
>> the instance of ocl::Class namedXXX has navigation relationships
>> base_XXX and extension_YYY to an instance of ocl::ElementExtension
>> which is an ocl::Class and an 'instance' of ocl::Stereotype named YYY.
>
>
> Based on the explaination above, I feel confused about the navigation
> to the instance of the instance of a stereotype in the following
> paragraph: "However the instance of this compound at M0 is an instance
> of XXX with navigation relationships base_XXX/extension_YYY to an
> instance of an instance of YYY." Therefore, I draw the models below to
> illustrate my understanding of the UML spec and the explanation above.
>
>
> Fig 1
>
> Fig 2
>
> Consider that we have a stereotype Clock extends metaclass Class, based
> on the UML spec, the notation of the extends relationship is
> represented as figure 1, and figure 2 shows that the extends
> relationship is an association between Class and Clock.
>
>
> Fig 3
>
> Fig 4
>
> Therefore, if I define a stereotyped element <<Clock>>StopWatch, the
> corresponding class diagram is shown in figure 3. If I use instance
> diagram notation to represent this M1 model as figure 4, the Extension
> between the Stereotype and the metaclass Class results in a link
> between the instance of Stereotype Clock and StopWatch.
>
>
> Fig 5
> Based on my understanding of your explanation, I draw the M0 diagram
> shown as figure 5. Therefore, the instance of this compound type,
> MyWatch, is an instance of StopWatch with navigation relationships
> base_Class/extension_Clock to an instance of an instance of Clock.
> But what I don't understand is, since the extends relationship is
> defined as an association in M2, I understand that we have a link
> between the StopWatch and the instance of Clock in M1. Since
> MyWatch:StopWatch is an instance of StopWatch in M0, why this object
> still have a link to navigate the instance of instance of Clock?
>
> Best Regards,
> Chung-Ling Lin
Re: Question about stereotype Instance [message #1738507 is a reply to message #1738175] Wed, 20 July 2016 12:48 Go to previous messageGo to next message
Chung-Ling Lin is currently offline Chung-Ling LinFriend
Messages: 39
Registered: December 2011
Member
Hi,

Thank you for your information. I compress the figures in my original post in the attachment for your reference. And I also write a simple program to help me understand your explanation.

Here is the summary of my program, and the complete project is attached for your reference:
1) Create a profile "MyProfile"
2) Create a stereotype "Clock" extends UML::Class in my profile
3) Create a domain model "MyDomain"
4) Create a class "StopWatch" in MyDomain, and apply the stereotype Clock to StopWatch
5) Get the stereotype application "sa" of StopWatch
6) Check the EReference of sa and I can see the base_Class is one of the EReference of sa
Quote:
EReference: org.eclipse.emf.ecore.impl.EReferenceImpl@321ca237 (name: base_Class) (ordered: false, unique: true, lowerBound: 1, upperBound: 1) (changeable: true, volatile: false, transient: false, defaultValueLiteral: null, unsettable: false, derived: false) (containment: false, resolveProxies: true)

7) Save MyProfile and MyDomain as .uml files.
8 ) Save MyProfile and MyDomain as ecore models (Failed)

Based on what you mentioned in the reply, I try to generate a Java API of my profile and my domain model so I can understand where these associations are created. Therefore, I need to save my profile and my domain model as .ecore files. In my program, I try to use the DefaultEcoreBuilder to create the ecore resources from my profile and my domain model and save them to .ecore files but it doesn't work. Would you please tell me how can I fix my program or where can I find the references about how to save my models as .ecore files?

Thank you very much for your help.

Best Regards,
Chung-Ling Lin

Re: Question about stereotype Instance [message #1738529 is a reply to message #1738507] Wed, 20 July 2016 14:43 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi,

Exporting UML models and profiles to Ecore is not an explicit step:
it's a side-effect of creating the EMF Generator Model for them. Just
right-click on your UML model or profile in the Project Explorer and
invoke New EMF Generator Model wizard to create the genmodel. From
that point, it's just like generating the code from an Ecore model.

http://wiki.eclipse.org/index.php?title=MDT/UML2/FAQ&cp=64_3_1#Can_I_generate_code_from_my_UML_.28.uml.29_model.3F


HTH,

Christian


On 2016-07-20 12:48:08 +0000, Chung-Ling Lin said:

> Hi,
>
> Thank you for your information. I compress the figures in my original
> post in the attachment for your reference. And I also write a simple
> program to help me understand your explanation.
>
> Here is the summary of my program, and the complete project is attached
> for your reference:
> 1) Create a profile "MyProfile"
> 2) Create a stereotype "Clock" extends UML::Class in my profile
> 3) Create a domain model "MyDomain"
> 4) Create a class "StopWatch" in MyDomain, and apply the stereotype
> Clock to StopWatch
> 5) Get the stereotype application "sa" of StopWatch
> 6) Check the EReference of sa and I can see the base_Class is one of
> the EReference of sa
> Quote:
>> EReference: org.eclipse.emf.ecore.impl.EReferenceImpl@321ca237 (name:
>> base_Class) (ordered: false, unique: true, lowerBound: 1, upperBound:
>> 1) (changeable: true, volatile: false, transient: false,
>> defaultValueLiteral: null, unsettable: false, derived: false)
>> (containment: false, resolveProxies: true)
>
> 7) Save MyProfile and MyDomain as .uml files.
> 8 ) Save MyProfile and MyDomain as ecore models (Failed)
>
> Based on what you mentioned in the reply, I try to generate a Java API
> of my profile and my domain model so I can understand where these
> associations are created. Therefore, I need to save my profile and my
> domain model as .ecore files. In my program, I try to use the
> DefaultEcoreBuilder to create the ecore resources from my profile and
> my domain model and save them to .ecore files but it doesn't work.
> Would you please tell me how can I fix my program or where can I find
> the references about how to save my models as .ecore files?
>
> Thank you very much for your help.
>
> Best Regards,
> Chung-Ling Lin
>
>
> <image><image>
Re: Question about stereotype Instance [message #1738544 is a reply to message #1738529] Wed, 20 July 2016 17:44 Go to previous messageGo to next message
Chung-Ling Lin is currently offline Chung-Ling LinFriend
Messages: 39
Registered: December 2011
Member
Hi,

Thank you for the information. I can create the genmodels and ecore files for the profile and the domain model, and then generate the Java projects from the genmodels.

But the .ecore model of the domain model does not contains the information about the applied profile/stereotype in the ecore model. Therefore, I can't find any information about the applied profile in the Java project generated from the domain model. Is it possible to keep the applied profile information in a ecore model?

Best Regards,
Chung-Ling Lin
  • Attachment: models.zip
    (Size: 4.31KB, Downloaded 205 times)

[Updated on: Wed, 20 July 2016 17:45]

Report message to a moderator

Re: Question about stereotype Instance [message #1738567 is a reply to message #1738544] Wed, 20 July 2016 23:02 Go to previous message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi,

Ecore does not have a concept of stereotypes. The closest analogue of
stereotype applications is annotations for attaching extra
application-specific information to an Ecore model element.

I thought that the UML importer had an option (in the big dialog of
options) to generate annotations from stereotype applications, but I
don't see it now. Perhaps I was imagining it, or it is only supported
for the stereotypes of the Ecore Profile.

Cheers,

Christian


On 2016-07-20 17:44:37 +0000, Chung-Ling Lin said:

> Hi,
>
> Thank you for the information. I can create the genmodels and ecore
> files for the profile and the domain model, and then generate the Java
> projects from the genmodels.
>
> But the .ecore model of the domain model does not contains the applied
> profile/stereotype in the ecore model. Therefore, I can't find any
> information about the applied profile in the Java project generated
> from the domain model. Is it possible to keep the applied profile
> information in a ecore model?
>
> Best Regards,
> Chung-Ling Lin
> <image>
Previous Topic:Dependency hell with org.eclipse.uml2.types and Maven
Next Topic:Regenerating an existing Static Profile from cli/CI?
Goto Forum:
  


Current Time: Fri Apr 19 10:41:15 GMT 2024

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

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

Back to the top