Skip to content

Commit

Permalink
fix metadata obj into jexl context
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed Aug 6, 2024
1 parent 45d9538 commit 3036ade
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/services/ngsi/entities-NGSI-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation,
function reduceMetadataAttrToPlainObject(attrs, initObj = {}) {
if (attrs !== undefined && Array.isArray(attrs)) {
return attrs.reduce((result, item) => {
result['metadata'] = {};
if (result['metadata'] === undefined) {
result['metadata'] = {};
}
if (item.metadata !== undefined) {
result['metadata'][item.name] = {};
for (var meta in item.metadata) {
Expand Down
22 changes: 22 additions & 0 deletions test/functional/testCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,17 @@ const testCases = [
commands: [],
lazy: [],
static_attributes: [
{
name: 'st_attr1',
type: 'Number',
value: 1.5,
metadata: {
coef1: {
value: 0.8,
type: 'Float'
}
}
},
{
name: 'st_attr',
type: 'Number',
Expand All @@ -1853,6 +1864,17 @@ const testCases = [
type: 'Float'
}
}
},
{
name: 'st_attr2',
type: 'Number',
value: 1.5,
metadata: {
coef2: {
value: 0.8,
type: 'Float'
}
}
}
],
attributes: [
Expand Down

0 comments on commit 3036ade

Please sign in to comment.