Skip to content

Commit

Permalink
Merge pull request #1010 from telefonicaid/task/find_group_without_type
Browse files Browse the repository at this point in the history
fix group command in device when entity_type is not equal group entity_type
  • Loading branch information
fgalan committed Apr 7, 2021
2 parents da2ea21 + e41ca45 commit 6f6f1bb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
17 changes: 9 additions & 8 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
- Hotfix: avoid automatic conversion from geo:xxxx ('xxxx' diferent from 'json') to geo:json (reverts the work done in PR #854)
- Add: use getDeviceSilently in checkDuplicates to avoid raise a false mongo alarm.
- Add: expose getConfigurationSilently to enable retrieve a configuration without raise a false mongo alarm (#1007)
- Add: db uri and options in mongo connection log INFO trace
- Set Nodejs 12 as minimum version in packages.json (effectively removing Nodev10 from supported versions)
- Update MongoDB to use lean() for faster retrieval
- Fix: PUT /iot/devices/:deviceId operation to implement proper update of entity_name and entity_type (#770)
- Fix: auto-provision functionality not working as expected when configured at device/group level in NGSIv1 API (#1003)
- Fix: group command is not provisioned in device when entity_type is different (#1011)
- Hotfix: avoid automatic conversion from geo:xxxx ('xxxx' diferent from 'json') to geo:json (reverts the work done in PR #854)
- Add: use getDeviceSilently in checkDuplicates to avoid raise a false mongo alarm.
- Add: expose getConfigurationSilently to enable retrieve a configuration without raise a false mongo alarm (#1007)
- Add: db uri and options in mongo connection log INFO trace
- Set Nodejs 12 as minimum version in packages.json (effectively removing Nodev10 from supported versions)
- Update MongoDB to use lean() for faster retrieval
- Fix: PUT /iot/devices/:deviceId operation to implement proper update of entity_name and entity_type (#770)
- Fix: auto-provision functionality not working as expected when configured at device/group level in NGSIv1 API (#1003)
28 changes: 13 additions & 15 deletions lib/services/devices/deviceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,7 @@ function findConfigurationGroup(deviceObj, callback) {
} else {
config
.getGroupRegistry()
.findTypeSilently(
deviceObj.service,
deviceObj.subservice,
deviceObj.type,
deviceObj.apikey,
handlerGroupFind
);
.findSilently(deviceObj.service, deviceObj.subservice, deviceObj.apikey, handlerGroupFind);
}
}

Expand All @@ -225,15 +219,19 @@ function findConfigurationGroup(deviceObj, callback) {
*/
function registerDevice(deviceObj, callback) {
function checkDuplicates(deviceObj, innerCb) {
config.getRegistry().getSilently(deviceObj.id, deviceObj.service, deviceObj.subservice,
/* eslint-disable-next-line no-unused-vars */
function (error, device) {
if (!error) {
innerCb(new errors.DuplicateDeviceId(deviceObj.id));
} else {
innerCb();
config.getRegistry().getSilently(
deviceObj.id,
deviceObj.service,
deviceObj.subservice,
/* eslint-disable-next-line no-unused-vars */
function (error, device) {
if (!error) {
innerCb(new errors.DuplicateDeviceId(deviceObj.id));
} else {
innerCb();
}
}
});
);
}

function prepareDeviceData(deviceObj, configuration, callback) {
Expand Down
1 change: 1 addition & 0 deletions lib/services/groups/groupRegistryMemory.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ exports.find = intoTrans(context, find);
exports.findBy = intoTrans(context, findBy);
exports.findType = intoTrans(context, findBy(['service', 'subservice', 'type']));
exports.findTypeSilently = intoTrans(context, findBy(['service', 'subservice', 'type']));
exports.findSilently = intoTrans(context, findBy(['service', 'subservice']));
exports.get = intoTrans(context, getSingleGroup);
exports.getSilently = intoTrans(context, getSingleGroup);
exports.getType = intoTrans(context, getSingleGroupType);
Expand Down
1 change: 1 addition & 0 deletions lib/services/groups/groupRegistryMongoDB.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ exports.findType = alarmsInt(
intoTrans(context, findBy(['service', 'subservice', 'type', 'apikey']))
);
exports.findTypeSilently = intoTrans(context, findBy(['service', 'subservice', 'type', 'apikey']));
exports.findSilently = intoTrans(context, findBy(['service', 'subservice', 'apikey']));
exports.findBy = alarmsInt(constants.MONGO_ALARM, intoTrans(context, findBy));
exports.get = alarmsInt(constants.MONGO_ALARM, intoTrans(context, findBy(['resource', 'apikey'])));
exports.getSilently = intoTrans(context, findBy(['resource', 'apikey']));
Expand Down

0 comments on commit 6f6f1bb

Please sign in to comment.