Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile Support #1

Open
aranega opened this issue Jun 13, 2018 · 8 comments
Open

Profile Support #1

aranega opened this issue Jun 13, 2018 · 8 comments
Labels
enhancement New feature or request

Comments

@aranega
Copy link
Member

aranega commented Jun 13, 2018

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.

@aranega aranega added the enhancement New feature or request label Jun 13, 2018
@aranega
Copy link
Member Author

aranega commented Jun 23, 2018

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 define function for Profile
  • the profile/model serialization which sounds good.

There is more work to do, but most of the problematic points are resolved.

@ollierGuillaume
Copy link

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.

@aranega
Copy link
Member Author

aranega commented Aug 31, 2023

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.

@ollierGuillaume
Copy link

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?

@aranega
Copy link
Member Author

aranega commented Aug 31, 2023

Honestly, I'm not sure 😅, 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.

@aranega
Copy link
Member Author

aranega commented Aug 31, 2023

Looking at the code, it looks like the apply_stereotype method is implemented

def apply_stereotype(self, stereotype):
"""Applies the specified stereotype to this element."""
from .profile_utils import get_definition_reference_matching
gdrm = get_definition_reference_matching
definition, base_reference = gdrm(stereotype, self)
if definition is None:
return
application = definition()
setattr(application, base_reference.name, self)
self.eResource.append(application)

so I guess, perhaps sub-profiles are not supported.

@ollierGuillaume
Copy link

ollierGuillaume commented Sep 1, 2023

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.

@aranega
Copy link
Member Author

aranega commented Sep 1, 2023

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants