Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: compaction of vocab values for simplified format #1538

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/lib/orionld/dbModel/dbModelToApiAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,21 @@ KjNode* dbModelToApiAttribute2(KjNode* dbAttrP, KjNode* datasetP, bool sysAttrs,
dbModelToApiLangPropertySimplified(dbAttrP, lang);
attrP = dbAttrP;
}
else if (strcmp(attrTypeNodeP->value.s, "VocabularyProperty") == 0)
{
attrP = kjLookup(dbAttrP, "value");

if (attrP->type == KjString)
attrP->value.s = orionldContextItemAliasLookup(orionldState.contextP, attrP->value.s, NULL, NULL);
else if (attrP->type == KjArray)
{
for (KjNode* wordP = attrP->value.firstChildP; wordP != NULL; wordP = wordP->next)
{
if (wordP->type == KjString)
wordP->value.s = orionldContextItemAliasLookup(orionldState.contextP, wordP->value.s, NULL, NULL);
}
}
}
else
{
// "Steal" the value node and rename it to have the attribute's name instead - that's all that's needed for SIMPLIFIED FORMAT
Expand Down
27 changes: 27 additions & 0 deletions test/functionalTest/cases/0000_ngsild/ngsild_vocab-property.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ accumulatorStart --pretty-print
# 05b. See urn:E2 in the DB - see [ "vocab", "id" ] expanded
# 06. Dump/Reset accumulator, see urn:E1+V1 and urn:E2+V2
#
# 07. GET urn:E1 in simplified format
#

echo '01. Create a subscription on entity type T'
echo '=========================================='
Expand Down Expand Up @@ -125,6 +127,13 @@ echo
echo


echo "07. GET urn:E1 in simplified format"
echo "==================================="
orionCurl --url /ngsi-ld/v1/entities/urn:E2?options=simplified
echo
echo


--REGEXPECT--
01. Create a subscription on entity type T
==========================================
Expand Down Expand Up @@ -314,6 +323,24 @@ Ngsild-Attribute-Format: Normalized
=======================================


07. GET urn:E1 in simplified format
===================================
HTTP/1.1 200 OK
Content-Length: 46
Content-Type: application/json
Date: REGEX(.*)
Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)

{
"V2": [
"vocab",
"id"
],
"id": "urn:E2",
"type": "T"
}


--TEARDOWN--
brokerStop CB
accumulatorStop
Expand Down
Loading