telefonicaid / fiware-orion

Context Broker and CEF building block for context data management, providing NGSI interfaces.
https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md
GNU Affero General Public License v3.0
212 stars 265 forks source link

Support linked entity attribute type #1958

Closed jmcanterafonseca closed 6 years ago

jmcanterafonseca commented 8 years ago

In API v2 we need to support the concept of linked entities. Example

WeatherStation and WeatherObserved could be two linked entities.

A weather station provides its latest observation through an instance of WeatherObserved. A weather observation has been gathered by a particular WeatherStation.

WeatherStation --> lastMeasurement --> WeatherObserved --> capturedFrom --|
^                                                                                                                             |
|---------------------------------------------------------------------------------------------------------

This issue has been open to gather feedback on how to materialize it:

Proposal.

Create a new built-in attribute type named 'ref:'.

Example.

{ 
   "id": "AEMET-345",
   "type": "WeatherStation",
   "location": {
      "type": "geo:point",
      "value": "43.5, -3.8"
   },
  "lastMeasurement": {
     "type": "ref:WeatherObserved",
     "value": "WeatherObserved-456778"
   }
} 

{ 
   "id": "WeatherObserved-456778",
   "type": "WeatherObserved",
   "capturedFrom": {
     "type": "ref:WeatherStation",
     "value": "AEMET-345"
   }
} 

Please take into account that in principle no consistency checking will be done by the implementation, although some checking tools could appear in the future.

When querying

http://broker.org:1026/v2/entities?id=AEMET-345

the HTTP response will include a link header with

Link rel="lastMeasurement" type="ref:WeatherObserved" href="http://broker.org:1026/v2/entities?id=WeatherObserved-456778&type=WeatherObserved"

(Please note that this feature is related to JSON-LD support but we can support it without JSON-LD as well)

fgalan commented 6 years ago

This issue has been considered not essential to be included in final version of NGSIv2, so it will be closed.

CC: @jmcanterafonseca