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

When deserializing a model which has 2 references of the same type, only 1 type is produced on the resulting object #66

Open
RubyBit opened this issue May 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@RubyBit
Copy link

RubyBit commented May 6, 2024

Take this model for example:

type food

operation cook
input food, food

This serializes as expected:

more json here...,

"operations":[{
  "name" : "cook",
  "inputs" : [ {
    "eClass" : "....",
    "$ref" : "//@cookingTypes.0"
  }, {
    "eClass" : "....",
    "$ref" : "//@cookingTypes.0"
  } ]
}]

When its deserialized though, this is the output:

type food

operation cook
input food

It takes only 1 input now.

I did some debugging and found out that when the 2nd reference is added to the list of inputs of the model (Elist), nothing happens. I am assuming it considers the 2 inputs to be the same cooking type impl object and as such it doesn't work. Is this expected behaviour or a bug?

@RubyBit RubyBit added the bug Something isn't working label May 6, 2024
@vhemery
Copy link
Contributor

vhemery commented May 6, 2024

That's a very old well known bug in EMF. https://bugs.eclipse.org/bugs/show_bug.cgi?id=89325
One solution is to refactor your grammar/metamodel, so you insert placehoders elements (with e.g. "Input" Eclass type) to hold the reference to food.

Such as (approximatively)

  "name" : "cook",
  "inputs" : [ {
    reference={
      "eClass" : "....",
      "$ref" : "//@cookingTypes.0"
    }
  }, {
    reference={
      "eClass" : "....",
      "$ref" : "//@cookingTypes.0"
    }
  } ]
}]```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants