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
50 stars 43 forks source link

Problem with timestamps and application/ld+json in notifications #93

Closed mariohese closed 5 years ago

mariohese commented 5 years ago

Hi, I think that it exists a problem with the timestamps in format ISO 8601 when receiving the notification data related to a subscription. When I post an entity like the one in https://github.com/FIWARE/NGSI-LD_Experimental/blob/master/doc/example-code.md

curl http://localhost:1026/ngsi-ld/v1/entities/ -H 'Content-Type:application/ld+json' -iX  POST -d '{
   "id": "urn:ngsi-ld:Vehicle:A4568",
   "type": "Vehicle",   
   "brandName": {
      "type": "Property",   
      "value": "Mercedes"
    },
   "isParked": {
      "type": "Relationship",
      "object": "urn:ngsi-ld:OffStreetParking:Downtown1",
      "observedAt":"2018-12-04T12:00:00Z",
      "providedBy": {
            "type": "Relationship",
            "object": "urn:ngsi-ld:Person:Bob"
       }
    },
   "@context": ["http://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"]
}'

I get the field observedAt correctly with a GET request: curl "http://localhost:1026/ngsi-ld/v1/entities?type=Vehicle" -H "Accept: application/ld+json"

But when I create a subscription for getting that entity

curl http://localhost:1026/ngsi-ld/v1/subscriptions/ -H 'Content-Type:application/ld+json' -iX POST -d '{
 "id": "urn:ngsi-ld:Subscription:01",
 "type": "Subscription",
 "entities": [{"type": "Vehicle"}],
 "@context": "http://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld", 
 "description": "Notify me of all product vehicles changes", 
 "notification": {
     "format": "normalized",
     "endpoint": {
         "uri": "http://mydomain/",
         "accept": "application/ld+json"
       }
   }
 }'

I get the following response:

{
 "id":"urn:ngsi-ld:Notification:5ce59a3631178d6ca8eefbe6",
 "type":"Notification",
 "subscriptionId":"urn:ngsi-ld:Subscription:01",
 "notifiedAt":"2019-05-22T18:51:34Z",
 "data":[
     {
       "id":"urn:ngsi-ld:Vehicle:A4568",
       "type":"Vehicle",
       "brandName":{
            "type":"Property",
            "value":"Mercedes"
        },
       "isParked":{
            "type":"Relationship",
            "value":"urn:ngsi-ld:OffStreetParking:Downtown1",
            "observedAt":"",
            "providedBy":"urn:ngsi-ld:Person:Bob"
        }
     }
  ]
}

With content-type: application/json

As it can be seen, in my subscription I specify that I want my notifications to have content in ld+json format instead of json and the field observedAt is empty in the notification. I am using docker-compose.

Furthermore, I was wondering if I could get in the notifications the creDate and modDate fields of the objects saved in Orion with a subscription.

kzangeli commented 5 years ago

I am more than sure there are plenty of bugs in orionld ... Keep in mind that this is a work in progress, first alpha release planned for October this year. I'm a bit busy at the moment but I promise to look into these problems you are facing as soon as I havre a bit of time over.

One thing that would help would be if you could edit the issue text and "pretty-print" the json payloads. Really difficult to read it when on a single line. Like this:

curl http://localhost:1026/ngsi-ld/v1/entities/ -H 'Content-Type:application/ld+json' -iX POST 
-d '{
  "id": "urn:ngsi-ld:Vehicle:A4568",
  "type": "Vehicle",
  "brandName": {
    "type": "Property", ...
mariohese commented 5 years ago

I have just edited the text for making it eassier to see. Thank you very much.

kzangeli commented 5 years ago

Problem found and fixed (hopefully), waiting for travis tests to accept PR #98

kzangeli commented 5 years ago

PR #98 finally landed in the develop branch. Please try again, with the new develop and let me know.

kzangeli commented 5 years ago

@mariohese: sorry for taking so long and thank you for finding these bugs for me! :)

mariohese commented 5 years ago

Thank you very much for fixing it, it works as expected:) Now, with you permission, I proceed to close the issue.