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

decode of many references in external resources failed #111

Open
AnNeub opened this issue Nov 18, 2021 · 5 comments
Open

decode of many references in external resources failed #111

AnNeub opened this issue Nov 18, 2021 · 5 comments

Comments

@AnNeub
Copy link

AnNeub commented Nov 18, 2021

I had the following issue with multiple references like:
"org.polarsys.capella.core.data.information:ExchangeItem fragments/software.capellafragment#92caadb3-fb4f-347c-ae2d-0f30ac43e9cc #1d237afa-50c3-4536-b27e-900958301d1e"

The problem occur in the function _decode_ereferences where this string is only splitted at the whitespaces and therefore the part org.polarsys.capella.core.data.information:ExchangeItem is tried to resolve which is no valid reference.

def _decode_ereferences(self):
        opposite = []
        for eobject, erefs in self._later:
            for ref, value in erefs:
                print(ref, value, eobject)
                name = ref.name
                if name == 'eOpposite':
                    opposite.append((eobject, ref, value))
                    continue
                if ref.many:
                    values = [self.normalize(x) for x in value.split()]  # <---
                else:
                    values = [value]

I try to solve this with a regex but I am not sure if this capture all possibilities. I don't find a detail definition how the serialization could look like.

@aranega
Copy link
Member

aranega commented Nov 18, 2021

Hi @AnNeub,

Thanks for the issue, I'll look for this asap to see from where the issue could come. I guess there is a special way of serializing hrefs for many non-containment references where the references type is abstract (or has subclasses) and the referenced object is in a external model.

I'll try to reproduce this situation on a minimal metamodel/model and see how emf serialize everything.

@aranega
Copy link
Member

aranega commented Nov 18, 2021

Just a quick update, I tried to create the same behavior with the default Java-EMF tools, but I cannot have a many reference with external references that encode the name of the package with the name of the pointed EClass name in between " ". Same thing regarding the use of elements separated by spaces in " ", when I load an external resource, I always have a href that is saved. Did capella implement a special way of serializing some data? Or use specific options? If the files you are handling have been generated by PyEcore, then perhaps there is something wrong in the serialization in the first place?

@AnNeub
Copy link
Author

AnNeub commented Nov 18, 2021

I dont know if capella use any customized serialization option. Is an open source tool but i haven't dived into the source code so far. The problem came up that capella put the type in front of it. Do you know a definiton how the serializiation of EReferences must look like? I tried something like findall(r'[\/\w.\-:]*#[\/\w.\-]*', value)] insteat of split, which works for me so far.

@aranega
Copy link
Member

aranega commented Nov 18, 2021

The thing that puzzles me is more the org.polarsys.capella.core.data.information:ExchangeItem, I suppose it's a valid way of serializing EReference, but that's the first time I see it. Usually, you can find more this (especially for cross-references)

<links href="m3.xmi#M31"/>
<links href="m3.xmi#M32"/>

or

<instance links="m3.xmi#M31 m3.xmi#M32"/>

The serialization with the type of the object before is not something I knew. I will try to add your fix asap with some tests. If you have time to do it before I do, I would be pleased to integrate the fix :)

@AnNeub
Copy link
Author

AnNeub commented Nov 18, 2021

I dont know if the regex above really covers all cases. I tried this pattern r'[^\s]*#[^\s]+' which also works and should be the equivalent to split at whitespaces. The only problem with the regex implementation is that a # is mandatory which is not compatible with your serialization. For internal references you don't put the # in front.

I check some other model files which based on ecore and they look like as you described. But on the other hand .ecore files itself always uses the # to mark a reference.

I think as long this solution does not covers both, cases it makes no sense to fix it.

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

No branches or pull requests

2 participants