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

Removed some 'garbage' from DDS samples before storing attr in NGSI-LD current state #1703

Merged
merged 1 commit into from
Oct 31, 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
27 changes: 21 additions & 6 deletions src/lib/orionld/dds/ddsNotification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,32 @@ void ddsNotification(const char* typeName, const char* topicName, const char* js
char* expandedType = orionldContextItemExpand(orionldState.contextP, entityType, true, NULL);
typeNodeP = kjString(orionldState.kjsonP, "type", expandedType);

KjNode* attrValueNodeP = kjLookup(kTree, topicName);
if (attrValueNodeP == NULL)
KjNode* topicNameNodeP = kjLookup(kTree, topicName);
if (topicNameNodeP == NULL)
KT_RVE("No attribute field ('%s') in DDS payload", topicName);
KjNode* dataNodeP = kjLookup(topicNameNodeP, "data");
if (dataNodeP == NULL)
KT_RVE("No 'data' field in DDS attribute payload", topicName);

KjNode* tNodeP = kjLookup(topicNameNodeP, "type");
if (tNodeP != NULL)
kjChildRemove(topicNameNodeP, tNodeP);

KjNode* valueNodeP = dataNodeP->value.firstChildP;
char* xId = valueNodeP->name;
KjNode* subAttrP = kjString(orionldState.kjsonP, "xId", xId);
KjNode* attrNodeP = kjObject(orionldState.kjsonP, NULL);

valueNodeP->name = (char*) "value";

kjChildAdd(attrNodeP, valueNodeP);

// Add the xId node as "hidden" sub-property - not to be included in GETs, only for DDS publish reconstruction
kjChildAdd(attrNodeP, subAttrP);

orionldState.payloadIdNode = idNodeP;
orionldState.payloadTypeNode = typeNodeP;

KjNode* attrNodeP = kjObject(orionldState.kjsonP, NULL);
kjChildAdd(attrNodeP, attrValueNodeP);
attrValueNodeP->name = (char*) "value";

orionldState.requestTree = attrNodeP;
orionldState.uriParams.format = (char*) "simplified";
orionldState.uriParams.type = typeNodeP->value.s;
Expand Down
100 changes: 48 additions & 52 deletions test/functionalTest/cases/0000_dds/dds_notifications.test
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,18 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
},
"type": "Property",
"value": {
"data": {
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0": {
"b": false,
"f": 0,
"i": 0,
"ia": [
0,
0
],
"s": "abc"
}
},
"type": "NgsildSample"
"b": false,
"f": 0,
"i": 0,
"ia": [
0,
0
],
"s": "abc"
},
"xId": {
"type": "Property",
"value": "REGEX(.*)"
}
},
"type": "Camera"
Expand All @@ -194,19 +193,18 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
},
"type": "Property",
"value": {
"data": {
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0": {
"b": false,
"f": 0,
"i": 2,
"ia": [
0,
0
],
"s": ""
}
},
"type": "NgsildSample"
"b": false,
"f": 0,
"i": 2,
"ia": [
0,
0
],
"s": ""
},
"xId": {
"type": "Property",
"value": "REGEX(.*)"
}
},
"ddsType": {
Expand All @@ -228,19 +226,18 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
},
"type": "Property",
"value": {
"data": {
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0": {
"b": false,
"f": 3.14,
"i": 0,
"ia": [
0,
0
],
"s": ""
}
},
"type": "NgsildSample"
"b": false,
"f": 3.14,
"i": 0,
"ia": [
0,
0
],
"s": ""
},
"xId": {
"type": "Property",
"value": "REGEX(.*)"
}
},
"P4": {
Expand All @@ -254,19 +251,18 @@ Link: <https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-contextREGEX(.*)
},
"type": "Property",
"value": {
"data": {
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0": {
"b": false,
"f": 4.14,
"i": 4,
"ia": [
0,
0
],
"s": "p4"
}
},
"type": "NgsildSample"
"b": false,
"f": 4.14,
"i": 4,
"ia": [
0,
0
],
"s": "p4"
},
"xId": {
"type": "Property",
"value": "REGEX(.*)"
}
},
"ddsType": {
Expand Down
Loading