problems saving stereotypes [message #1800647] |
Fri, 04 January 2019 06:15  |
Eclipse User |
|
|
|
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 08:25   |
Eclipse User |
|
|
|
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 #1835512 is a reply to message #1834973] |
Sat, 05 December 2020 06:59  |
Eclipse User |
|
|
|
I also found that I needed to add the following in my code when saving
xmiResource.defaultSaveOptions.put(XMIResource.OPTION_SCHEMA_LOCATION, true)
but not in the example code....
not quite sure why
|
|
|
Powered by
FUDForum. Page generated in 0.05986 seconds