Until now, Thing'in supports RDF/Turtle format. To leverage the property graph that powers the platform, we make first step to NGSI-LD model compliancy.
Mainly, we implement the description of property graph as define in ETSI GS CIM 009 v1.4.2.
Then Avatar could have CIM Property through a Thing'in property <http://orange-labs.fr/fog/ont/iot.owl#hasProperty>
. In RDF, this property should target a blanknode composed of the fields <http://orange-labs.fr/fog/ont/iot.owl#label>
and <http://orange-labs.fr/fog/ont/iot.owl#type>
. The label specify the name of the property and the type the NGSI-LD type of the property. Depending on the type, the property could have dedicated fields.
Here examples of CIM property in Thing'in
In Turtle:
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://orange-labs.fr/fog/ont/iot.owl#> .
@prefix ngsi: <https://uri.etsi.org/ngsi-ld/> .
<http://www.example.com/toto>
:label "tag:red"^^xsd:string ;
:hasProperty [
:type "Integer"^^xsd:string ;
:label "tag:prop0"^^xsd:string ;
ngsi:hasValue "10"^^xsd:string
] ;
:hasProperty [
:type "TimeInterval"^^xsd:string ;
:label "tag:prop1"^^xsd:string ;
ngsi:startAt "2021-05-10T21:36:00Z"^^xsd:string ;
ngsi:endAt "2021-06-10T21:36:00Z"^^xsd:string
].
In JSON:
{
"_iri": "http://www.example.com/toto",
"_labels": [
"tag:red"
],
"tag:prop0": 10, << implicit json type
"tag:prop1": {
"http://orange-labs.fr/fog/ont/iot.owl#type": "TimeInterval",
"https://uri.etsi.org/ngsi-ld/endAt": "2021-06-10T21:36:00Z",
"https://uri.etsi.org/ngsi-ld/startAt": "2021-05-10T21:36:00Z"
}
}
As the avatar, we could now add CIM properties to relationship. In RDF, as this fonctionnality is not available, we dereference the relationship to a blanknode. In the underlying graph db, it is implemented as property on edges.
The thing'in Property that describe a relationship is <http://orange-labs.fr/fog/ont/iot.owl#hasRelationship>
. In RDF, this property should target a blanknode composed of the fields <http://orange-labs.fr/fog/ont/iot.owl#label>
and optionally any properties.
Here examples of CIM relationship in Thing'in
In Turtle:
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix : <http://orange-labs.fr/fog/ont/iot.owl#> .
@prefix ngsi: <https://uri.etsi.org/ngsi-ld/> .
<http://www.example.com/toto>
:hasRelationship [
:label "tag:edge1"^^xsd:string ;
ngsi:hasObject <http://www.example.com/toto0> ;
:hasProperty [
:label "tag:prop1"^^xsd:string ;
:type "Double"^^xsd:string ;
ngsi:hasValue "1978.011"^^xsd:string
] ;
:hasProperty [
:label "tag:prop2"^^xsd:string ;
:type "String"^^xsd:string ;
ngsi:hasValue "deuxieme"^^xsd:string
]
] .
In JSON:
{
"_iri": "http://www.example.com/toto",
"_outE": [
{
"_label": "tag:edge1",
"_targetIRI": "http://www.example.com/toto0",
"tag:prop2": "deuxieme",
"tag:prop1": 1978.011
}
]
}
In the current version of the platform, we implement property types of CIM (but not all). In the following, you can find the supported ones.
:hasProperty [
:type "String"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "blabla"^^xsd:string
] ;
{
"tag:prop": "blabla"
}
:hasProperty [
:type "Boolean"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "true"^^xsd:string
] ;
{
"tag:prop": true
}
:hasProperty [
:type "Long"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "100000000"^^xsd:string
] ;
{
"tag:prop": 100000000
}
:hasProperty [
:type "Integer"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "100000000"^^xsd:string
] ;
:hasProperty [
:type "Double"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "1000.000001"^^xsd:string
] ;
{
"tag:prop": 1000.000001
}
:hasProperty [
:type "Float"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "100000.0001"^^xsd:string
] ;
ISO Date
:hasProperty [
:type "Date"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "2021-05-21"^^xsd:string
] ;
{
"tag:prop": {
"type": "Date",
"value": "2021-05-21"
}
}
ISO DateTime
:hasProperty [
:type "DateTime"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "2011-12-03T10:15:30"^^xsd:string
] ;
{
"tag:prop": {
"type": "DateTime",
"value": "2011-12-03T10:15:30"
}
}
ISO Time
:hasProperty [
:type "Time"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "10:15:30"^^xsd:string
] ;
{
"tag:prop": {
"type": "Time",
"value": "10:15:30"
}
}
:hasProperty [
:type "TimeInterval"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:startAt "2021-05-10T21:36:00Z"^^xsd:string ;
ngsi:endAt "2021-06-10T21:36:00Z"^^xsd:string
] ;
{
"tag:prop": {
"type": "TimeInterval",
"endAt": "2021-06-10T21:36:00Z",
"startAt": "2021-05-10T21:36:00Z"
}
}
:hasProperty [
:type "LineString"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
<https://purl.org/geojson/vocab#coordinates> "[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]";
] ;
{
"tag:prop": {
"type": "LineString",
"coordinates": [[102,0],[103,1],[104,0],[105,1]]
}
}
:hasProperty [
:type "MultiLineString"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
<https://purl.org/geojson/vocab#coordinates> "[[[10, 10], [20, 20], [10, 40]], [[40, 40], [30, 30], [40, 20], [30, 10]]]";
] ;
{
"tag:prop": {
"type": "MultiLineString",
"coordinates": [[[10, 10], [20, 20], [10, 40]], [[40, 40], [30, 30], [40, 20], [30, 10]]]
}
}
:hasProperty [
:type "MultiPoint"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
<https://purl.org/geojson/vocab#coordinates> "[[10, 40], [40, 30], [20, 20], [30, 10]]";
] ;
{
"tag:prop": {
"type": "MultiPoint",
"coordinates": [[10, 40], [40, 30], [20, 20], [30, 10]]
}
}
:hasProperty [
:type "MultiPolygon"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
<https://purl.org/geojson/vocab#coordinates> "[[[[30, 20], [45, 40], [10, 40], [30, 20]]], [[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]]]";
] ;
{
"tag:prop": {
"type": "MultiPolygon",
"coordinates": [[[[30, 20], [45, 40], [10, 40], [30, 20]]], [[[15, 5], [40, 10], [10, 20], [5, 10], [15, 5]]]]
}
}
:hasProperty [
:type "Point"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
<https://purl.org/geojson/vocab#coordinates> "[30, 10]";
] ;
{
"tag:prop": {
"type": "Point",
"coordinates": [30, 10]
}
}
:hasProperty [
:type "Polygon"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
<https://purl.org/geojson/vocab#coordinates> "[[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]]";
] ;
{
"tag:prop": {
"type": "Polygon",
"coordinates": [[[30, 10], [40, 40], [20, 40], [10, 20], [30, 10]]]
}
}
:hasProperty [
:type "Coordinates"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]";
] ;
{
"tag:prop": {
"type": "Coordinates",
"value": [[102,0],[103,1],[104,0],[105,1]]
}
}
Geoproperty could embed Point, LineString, Polygon, MultiLineString, MultiPoint, MultiPolygon.
The following example embeds a LineString.
:hasProperty [
:type "GeoProperty"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue [
:type "LineString"^^xsd:string ;
<https://purl.org/geojson/vocab#coordinates> "[[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]]";
]
] ;
{
"tag:prop": {
"type": "GeoProperty",
"value": {
"type": "LineString",
"coordinates": [[102,0],[103,1],[104,0],[105,1]]
}
}
}
:hasProperty [
:type "AnyURI"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
ngsi:hasValue "urn:oasis:names:specification:docbook:dtd:xml:4.1.2"^^xsd:string;
] ;
{
"tag:prop": {
"type": "AnyURI",
"value": "urn:oasis:names:specification:docbook:dtd:xml:4.1.2"
}
}
See https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.02.02_60/gs_CIM009v010202p.pdf section 5.5.2
:hasProperty [
:type "Error"^^xsd:string ;
:label "tag:prop"^^xsd:string ;
...
] ;
{
"tag:prop": {
"type": "Error",
...
}
}
The relationship API at /avatars/relationships/ in Thing in the future's API allows to create relations between avatars without the need to include avatars in the payload, only the source and target IRIs. This can be useful if you desire to create relationships separately from avatars.
To create an object property with this API, below is an example payload :
{
"sourceIRI": "http://www.example.com/MyRelationshipExample/avatar1",
"targetIRI": "http://www.example.com/MyRelationshipExample/avatar2",
"label": "http://elite.polito.it/ontologies/dogont.owl#isIn"
}