From e251bc575036753744daa321bd2ca6017665b0bd Mon Sep 17 00:00:00 2001 From: Andrew Shvayka Date: Sat, 2 May 2020 18:12:43 +0300 Subject: [PATCH] Improvement to deserialization and remove debug on dashboards --- .../data/json/demo/rule_chains/root_rule_chain.json | 4 ++-- .../json/demo/rule_chains/thermostat_alarms.json | 4 ++-- .../org/thingsboard/server/common/msg/TbMsg.java | 12 +++++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/application/src/main/data/json/demo/rule_chains/root_rule_chain.json b/application/src/main/data/json/demo/rule_chains/root_rule_chain.json index 32cecf6e4e..9805c6f996 100644 --- a/application/src/main/data/json/demo/rule_chains/root_rule_chain.json +++ b/application/src/main/data/json/demo/rule_chains/root_rule_chain.json @@ -17,7 +17,7 @@ }, "type": "org.thingsboard.rule.engine.filter.TbJsFilterNode", "name": "Is Thermostat?", - "debugMode": true, + "debugMode": false, "configuration": { "jsScript": "return msg.id.entityType === \"DEVICE\" && msg.type === \"thermostat\";" } @@ -113,7 +113,7 @@ }, "type": "org.thingsboard.rule.engine.action.TbCreateRelationNode", "name": "Relate to Asset", - "debugMode": true, + "debugMode": false, "configuration": { "direction": "FROM", "relationType": "ToAlarmPropagationAsset", diff --git a/application/src/main/data/json/demo/rule_chains/thermostat_alarms.json b/application/src/main/data/json/demo/rule_chains/thermostat_alarms.json index 8fd10c88f1..d67052cbc5 100644 --- a/application/src/main/data/json/demo/rule_chains/thermostat_alarms.json +++ b/application/src/main/data/json/demo/rule_chains/thermostat_alarms.json @@ -81,7 +81,7 @@ }, "type": "org.thingsboard.rule.engine.filter.TbJsSwitchNode", "name": "Check Alarms", - "debugMode": true, + "debugMode": false, "configuration": { "jsScript": "var relations = [];\nif(metadata[\"ss_alarmTemperature\"] === \"true\"){\n if(msg.temperature > metadata[\"ss_thresholdTemperature\"]){\n relations.push(\"NewTempAlarm\");\n } else {\n relations.push(\"ClearTempAlarm\");\n }\n}\nif(metadata[\"ss_alarmHumidity\"] === \"true\"){\n if(msg.humidity < metadata[\"ss_thresholdHumidity\"]){\n relations.push(\"NewHumidityAlarm\");\n } else {\n relations.push(\"ClearHumidityAlarm\");\n }\n}\n\nreturn relations;" } @@ -93,7 +93,7 @@ }, "type": "org.thingsboard.rule.engine.metadata.TbGetAttributesNode", "name": "Fetch Configuration", - "debugMode": true, + "debugMode": false, "configuration": { "clientAttributeNames": [], "sharedAttributeNames": [], diff --git a/common/message/src/main/java/org/thingsboard/server/common/msg/TbMsg.java b/common/message/src/main/java/org/thingsboard/server/common/msg/TbMsg.java index 3edf4e5061..9da7407552 100644 --- a/common/message/src/main/java/org/thingsboard/server/common/msg/TbMsg.java +++ b/common/message/src/main/java/org/thingsboard/server/common/msg/TbMsg.java @@ -27,6 +27,7 @@ import org.thingsboard.server.common.data.id.RuleNodeId; import org.thingsboard.server.common.msg.gen.MsgProtos; import org.thingsboard.server.common.msg.queue.TbMsgCallback; +import java.io.IOException; import java.io.Serializable; import java.util.UUID; @@ -47,7 +48,7 @@ public final class TbMsg implements Serializable { private final RuleChainId ruleChainId; private final RuleNodeId ruleNodeId; //This field is not serialized because we use queues and there is no need to do it - private final TbMsgCallback callback; + transient private final TbMsgCallback callback; public static TbMsg newMsg(String type, EntityId originator, TbMsgMetaData metaData, String data) { return new TbMsg(UUID.randomUUID(), type, originator, metaData.copy(), TbMsgDataType.JSON, data, null, null, TbMsgCallback.EMPTY); @@ -156,4 +157,13 @@ public final class TbMsg implements Serializable { public TbMsg copyWithRuleNodeId(RuleChainId ruleChainId, RuleNodeId ruleNodeId) { return new TbMsg(this.id, this.type, this.originator, this.metaData, this.dataType, this.data, ruleChainId, ruleNodeId, callback); } + + public TbMsgCallback getCallback() { + //May be null in case of deserialization; + if (callback != null) { + return callback; + } else { + return TbMsgCallback.EMPTY; + } + } }