Skip to content

Commit

Permalink
Array reduction for vocab properties for normalized mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kzangeli committed Jan 9, 2025
1 parent 8215d0e commit d30e4e8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#1708: Reloaded hosted contexts were not persisted in mongo, only the context cache
#XXXX: Using "VocabProperty" and not "VocabularyProperty" (old name still accepted as input)
#XXXX: Array reduction for LanguageProperty languageMap values
#XXXX: Array reduction for VocabProperty vocab values, for normalized mode

## New Features:
#1707: Support for local=true in the type discovery endpoints (GET /ngsi-ld/v1/types[/{typeName}]
Expand Down
9 changes: 7 additions & 2 deletions src/lib/orionld/payloadCheck/pCheckAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,8 +1127,13 @@ static bool pCheckAttributeObject
else
LM_W(("No languageMap field found!"));
}

if (attributeType == NoAttributeType)
else if (attributeType == VocabularyProperty)
{
KjNode* vocabP = kjLookup(attrP, "vocab");
if (vocabP != NULL)
arrayReduce(vocabP);
}
else if (attributeType == NoAttributeType)
{
if (isGeoJsonValue(attrP))
{
Expand Down
22 changes: 22 additions & 0 deletions test/functionalTest/cases/0000_ngsild/ngsild_vocab-property.test
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ accumulatorStart --pretty-print
# 11. Query entities with q=V1==abc&expandValues=V1,V2 => see urn:E1
# 12. Query entities with q=V2==id&expandValues=V1,V2 => see urn:E2
#
# 13. Create an entity urn:E4, type T, with a VocabProperty V4 whose vocab is an array with a single element - for array reduction
# 14. GET urn:E4 in normalized format, see V4 with an array-recuced 'vocab'
#

echo '01. Create a subscription on entity type T'
echo '=========================================='
Expand Down Expand Up @@ -194,6 +197,25 @@ echo
echo


echo "13. Create an entity urn:E4, type T, with a VocabProperty V4 whose vocab is an array with a single element - for array reduction"
echo "================================================================================================================================"
payload='{
"id": "urn:E4",
"type": "T",
"V4": { "type": "VocabProperty", "vocab": [ "test" ] }
}'
orionCurl --url /ngsi-ld/v1/entities --payload "$payload"
echo
echo


echo "14. GET urn:E4 in normalized format, see V4 with an array-recuced 'vocab'"
echo "========================================================================="
orionCurl --url /ngsi-ld/v1/entities/urn:E4
echo
echo


--REGEXPECT--
01. Create a subscription on entity type T
==========================================
Expand Down

0 comments on commit d30e4e8

Please sign in to comment.