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

EntityModule only keeps @iot.id of nested entities after JSON serialization #133

Open
PhilippMatthes opened this issue Mar 15, 2022 · 2 comments

Comments

@PhilippMatthes
Copy link

Currently, it is not clear enough how the EntityModule intends to serialize entities.

Due to the above lines, prepopulated fields of subentities are thrown away. I would like to know the reasoning for this design decision to further understand if this is intended behaviour or not. In our use case, we would like to serialize/deserialize a Thing including its Datastreams and Locations. However, the fields of Datastreams and Locations that were populated by an Expand query are thrown away during JSON serialization. Could you maybe elaborate a bit on the above, and point me into the right direction on how I can serialize the subentities without losing their populated fields and not having to perform separate fetch queries?

@PhilippMatthes PhilippMatthes changed the title EntityModule only keeps @iod.id of nested entities after JSON serialization EntityModule only keeps @iot.id of nested entities after JSON serialization Mar 15, 2022
@hylkevds
Copy link
Member

Expanded entities in POSTs should either have an @iot.id, or other fields, but never both:

  • When updating an entity (PATCH / PUT) sub-entities are only allowed to be references for updating relations. Only the @iot.id is allowed to be in the related entity in this case.
  • When creating entities (POST), related entities must either:
    • not exist yet and thus created using deep-inset, in which case they have no @iot.id, but all other properties
    • already exist and thus linked, in which case only the @iot.id is allowed to be in the json.

hence, sub-entities are never serialised with both their @iot.id and their properties, since such a representation is never valid when being sent to a SensorThings service.

@PhilippMatthes
Copy link
Author

Thank you for the elaborate answer. Maybe it should be documented that the EntityModule relates to internal JSON Serialization of the framework when sending requests to the SensorThings service. In my case I just expected that the EntityModule can be reused for the JSON serialization of Things and their nested properties. Hence, an added documentation on the behaviour of the EntityModule, especially EntitySerializer would increase the reusability of the framework.

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

No branches or pull requests

2 participants