FIWARE / context.Orion-LD

Context Broker and CEF building block for context data management which supports both the NGSI-LD and the NGSI-v2 APIs
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf
GNU Affero General Public License v3.0
51 stars 43 forks source link

Placement of @context in notification data #1245

Open Blobonat opened 2 years ago

Blobonat commented 2 years ago

Hi,

I noticed a small deviation between Scorpio and Orion-LD with the placement of @context inside a notification with endpoint.accept: "application/ld+json": Orion-LD places the @context on the top level and Scorpio in data for each entity.

Orion-LD behavior:

{
  "id": "urn:ngsi-ld:Notification:7fe5040e-4865-11ed-95af-0242ac130006",
  "type": "Notification",
  "subscriptionId": "urn:ngsi-ld:Subscription:withAttributes",
  "@context": "https://fiware.github.io/data-models/full-context.jsonld",
  "notifiedAt": "2022-10-10T06:33:49.293Z",
  "data": [
    {
      "id": "urn:ngsi-ld:Vehicle:A500",
      "type": "Vehicle",
      "speed": {
        "type": "Property",
        "value": 80
      }
    }
  ]
}

Scorpio behavior:

{
  "id": "urn:ngsi-ld:Notification:7fe5040e-4865-11ed-95af-0242ac130006",
  "type": "Notification",
  "subscriptionId": "urn:ngsi-ld:Subscription:withAttributes",
  "notifiedAt": "2022-10-10T06:33:49.293Z",
  "data": [
    {
      "id": "urn:ngsi-ld:Vehicle:A500",
      "type": "Vehicle",
      "speed": {
        "type": "Property",
        "value": 80
      },
     "@context": "https://fiware.github.io/data-models/full-context.jsonld"
    }
  ]
}

I haven't found any requirement regarding the placement of the @context in the NGSI-LD API spec, but some FIWARE components such as Cosmos expect the format as used by Scorpio. Is there any way, e.g. the usage of a receiverInfo inside a subscription, to influence the format used by Orion-LD?

kzangeli commented 2 years ago

I guess we could put the @contexzt in either of the two positions (unless we add to the spec something we've been discussing in ETSI ISG CIM where the NGSI-LD API is defined - prohibiting the @context to be anywhere except the toplevel of a payload body).

In either case, if you receive a notification with 100 entities in the "data" array, and the @context is part of the items of that array, then you'd receive 100 copies of the exact same @context. That's an important waste of bandwidth and I'll talk to NEC about this. I'm confident they'll see my thinking and change Scorpio accordingly.

I'll post any news about this in this issue.

kzangeli commented 2 years ago

Just got the preliminary OK from NEC (owners of Scorpio) to do it "my way" - just preliminary for now. Well discuss this in ETSI ISG CIM and amend the API spec accordingly. A new release of the API spec is due just after Christmas, so it just might be part of that new version.

Once we have a definitive agreement, I'll post again (well, I'll try to remember!)