Profile Support
The current implementation works well for UML diagrams without applied profiles. The idea is to be as much compliant with the Eclipse implementation as possible.
I've performed some tests about deserialization (profile deserialization and model with applied profile deserialization). At the moment, the code is a little ugly, but it works!
The POC state is the following, I'm able to:
- load a profile with its references to the UML metamodel self defined (UML defined in UML)
- load a model which have a profiled applied on it, and see its stereotypes instances
- load the UML metamodel defined in UML
- navigate from a model to the applied profile
- navigate from a profile to the UML metamodel defined in UML
These points currently need some fixes that are present in the PyEcore develop branch.
The final support should include
- these previously mentionned points,
- the implementation of related methods in the code (i.e:
apply_stereotype...), - the profile "definition" (transformation from Profile to Ecore),
- the profile/model serialization in order to be Eclipse-EMF/UML2 compliant.
I will use this issue to report the progresses I made on this POC.
A quick summary about how progresses the POC, the covered points are:
- some of the dedicated functions (
apply_stereotype,get_applied_stereotype) - a first quick
definefunction for Profile - the profile/model serialization which sounds good.
There is more work to do, but most of the problematic points are resolved.
Hello, Is it possible to add in the documentation a code example to load a model with its applied profile from a .uml or .ecore file? Thank you in advance.
Hi @ollierGuillaume
Thanks for reaching about the profiles :). That's a huge point of PyUML2 that is not 100% finished, so it's not on the main/develop branch right now, but on the feature/profiles branch. At the same time, you can check the tests here: https://github.com/pyecore/pyuml2/blob/feature/profiles/tests/test_profiles.py
which will give you more insight about how to load a profile, a file with an applied profile and about functions that could be useful to retrived applied profiles, applied stereotypes...etc.
Thank you for your quick answer! I am trying to load a model using stereotypes packaged in subprofiles (<packagedElement xmi:type="uml:Profile"...). I can iterate on my Stereotype elements for each subprofile when I load the profile model but it seems not working when I try to apply a subprofile on my model. Is this case covered by the current version of the library?
Honestly, I'm not sure :sweat_smile:, it's a long time I didn't have the time to work on it, but that's possible that currently sub-profiles are not supported. More generally actually, I think they might be supported, but I think it's the profile application that is not yet fully covered. For loading models, it should be fine, but for applying stereotypes, I don't remember well.
Looking at the code, it looks like the apply_stereotype method is implemented https://github.com/pyecore/pyuml2/blob/951416fe2e553012ff9e7bbdac7f82b56ac501cc/pyuml2/uml_mixins.py#L68-L77
so I guess, perhaps sub-profiles are not supported.
Thank you for your help. Actually, I am blocked before this step, and my profile URI is not recognize. I tried to change in the file applied.uml one character in the profile reference "testProfile.profile.uml#_uEUhcDNiEei1Zri9xPBGPQ" to "testProfile.profile.uml#_uEUhcDNiEei1Zri9xPBGPR" and I saw that it reproduces the exact same error (this reference appear in xmi:XMI schemaLocation and references href). The .uml file produced by my Papyrus version contains a reference with another format: OLDAS.profile.uml#//DomainOntology. Then I think I need to find how to replace "//DomainOntology" with the good reference.
It's a little bit hard to tell without the files, but perhaps there is something that is not yet fully registered properly in the ResourceSet. If your file references another profile (the OLDAS.profile.uml, I think you should load it, but I'm not certain it's 100% necessary because of the way the profiles and stereotypes are handled.
If you can share the files with me, I can try to take a look to help you with. I might take few days tough, I might not have access properly to a machine for the next 4 days.
EDIT> If you cannot share the files with me for privacy or security reasons, try to forge a minimal example and feel free to send them to me by email :)