Skip to content

Commit

Permalink
relace metadata format for jexl context from metadata.Attr.value to m…
Browse files Browse the repository at this point in the history
…etadata_Attr_value
  • Loading branch information
AlvaroVega committed Aug 6, 2024
1 parent c8778c7 commit a1063a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ Additionally, for attribute expressions (`expression`, `entity_name`), `entityNa
(`expression`) measures are available in the **context** used to evaluate them.

Attribute metadata and Static Attribute metadata are available in the **context** under the following convention:
`metadata.AttributeName.MetadataName` or `metadata.StaticAttributeName.MetadataName` in a similar way of defined for
`metadata_AttributeName_MetadataName` or `metadata_StaticAttributeName_MetadataName` in a similar way of defined for
[Context Broker](https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md#metadata-support)

### Examples of JEXL expressions
Expand Down
2 changes: 1 addition & 1 deletion lib/services/ngsi/entities-NGSI-v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation,
return attrs.reduce((result, item) => {
if (item.metadata !== undefined) {
for (var meta in item.metadata) {
result['metadata.' + item.name + '.' + meta] = item.metadata[meta].value;
result['metadata_' + item.name + '_' + meta] = item.metadata[meta].value;
}
}
return result;
Expand Down
6 changes: 3 additions & 3 deletions test/functional/testCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,6 @@ const testCases = [
{
describeName:
'0175 - Simple group with active attribute + JEXL expression referencing metadata context attributes',
skip: 'lib', // Explanation in #1523
provision: {
url: 'http://localhost:' + config.iota.server.port + '/iot/services',
method: 'POST',
Expand Down Expand Up @@ -1861,9 +1860,10 @@ const testCases = [
object_id: 'a',
name: 'attr_a',
type: 'Number',
expression: 'a*st_attr*metadata.st_attr.coef'
expression: 'a*st_attr*metadata_st_attr_coef'
}
]
],
explicitAttrs: "['attr_a']"
}
]
},
Expand Down

0 comments on commit a1063a1

Please sign in to comment.