Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » problems saving stereotypes
problems saving stereotypes [message #1800647] Fri, 04 January 2019 11:15 Go to next message
gary s thompson is currently offline gary s thompsonFriend
Messages: 83
Registered: July 2009
Member
Dear All

I have been trying to apply stereotypes to a uml2 model using the code in Introduction to UML2 profiles. After some head scratching (see previous post https://www.eclipse.org/forums/index.php/t/1093776/) I have now been able to apply stereotypes to my model in memory. However, when I save the model to disk and open it in papyrus the stereotypes don't appear to be applied. is there anything I am missing? One though I had was do the loaded profile and the file being saved need to share the same resource set?

One other question in parsing, does every package that has a class with a stereotype applied need to have a reference to the profile, created with applyProfile, or does the profile cascade down package hierarchy (ie do we only need to load the profile on the root of the model; I thinks its the former)?

Finally can someone tell me the difference to static and dynamic emf profiles, the article that goes with 'Introduction to UML2 profiles' alluded to this but only uses dynamic profiles

In advance thanks for any help

regards
Gary
Re: problems saving stereotypes [message #1800651 is a reply to message #1800647] Fri, 04 January 2019 13:25 Go to previous messageGo to next message
Christian W. Damus is currently offline Christian W. DamusFriend
Messages: 1199
Registered: July 2009
Location: Canada
Senior Member

Hi, Gary,

Did you remember to add your stereotype applications (instances) to the contents of the resource before saving it? This will happen automatically if your UML package is already in the resource before any stereotypes are applied to elements. Otherwise, you may have to track down all the stereotype applications and add them yourself. Note that the return result from Element::applyStereotype(...) is the stereotype application/instance that needs to be added to the Resource::getContents() list.

Profiles applied to a package are implicitly applied to all packages within it. However, it's possible that a Packages within a Component don't "see" profiles applied to packages containing the component, but of course I would never recommend putting packages in components anyways.

A "static profile" is just a profile that has been imported into an EMF generator model (*.genmodel) and generated to code. So, it provides a generated Java API and EPackage implementation for working with stereotype instances, just like any other EMF-generated model (including UML, itself). It can be easier to manipulate the properties of stereotypes this way, rather than relying on the Element::set/getValue(Stereotype, ...) API.

HTH,
Christian
Re: problems saving stereotypes [message #1800653 is a reply to message #1800647] Fri, 04 January 2019 13:30 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6588
Registered: July 2009
Senior Member
gary s thompson wrote on Fri, 04 January 2019 06:15
One though I had was do the loaded profile and the file being saved need to share the same resource set?


Multiple ResourceSets can be useful to handle multiple model systems. However you are operating on a single model-system, so I would question why you are using multiple ResourceSets.

Regards

Ed Willink
Re: problems saving stereotypes [message #1800688 is a reply to message #1800653] Sat, 05 January 2019 14:39 Go to previous messageGo to next message
gary s thompson is currently offline gary s thompsonFriend
Messages: 83
Registered: July 2009
Member
Hi Ed

I wasn't sure how they needed to be connected up but after thought it is clear they have to go together, and after some digging in other model this does make sense.

regards
Gary
Re: problems saving stereotypes [message #1800704 is a reply to message #1800651] Sun, 06 January 2019 11:50 Go to previous messageGo to next message
gary s thompson is currently offline gary s thompsonFriend
Messages: 83
Registered: July 2009
Member
Hi Christian

Quote:
Did you remember to add your stereotype applications (instances) to the contents of the resource before saving it? This will happen automatically if your UML package is already in the resource before any stereotypes are applied to elements. Otherwise, you may have to track down all the stereotype applications and add them yourself. Note that the return result from Element::applyStereotype(...) is the stereotype application/instance that needs to be added to the Resource::getContents() list.


No I hadn't, I am afraid it wasn't at all obvious that I needed to do this! However, having done it it worsk, even though it does seem very counter intuitive. I guess my expectation was that an in memory structure would be created and then added to a resource afterwards and everything gets saved to disc .... It just work a bit different to (my typical) expectations.

I hope you don't mind if I ask why stereotypes behave this way as it does seem rather odd ;-)


regards
Gary
Re: problems saving stereotypes [message #1800707 is a reply to message #1800704] Sun, 06 January 2019 16:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6588
Registered: July 2009
Senior Member
Hi

It is a fairly widespread EMF (and UML2) policy that the caller is responsible for establishing the relationships (especially containment) of created objects. For low level functionality, anything else would be even more irritating. EMF provides help diagnosing the problem by complaining if a save involves orphan objects.

For high level functionality, M2M tools tend to put all orphan objects at the root of some Resource so that the user can examine all the root orphans that have not been adequately transformed.

It seems that UML2 functionality is falling between these two stools. I think it reasonable to expect that a failure to save an applied profile should give a diagnostic either at the time of save or at the time of unsatisfactory application. Probably worth a Bugzilla. (Perhaps UML2's CacheAdapters are defeating EMF's orphan detection.)

Regards

Ed Willink
Re: problems saving stereotypes [message #1800747 is a reply to message #1800707] Mon, 07 January 2019 17:31 Go to previous messageGo to next message
gary s thompson is currently offline gary s thompsonFriend
Messages: 83
Registered: July 2009
Member
Hi

Once again thank you for the helpful insights

So a quick question, if

Quote:
It is a fairly widespread EMF (and UML2) policy that the caller is responsible for establishing the relationships (especially containment) of created objects.


where is the correct place to save the stereotype Applications is it in the root of the storage or is there somewhere more granular within the model to put them?


regards
Gary
Re: problems saving stereotypes [message #1800776 is a reply to message #1800747] Tue, 08 January 2019 07:01 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6588
Registered: July 2009
Senior Member
gary s thompson wrote on Mon, 07 January 2019 12:31
where is the correct place to save the stereotype Applications is it in the root of the storage or is there somewhere more granular within the model to put them?


Well when you ask so directly, there can only be one answer:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=543231

(Stereotype Applications have to be at the Resource root.)

At MODELS 2018, in the context of OCL evaluation of stereotype constraints, I happened to discuss this generally deficient UML area with Ed Seidewitz and he agreed that there is a missing class, but observed that each vendor now had a proprietary workaround that made standardisation nearly impossible.

Regards

Ed Willink
Previous Topic:problem with IntroductionToUML2Profiles
Next Topic:Ecore to UML
Goto Forum:
  


Current Time: Fri Feb 21 13:59:00 GMT 2020

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

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

Back to the top