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: 88
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 Damus is currently offline Christian DamusFriend
Messages: 1221
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: 6934
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: 88
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: 88
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: 6934
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: 88
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 messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6934
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
Re: problems saving stereotypes [message #1834948 is a reply to message #1800647] Sat, 21 November 2020 18:24 Go to previous messageGo to next message
gary s thompson is currently offline gary s thompsonFriend
Messages: 88
Registered: July 2009
Member
Hi Ed and Kevin

It seems like archaeology but I am at last back on the project with the recalcitrant stereotypes. I have had a go at modifying the introduction to url profiles project as described in the bug report and your replies. Please see the attached file. I wonder if it would begged to add this to the introprofiles example shipped with uml2

regards
Gary
Re: problems saving stereotypes [message #1834949 is a reply to message #1834948] Sat, 21 November 2020 18:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6934
Registered: July 2009
Senior Member
Hi

I suggest raising a new Bugzilla, describing and attaching the improvement. Reference Bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=543231 and this message.

Regards

Ed Willink
Re: problems saving stereotypes [message #1834967 is a reply to message #1800647] Sun, 22 November 2020 15:04 Go to previous messageGo to next message
gary s thompson is currently offline gary s thompsonFriend
Messages: 88
Registered: July 2009
Member
Dear Ed, Christian and Kenn et al

More fun and games, I have this working with my own project but have had to apply a hack! After a certain amount of hacking I have found that the saved uml file for the model with the profile applied doesn't seem to be picking up the profile when its saved. So the header of the file doesn't have the correct xmi stanza for the profile attached:

non working:

<?xml version="1.0" encoding="ASCII"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ccpn="http://ccpn.ac.uk/profiles/ccpn" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML">
<uml:Model xmi:id="_Mx3NcCzGEeuc98ICDErXzA" name="Root" URI="guid:/Root_www.ccpn.ac.uk_RasmusFogh_2006-06-21-19:13:29_00000">

working:

<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ccpn="http://ccpn.ac.uk/profiles/ccpn" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://ccpn.ac.uk/profiles/ccpn CCPN.profile.uml#_MHdPwBJQEemRH-d3KnRTFg">

as you can see the components,
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" and
xsi:schemaLocation="http://ccpn.ac.uk/profiles/ccpn CCPN.profile.uml#_MHdPwBJQEemRH-d3KnRTFg"

are missing...

the main difference between my code and the example code is that I am reading my profile in from a file rather than creating it in memory, could this be the problem?

so others can see what things look like with a 'detached profile' (I am sure you have see it before ;-) ) I include a photo of the uml file loaded with a 'detached profile'.

index.php/fa/39385/0/

regards
Gary




[Updated on: Sun, 22 November 2020 15:15]

Report message to a moderator

Re: problems saving stereotypes [message #1834973 is a reply to message #1834949] Sun, 22 November 2020 15:37 Go to previous message
gary s thompson is currently offline gary s thompsonFriend
Messages: 88
Registered: July 2009
Member
Hi Ed

done, https://bugs.eclipse.org/bugs/show_bug.cgi?id=569035 !

I am not sure what you would write about this in the description of how to do it in the UI (ergo I have no idea how to do it in the ui or even if it works...)

regards
gary
Previous Topic:Profile definition results in dangling references when using a model library
Next Topic:Programatically load and save sequence diagram
Goto Forum:
  


Current Time: Mon Nov 30 02:43:10 GMT 2020

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

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

Back to the top