Groot icon indicating copy to clipboard operation
Groot copied to clipboard

Relation to inherited entities

Open o15a3d4l11s2 opened this issue 9 years ago • 3 comments

Is there an annotation to cover the following case: screen shot 2015-12-01 at 23 09 41

The JSON structure is the following:

{
  "users": [
    {
      "id": 1,
      "sentMessages": [
        {
          "id": 1,
          "type": "textMessage",
          "text": "asdfghjkl"
        },
        {
          "id": 2,
          "type": "pictureMessage",
          "url": "http://example.com/image.png"
        }
      ]
    }
  ]
}

The logic for the messages is taken from your example for entityMapperName, but I am not sure how to map the relationship between the objects.

How should I annotate the relations textMessages and pictureMessages together with the entityMapperName logic for the abstract base entity Message?

o15a3d4l11s2 avatar Dec 01 '15 21:12 o15a3d4l11s2

Groot does not currently support mapping one relationship into multiple relationships. You should map your sentMessages array to a single relationship and then filter by type when fetching your managed objects.

gonzalezreal avatar Dec 04 '15 08:12 gonzalezreal

Is it reasonable to use the JSONDictionaryTransformerName to transform the JSON data to two separate relations (sentMessages would become textMessages and pictureMessages), as in the model?

o15a3d4l11s2 avatar Dec 05 '15 12:12 o15a3d4l11s2

Nope, sorry that wouldn't work.

gonzalezreal avatar Dec 07 '15 08:12 gonzalezreal