Can we cross-reference entities in different service paths using Relationships?

Viewed 85

We are using FIWARE Orion NGSI V2 version. We are trying to create a data model where entities exist in different service paths and these entities are connected to each other through relationships.

We checked FIWARE documentation and did not find any answers on how to achieve this.

Please find attached the pictorial representation of what we are trying to achieve. Also the version of FIWARE Orion we are using. "Connected To" relationship to be created between entities in different service paths. Can you please guide us on how to achieve this.

{
"orion" : {
  "version" : "2.4.0-next",
  "uptime" : "0 d, 0 h, 1 m, 7 s",
  "git_hash" : "4f26834ca928e468b091729d93dabd22108a2690",
  "compile_time" : "Tue Mar 31 16:21:23 UTC 2020",
  "compiled_by" : "root",
  "compiled_in" : "3369cff2fa4c",
  "release_date" : "Tue Mar 31 16:21:23 UTC 2020",
  "doc" : "https://fiware-orion.rtfd.io/"
}

}

enter image description here

3 Answers

You only need a trio of attributes like this one:

  • XXXSource, for de ID of the entity
  • XXXSourceType, for the type of the entity
  • XXXSourcePath, for the service path of the entity

Where XXX is a token specifying the name of the relationship if you need to distinguish many of them. For instance:

  • managerSource
  • managerSourceType
  • managerSourcePath

Other naming variants are possible, e.g.

  • refXXX
  • refXXXType
  • refXXXPath

The fiware-servicepath header is meant to logically divide a system in a hierarchical manner, By default the / hierarchy is assumed.

If you create the following:

curl -L -X POST 'http://localhost:1026/v2/entities/' \
-H 'fiware-servicepath: /pigs' \
-d {
    "id": "urn:ngsi-ld:Animal:001",
    "type": "Animal",
}'
curl -L -X POST 'http://localhost:1026/v2/entities/' \
-H 'fiware-servicepath: /cows' \
-d {
    "id": "urn:ngsi-ld:Animal:002",
    "type": "Animal",
}'

You can retrieve cows only by requesting the following:

curl -L -X GET 'http://localhost:1026/v2/entities' \
-H 'fiware-servicepath: /cows' 

You can retrieve cows and pigs by requesting:

curl -L -X GET 'http://localhost:1026/v2/entities' \
-H 'fiware-servicepath: /#' 

Therefore if your Relationship is cross hierarchy, you just need to supply a fiware-servicepath with a wildcard service-path /# when retrieving entities.

Note that if the data is found under a longer service-path (e.g. /animals/cows and animals/pigs) then you could use /animals/# or /# as necessary.

I would not recommend at all using the FIWARE Service Path. You can very easily end up with a system with duplicate ids and a total mess.

In a linked data and distributed scenario you can have pointers to entities that live within multiple brokers or systems and just use URIs to point to them through Relationships.

Related