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

XMI customization #108

Open
CFAndy opened this issue Sep 27, 2021 · 1 comment
Open

XMI customization #108

CFAndy opened this issue Sep 27, 2021 · 1 comment

Comments

@CFAndy
Copy link
Contributor

CFAndy commented Sep 27, 2021

Dear Vincent @aranega,
Hope you and your family are all well!
I stick with 0.9 and today, I bump it to 1.2.
I have a customized implementation of Resource, where I'll do the following things:

def _go_across(self, obj, serialize_default=False):
    self._cur_eobject = obj
    return super()._go_across(obj, serialize_default)

def _build_path_from(self, obj):
    if isinstance(obj, type):
        obj = obj.eClass
    if obj.eResource and obj.eResource != self and obj.eResource.uri:
        return self._build_path_from_my_cross(obj) # this fun need obj, which I store with self._cur_eobject
    return super()._build_path_from(obj)
# so, can we pass the 


def _decode_ereferences(self):
	  for eobject, erefs in self._later:
	      for ref in erefs[:]:
	          if ref[1] in self.ref_to_be_ignored:
	              erefs.remove(ref)
	  super()._decode_ereferences()


def _decode_attribute(self, owner, key, value, node=None):
    namespace, att_name = self.extract_namespace(key)
    if att_name in self.attr_to_be_ignored:
        return
    if node:
        return super()._decode_attribute(owner, key, value, node)
    else:
        return super()._decode_attribute(owner, key, value)

Would it be possible to provide some support for such customization, like:

  1. add attr_to_be_ignored to drop deprecated attribute when decode attribute
  2. add ref_to_be_ignored to drop ill-formed ref
  3. pass the obj of _go_across to _build_path_from
    This is just a soft suggestion.
    Thanks!
@aranega
Copy link
Member

aranega commented Sep 27, 2021

Hi @CFAndy!

Glad to see that the update was fine and that there is no regression for your project :) (I hope at least...).

Regarding the points you are suggesting, they are quite interesting as they really touch to model/metamodel evolution and could be helpful for others. Regarging them, I know EMF as a special option that you can pass during deserialization to explicitally ask to record the unknown features. This would take all unknow feature and store them in a special map in the resource so they can be accessed at another moment (option RECORD_UNKNOWN_FEATURE). Do you think this could cover your two first points?

For your last point, about passing the object from one method to the other, I think it could be done without so much trouble. I need to check.

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