Skip to content

Commit

Permalink
fix and clone typeInformation
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroVega committed May 8, 2024
1 parent cfbe12f commit 3705bd6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/services/ngsi/entities-NGSI-v2.js
Expand Up @@ -260,7 +260,7 @@ function sendQueryValueNgsi2(entityName, attributes, typeInformation, token, cal
* @param {Object} typeInformation Configuration information for the device.
* @param {String} token User token to identify against the PEP Proxies (optional).
*/
function sendUpdateValueNgsi2(entityName, originMeasures, typeInformation, token, callback) {
function sendUpdateValueNgsi2(entityName, originMeasures, originTypeInformation, token, callback) {
//aux function used to builf JEXL context.
//it returns a flat object from an Attr array
function reduceAttrToPlainObject(attrs, initObj = {}) {
Expand All @@ -273,11 +273,10 @@ function sendUpdateValueNgsi2(entityName, originMeasures, typeInformation, token
return initObj;
}
}

//Make a clone and overwrite
let typeInformation = JSON.parse(JSON.stringify(originTypeInformation));
let idTypeSSSList = pluginUtils.getIdTypeServSubServiceFromDevice(typeInformation);

//Make a clone and overwrite
typeInformation = JSON.parse(JSON.stringify(typeInformation));
//Check mandatory information: type
if (!typeInformation || !typeInformation.type) {
callback(new errors.TypeNotFound(null, entityName, typeInformation));
Expand All @@ -303,6 +302,8 @@ function sendUpdateValueNgsi2(entityName, originMeasures, typeInformation, token
let jexlctxt = {}; //will store the whole context (not just for JEXL)

let plainMeasures = null; //will contain measures POJO
//Make a clone and overwrite
typeInformation = JSON.parse(JSON.stringify(originTypeInformation));

//Rename all measures with matches with id and type to measure_id and measure_type
for (let measure of measures) {
Expand Down Expand Up @@ -545,6 +546,7 @@ function sendUpdateValueNgsi2(entityName, originMeasures, typeInformation, token
//PRE-PROCESSING FINISHED
//Explicit ATTRS and SKIPVALUES will be managed while we build NGSI payload
//Get ready to build and send NGSI payload (entities-->payload)

for (let ename in entities) {
for (let etype in entities[ename]) {
let e = {};
Expand Down

0 comments on commit 3705bd6

Please sign in to comment.