From 96dfc0691bd86fd3f70d755136e3ec9a2064e42d Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Fri, 18 Dec 2020 18:07:30 +0200 Subject: [PATCH] Added device profile rule node to default edge root. Fixed notification event --- .../rule_chains/edge_root_rule_chain.json | 53 +++++++++++++------ .../controller/DeviceProfileController.java | 2 +- .../DeviceProfileMsgConstructor.java | 4 +- 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/application/src/main/data/json/tenant/rule_chains/edge_root_rule_chain.json b/application/src/main/data/json/tenant/rule_chains/edge_root_rule_chain.json index 0d777f029f..740d64627e 100644 --- a/application/src/main/data/json/tenant/rule_chains/edge_root_rule_chain.json +++ b/application/src/main/data/json/tenant/rule_chains/edge_root_rule_chain.json @@ -9,8 +9,22 @@ "configuration": null }, "metadata": { - "firstNodeIndex": 2, + "firstNodeIndex": 0, "nodes": [ + { + "additionalInfo": { + "description": "Process incoming messages from devices with the alarm rules defined in the device profile. Dispatch all incoming messages with \"Success\" relation type.", + "layoutX": 203, + "layoutY": 259 + }, + "type": "org.thingsboard.rule.engine.profile.TbDeviceProfileNode", + "name": "Device Profile Node", + "debugMode": false, + "configuration": { + "persistAlarmRulesState": false, + "fetchAlarmRulesStateOnStart": false + } + }, { "additionalInfo": { "layoutX": 823, @@ -99,42 +113,47 @@ "connections": [ { "fromIndex": 0, - "toIndex": 6, + "toIndex": 3, "type": "Success" }, { "fromIndex": 1, - "toIndex": 6, + "toIndex": 7, "type": "Success" }, { "fromIndex": 2, - "toIndex": 4, + "toIndex": 7, + "type": "Success" + }, + { + "fromIndex": 3, + "toIndex": 6, + "type": "RPC Request to Device" + }, + { + "fromIndex": 3, + "toIndex": 5, "type": "Other" }, { - "fromIndex": 2, - "toIndex": 1, + "fromIndex": 3, + "toIndex": 2, "type": "Post attributes" }, { - "fromIndex": 2, - "toIndex": 0, + "fromIndex": 3, + "toIndex": 1, "type": "Post telemetry" }, { - "fromIndex": 2, - "toIndex": 3, + "fromIndex": 3, + "toIndex": 4, "type": "RPC Request from Device" }, { - "fromIndex": 2, - "toIndex": 5, - "type": "RPC Request to Device" - }, - { - "fromIndex": 3, - "toIndex": 6, + "fromIndex": 4, + "toIndex": 7, "type": "Success" } ], diff --git a/application/src/main/java/org/thingsboard/server/controller/DeviceProfileController.java b/application/src/main/java/org/thingsboard/server/controller/DeviceProfileController.java index ddef8b2925..263e6027e1 100644 --- a/application/src/main/java/org/thingsboard/server/controller/DeviceProfileController.java +++ b/application/src/main/java/org/thingsboard/server/controller/DeviceProfileController.java @@ -103,7 +103,7 @@ public class DeviceProfileController extends BaseController { null, savedDeviceProfile.getId() == null ? ActionType.ADDED : ActionType.UPDATED, null); - sendNotificationMsgToEdgeService(getTenantId(), deviceProfile.getId(), EntityType.DEVICE_PROFILE, + sendNotificationMsgToEdgeService(getTenantId(), savedDeviceProfile.getId(), EntityType.DEVICE_PROFILE, deviceProfile.getId() == null ? EdgeEventActionType.ADDED : EdgeEventActionType.UPDATED); return savedDeviceProfile; diff --git a/application/src/main/java/org/thingsboard/server/service/edge/rpc/constructor/DeviceProfileMsgConstructor.java b/application/src/main/java/org/thingsboard/server/service/edge/rpc/constructor/DeviceProfileMsgConstructor.java index b56e1447cf..a42c1e727d 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/rpc/constructor/DeviceProfileMsgConstructor.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/rpc/constructor/DeviceProfileMsgConstructor.java @@ -38,7 +38,6 @@ public class DeviceProfileMsgConstructor { .setIdMSB(deviceProfile.getId().getId().getMostSignificantBits()) .setIdLSB(deviceProfile.getId().getId().getLeastSignificantBits()) .setName(deviceProfile.getName()) - .setDescription(deviceProfile.getDescription()) .setDefault(deviceProfile.isDefault()) .setType(deviceProfile.getType().name()) .setTransportType(deviceProfile.getTransportType().name()) @@ -52,6 +51,9 @@ public class DeviceProfileMsgConstructor { // if (deviceProfile.getDefaultQueueName() != null) { // builder.setDefaultQueueName(deviceProfile.getDefaultQueueName()); // } + if (deviceProfile.getDescription() != null) { + builder.setDescription(deviceProfile.getDescription()); + } if (deviceProfile.getProvisionDeviceKey() != null) { builder.setProvisionDeviceKey(deviceProfile.getProvisionDeviceKey()); }