Skip to content

Commit

Permalink
Fixed issue #1385
Browse files Browse the repository at this point in the history
  • Loading branch information
kzangeli committed Jun 16, 2023
1 parent 70ec52e commit d5abaac
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 10 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ For source code contributions, please see the [Contribution guidelines](doc/manu
Its payloads are encoded as [linked data](https://en.wikipedia.org/wiki/Linked_data) using JSON.

The NGSI-LD Specification is regularly updated and published by ETSI.
The latest specification is [version 1.6.1](https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf)
and it was published in December 2022.
Version 1.7.1 is about to be released (May 2023).
The latest specification is [version 1.7.1](https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.07.01_60/gs_CIM009v010701p.pdf)
and it was published in June 2023.

This presentation from FIWARE Summit Malaga 2018 might be of interest:
This presentation from the FIWARE Summit in Malaga 2018 might be of interest:
https://www.slideshare.net/FI-WARE/fiware-global-summit-ngsild-ngsi-with-linked-data

Examples of **NGSI-LD** can be found in [ETSI](https://forge.etsi.org/gitlab/NGSI-LD/NGSI-LD/tree/master/examples).
Expand Down
4 changes: 2 additions & 2 deletions doc/manuals-ld/quick-start-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Orion-LD is an enhanced [Orion](https://github.com/telefonicaid/fiware-orion) an
The NGSI-LD API is specified [here](https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf) and while it's a pretty extensive
document, anybody that is really going to work with NGSI-LD should definitely read this document. And use it as a reference, of course.

The first thing to do is to thoroughly read [this quick guide to the @context](doc/manuals-ld/the-context.md).
The first thing to do is to thoroughly read [this quick guide to the @context](the-context.md).
There are also a number of tutorials about NGSI-LD:
* [FIWARE 601: Introduction to Linked Data](https://fiware-tutorials.readthedocs.io/en/latest/linked-data)
* [FIWARE 602: Linked Data Relationships and Data Models](https://fiware-tutorials.readthedocs.io/en/latest/relationships-linked-data)
Expand Down Expand Up @@ -47,7 +47,7 @@ Let's create an entity with two attributes:
* status (which is part of the Core Context)
* state (which is **not** part of the Core Context)

We will be using `curl` which you have already installed if you have followed the [installation guide](doc/manuals-ld/installation-guide.md).
We will be using `curl` which you have already installed if you have followed the [installation guide](installation-guide.md).
If not, make sure you have `curl` installed before proceeding.
However, there are code snippets also for Python and JavaScript (node.js), so if you prefer those ...

Expand Down
8 changes: 4 additions & 4 deletions src/lib/orionld/legacyDriver/legacyPatchAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ bool orionldPatchAttributeWithDatasetId(KjNode* inAttribute, char* entityId, cha
//
// kjAttributeMerge -
//
// Merge:
// inAttribute = inAttribute + dbAttribute
//
bool kjAttributeMerge(KjNode* inAttribute, KjNode* dbAttribute, KjNode* dbAttributeType, KjNode* inAttributeType, KjNode* dbCreatedAt)
{
KjNode* inValueP = NULL;
Expand Down Expand Up @@ -553,10 +556,7 @@ bool kjAttributeToNgsiContextAttribute(ContextAttribute* caP, KjNode* inAttribut
else if (strcmp(mdP->name, "value") == 0)
kjTreeToAttributeValue(caP, mdP, &level);
else if (strcmp(mdP->name, "object") == 0)
{
caP->valueType = orion::ValueTypeString;
caP->stringValue = mdP->value.s;
}
kjTreeToAttributeValue(caP, mdP, &level); // As ARRAY is allowed as well - to be deprecated
else if (strcmp(mdP->name, "languageMap") == 0)
{
caP->valueType = orion::ValueTypeObject;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Copyright 2023 FIWARE Foundation e.V.
#
# This file is part of Orion-LD Context Broker.
#
# Orion-LD Context Broker is free software: you can redistribute it and/or
# modify it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Orion-LD Context Broker is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Orion-LD Context Broker. If not, see http://www.gnu.org/licenses/.
#
# For those usages not covered by this license please contact with
# orionld at fiware dot org

# VALGRIND_READY - to mark the test ready for valgrindTestSuite.sh

--NAME--
Patch an attribute that is a relationship whose object is an array

--SHELL-INIT--
dbInit CB
orionldStart CB

--SHELL--

#
# 01. Create E1 with a relationship R1 whose object is an array
# 02. PATCH R1, setting its object to another array
# 03. GET E1 - make sure step 02 worked
#

echo "01. Create E1 with a relationship R1 whose object is an array"
echo "=============================================================="
payload='{
"id": "urn:ngsi-ld:entity:E1",
"type": "Device",
"owners": {
"type": "Relationship",
"object": [ "urn:ngsi-ld:owner:1", "urn:ngsi-ld:owner:2" ],
"observedAt": "2021-03-07T08:32:00.123Z"
}
}'
orionCurl --url /ngsi-ld/v1/entities --payload "$payload"
echo
echo


echo "02. PATCH R1, setting its object to another array"
echo "================================================="
payload='{
"type": "Relationship",
"object": [ "urn:ngsi-ld:owner:3", "urn:ngsi-ld:owner:4" ],
"observedAt": "2021-03-10T10:32:00.456Z"
}'
orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entity:E1/attrs/owners --payload "$payload" -X PATCH
echo
echo


echo "03. GET E1 - make sure step 02 worked"
echo "======================================"
orionCurl --url /ngsi-ld/v1/entities/urn:ngsi-ld:entity:E1
echo
echo


--REGEXPECT--
01. Create E1 with a relationship R1 whose object is an array
==============================================================
HTTP/1.1 201 Created
Content-Length: 0
Date: REGEX(.*)
Location: /ngsi-ld/v1/entities/urn:ngsi-ld:entity:E1



02. PATCH R1, setting its object to another array
=================================================
HTTP/1.1 204 No Content
Date: REGEX(.*)



03. GET E1 - make sure step 02 worked
======================================
HTTP/1.1 200 OK
Content-Length: 174
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld>; rel="http://www.w3.org/ns/json-ld#context"; type="application/ld+json"

{
"id": "urn:ngsi-ld:entity:E1",
"owners": {
"object": [
"urn:ngsi-ld:owner:3",
"urn:ngsi-ld:owner:4"
],
"observedAt": "2021-03-10T10:32:00.456Z",
"type": "Relationship"
},
"type": "Device"
}


--TEARDOWN--
brokerStop CB
dbDrop CB

0 comments on commit d5abaac

Please sign in to comment.