msg property. For example msg.temperature < 10;" +
- "Message metadata can be accessed via meta property. For example meta.customerName === 'John';",
+ "Message metadata can be accessed via metadata property. For example metadata.customerName === 'John';",
uiResources = {"static/rulenode/rulenode-core-config.js"},
configDirective = "tbFilterNodeScriptConfig")
@@ -47,7 +47,7 @@ public class TbJsFilterNode implements TbNode {
@Override
public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
this.config = TbNodeUtils.convert(configuration, TbJsFilterNodeConfiguration.class);
- this.jsEngine = new NashornJsEngine(config.getJsScript());
+ this.jsEngine = new NashornJsEngine(config.getJsScript(), "Filter");
}
@Override
diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/filter/TbJsFilterNodeConfiguration.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/filter/TbJsFilterNodeConfiguration.java
index 3b19c7c641..2d776ce3e3 100644
--- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/filter/TbJsFilterNodeConfiguration.java
+++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/filter/TbJsFilterNodeConfiguration.java
@@ -26,7 +26,7 @@ public class TbJsFilterNodeConfiguration implements NodeConfiguration {
@Override
public TbJsFilterNodeConfiguration defaultConfiguration() {
TbJsFilterNodeConfiguration configuration = new TbJsFilterNodeConfiguration();
- configuration.setJsScript("msg.passed < 15 && msg.name === 'Vit' && meta.temp == 10 && msg.bigObj.prop == 42;");
+ configuration.setJsScript("return msg.passed < 15 && msg.name === 'Vit' && metadata.temp == 10 && msg.bigObj.prop == 42;");
return configuration;
}
}
diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/filter/TbJsSwitchNode.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/filter/TbJsSwitchNode.java
index c1236a4653..98f0ebcd76 100644
--- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/filter/TbJsSwitchNode.java
+++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/filter/TbJsSwitchNode.java
@@ -36,7 +36,9 @@ import static org.thingsboard.rule.engine.DonAsynchron.withCallback;
nodeDetails = "Node executes configured JS script. Script should return array of next Chain names where Message should be routed. " +
"If Array is empty - message not routed to next Node. " +
"Message payload can be accessed via msg property. For example msg.temperature < 10; " +
- "Message metadata can be accessed via meta property. For example meta.customerName === 'John';")
+ "Message metadata can be accessed via metadata property. For example metadata.customerName === 'John';",
+ uiResources = {"static/rulenode/rulenode-core-config.js"},
+ configDirective = "tbFilterNodeSwitchConfig")
public class TbJsSwitchNode implements TbNode {
private TbJsSwitchNodeConfiguration config;
@@ -45,22 +47,11 @@ public class TbJsSwitchNode implements TbNode {
@Override
public void init(TbNodeConfiguration configuration, TbNodeState state) throws TbNodeException {
this.config = TbNodeUtils.convert(configuration, TbJsSwitchNodeConfiguration.class);
- if (config.getAllowedRelations().size() < 1) {
- String message = "Switch node should have at least 1 relation";
- log.error(message);
- throw new IllegalStateException(message);
- }
- if (!config.isRouteToAllWithNoCheck()) {
- this.jsEngine = new NashornJsEngine(config.getJsScript());
- }
+ this.jsEngine = new NashornJsEngine(config.getJsScript(), "Switch");
}
@Override
public void onMsg(TbContext ctx, TbMsg msg) {
- if (config.isRouteToAllWithNoCheck()) {
- ctx.tellNext(msg, config.getAllowedRelations());
- return;
- }
ListeningExecutor jsExecutor = ctx.getJsExecutor();
withCallback(jsExecutor.executeAsync(() -> jsEngine.executeSwitch(toBindings(msg))),
result -> processSwitch(ctx, msg, result),
@@ -68,15 +59,7 @@ public class TbJsSwitchNode implements TbNode {
}
private void processSwitch(TbContext ctx, TbMsg msg, Setmeta.cs.temperature or meta.shared.limit " +
+ "metadata.cs.temperature or metadata.shared.limit " +
"If Latest Telemetry enrichment configured, latest telemetry added into metadata without prefix.")
public class TbGetAttributesNode implements TbNode {
diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbGetCustomerAttributeNode.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbGetCustomerAttributeNode.java
index cc6d6a1197..c59a65e27d 100644
--- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbGetCustomerAttributeNode.java
+++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbGetCustomerAttributeNode.java
@@ -30,7 +30,7 @@ import org.thingsboard.server.common.data.plugin.ComponentType;
nodeDescription = "Add Originators Customer Attributes or Latest Telemetry into Message Metadata",
nodeDetails = "If Attributes enrichment configured, server scope attributes are added into Message metadata. " +
"To access those attributes in other nodes this template can be used " +
- "meta.temperature. If Latest Telemetry enrichment configured, latest telemetry added into metadata")
+ "metadata.temperature. If Latest Telemetry enrichment configured, latest telemetry added into metadata")
public class TbGetCustomerAttributeNode extends TbEntityGetAttrNodemeta.temperature. If Latest Telemetry enrichment configured, latest telemetry added into metadata")
+ "metadata.temperature. If Latest Telemetry enrichment configured, latest telemetry added into metadata")
public class TbGetRelatedAttributeNode extends TbEntityGetAttrNodemeta.temperature. If Latest Telemetry enrichment configured, latest telemetry added into metadata")
+ "metadata.temperature. If Latest Telemetry enrichment configured, latest telemetry added into metadata")
public class TbGetTenantAttributeNode extends TbEntityGetAttrNodemeta - is a Message metadata.metadata - is a Message metadata.msg - is a Message payload.