Commit a8f5b0d140dc8382854d107f3c5f0cfa68d3e9e2

Authored by Igor Kulikov
2 parents dff2ca0c f8ec713d

Merge branch 'develop/1.5' of github.com:thingsboard/thingsboard into develop/1.5

... ... @@ -16,7 +16,6 @@
16 16 package org.thingsboard.rule.engine.api;
17 17
18 18 import org.thingsboard.server.common.data.plugin.ComponentScope;
19   -import org.thingsboard.server.extensions.api.component.EmptyComponentConfiguration;
20 19
21 20 import java.lang.annotation.ElementType;
22 21 import java.lang.annotation.Retention;
... ... @@ -32,11 +31,19 @@ public @interface EnrichmentNode {
32 31
33 32 String name();
34 33
  34 + String nodeDescription();
  35 +
  36 + String nodeDetails();
  37 +
  38 + boolean inEnabled() default true;
  39 +
  40 + boolean outEnabled() default true;
  41 +
35 42 ComponentScope scope() default ComponentScope.TENANT;
36 43
37 44 String descriptor() default "EmptyNodeDescriptor.json";
38 45
39   - String[] relationTypes() default {"Success","Failure"};
  46 + String[] relationTypes() default {"Success", "Failure"};
40 47
41 48 boolean customRelations() default false;
42 49 }
... ...
... ... @@ -16,7 +16,6 @@
16 16 package org.thingsboard.rule.engine.api;
17 17
18 18 import org.thingsboard.server.common.data.plugin.ComponentScope;
19   -import org.thingsboard.server.extensions.api.component.EmptyComponentConfiguration;
20 19
21 20 import java.lang.annotation.ElementType;
22 21 import java.lang.annotation.Retention;
... ... @@ -32,11 +31,19 @@ public @interface FilterNode {
32 31
33 32 String name();
34 33
  34 + String nodeDescription();
  35 +
  36 + String nodeDetails();
  37 +
  38 + boolean inEnabled() default true;
  39 +
  40 + boolean outEnabled() default true;
  41 +
35 42 ComponentScope scope() default ComponentScope.TENANT;
36 43
37 44 String descriptor() default "EmptyNodeDescriptor.json";
38 45
39   - String[] relationTypes() default {"Success","Failure"};
  46 + String[] relationTypes() default {"Success", "Failure"};
40 47
41 48 boolean customRelations() default false;
42 49
... ...
... ... @@ -32,6 +32,14 @@ public @interface TransformationNode {
32 32
33 33 String name();
34 34
  35 + String nodeDescription();
  36 +
  37 + String nodeDetails();
  38 +
  39 + boolean inEnabled() default true;
  40 +
  41 + boolean outEnabled() default true;
  42 +
35 43 ComponentScope scope() default ComponentScope.TENANT;
36 44
37 45 String descriptor() default "EmptyNodeDescriptor.json";
... ...
... ... @@ -26,7 +26,12 @@ import javax.script.Bindings;
26 26 import static org.thingsboard.rule.engine.DonAsynchron.withCallback;
27 27
28 28 @Slf4j
29   -@FilterNode(name = "Filter Node", relationTypes = {"True", "False", "Failure"})
  29 +@FilterNode(name = "script", relationTypes = {"True", "False", "Failure"},
  30 + nodeDescription = "Filter incoming messages using JS script",
  31 + nodeDetails = "Evaluate incoming Message with configured JS condition. " +
  32 + "If 'True' - send Message via 'True' chain, otherwise 'False' chain is used." +
  33 + "Message payload can be accessed via 'msg' property. For example 'msg.temperature < 10;'" +
  34 + "Message metadata can be accessed via 'meta' property. For example 'meta.customerName === 'John';'")
30 35 public class TbJsFilterNode implements TbNode {
31 36
32 37 private TbJsFilterNodeConfiguration config;
... ...
... ... @@ -27,7 +27,12 @@ import java.util.Set;
27 27 import static org.thingsboard.rule.engine.DonAsynchron.withCallback;
28 28
29 29 @Slf4j
30   -@FilterNode(name = "Switch Node", customRelations = true)
  30 +@FilterNode(name = "switch", customRelations = true,
  31 + nodeDescription = "Route incoming Message to one or multiple output chains",
  32 + nodeDetails = "Node executes configured JS script. Script should return array of next Chain names where Message should be routed. " +
  33 + "If Array is empty - message not routed to next Node. " +
  34 + "Message payload can be accessed via 'msg' property. For example 'msg.temperature < 10;' " +
  35 + "Message metadata can be accessed via 'meta' property. For example 'meta.customerName === 'John';' ")
31 36 public class TbJsSwitchNode implements TbNode {
32 37
33 38 private TbJsSwitchNodeConfiguration config;
... ...
... ... @@ -24,7 +24,10 @@ import org.thingsboard.server.common.msg.TbMsg;
24 24 * Created by ashvayka on 19.01.18.
25 25 */
26 26 @Slf4j
27   -@FilterNode(name = "Message Type Filter Node")
  27 +@FilterNode(name = "message type",
  28 + nodeDescription = "Filter incoming messages by Message Type",
  29 + nodeDetails = "Evaluate incoming Message with configured JS condition. " +
  30 + "If incoming MessageType is expected - send Message via 'Success' chain, otherwise 'Failure' chain is used.")
28 31 public class TbMsgTypeFilterNode implements TbNode {
29 32
30 33 TbMsgTypeFilterNodeConfiguration config;
... ...
... ... @@ -21,12 +21,7 @@ import com.google.common.util.concurrent.ListenableFuture;
21 21 import lombok.extern.slf4j.Slf4j;
22 22 import org.apache.commons.collections.CollectionUtils;
23 23 import org.thingsboard.rule.engine.TbNodeUtils;
24   -import org.thingsboard.rule.engine.api.TbContext;
25   -import org.thingsboard.rule.engine.api.TbNodeConfiguration;
26   -import org.thingsboard.rule.engine.api.TbNodeException;
27   -import org.thingsboard.rule.engine.api.TbNodeState;
28   -import org.thingsboard.rule.engine.api.TbNode;
29   -import org.thingsboard.rule.engine.api.EnrichmentNode;
  24 +import org.thingsboard.rule.engine.api.*;
30 25 import org.thingsboard.server.common.data.kv.AttributeKvEntry;
31 26 import org.thingsboard.server.common.data.kv.TsKvEntry;
32 27 import org.thingsboard.server.common.msg.TbMsg;
... ... @@ -40,7 +35,12 @@ import static org.thingsboard.server.common.data.DataConstants.*;
40 35 * Created by ashvayka on 19.01.18.
41 36 */
42 37 @Slf4j
43   -@EnrichmentNode(name = "Get Attributes Node")
  38 +@EnrichmentNode(name = "originator attributes",
  39 + nodeDescription = "Add Message Originator Attributes or Latest Telemetry into Message Metadata",
  40 + nodeDetails = "If Attributes enrichment configured, CLIENT/SHARED/SERVER attributes are added into Message metadata " +
  41 + "with specific prefix: cs/shared/ss. To access those attributes in other nodes this template can be used " +
  42 + "'meta.cs.temperature' or 'meta.shared.limit' " +
  43 + "If Latest Telemetry enrichment configured, latest telemetry added into metadata without prefix.")
44 44 public class TbGetAttributesNode implements TbNode {
45 45
46 46 private TbGetAttributesNodeConfiguration config;
... ...
... ... @@ -22,7 +22,11 @@ import org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader;
22 22 import org.thingsboard.server.common.data.id.CustomerId;
23 23 import org.thingsboard.server.common.data.id.EntityId;
24 24
25   -@EnrichmentNode(name="Get Customer Attributes Node")
  25 +@EnrichmentNode(name="customer attributes",
  26 + nodeDescription = "Add Originators Customer Attributes or Latest Telemetry into Message Metadata",
  27 + nodeDetails = "If Attributes enrichment configured, server scope attributes are added into Message metadata. " +
  28 + "To access those attributes in other nodes this template can be used " +
  29 + "'meta.temperature'. If Latest Telemetry enrichment configured, latest telemetry added into metadata")
26 30 public class TbGetCustomerAttributeNode extends TbEntityGetAttrNode<CustomerId> {
27 31
28 32 @Override
... ...
... ... @@ -26,7 +26,13 @@ import org.thingsboard.rule.engine.util.EntitiesRelatedEntityIdAsyncLoader;
26 26
27 27 import org.thingsboard.server.common.data.id.EntityId;
28 28
29   -@EnrichmentNode(name="Get Related Entity Attributes Node")
  29 +@EnrichmentNode(name="related attributes",
  30 + nodeDescription = "Add Originators Related Entity Attributes or Latest Telemetry into Message Metadata",
  31 + nodeDetails = "Related Entity found using configured relation direction and Relation Type. " +
  32 + "If multiple Related Entities are found, only first Entity is used for attributes enrichment, other entities are discarded. " +
  33 + "If Attributes enrichment configured, server scope attributes are added into Message metadata. " +
  34 + "To access those attributes in other nodes this template can be used " +
  35 + "'meta.temperature'. If Latest Telemetry enrichment configured, latest telemetry added into metadata")
30 36 public class TbGetRelatedAttributeNode extends TbEntityGetAttrNode<EntityId> {
31 37
32 38 private TbGetRelatedAttrNodeConfiguration config;
... ...
... ... @@ -24,7 +24,11 @@ import org.thingsboard.server.common.data.id.EntityId;
24 24 import org.thingsboard.server.common.data.id.TenantId;
25 25
26 26 @Slf4j
27   -@EnrichmentNode(name="Get Tenant Attributes Node")
  27 +@EnrichmentNode(name="tenant attributes",
  28 + nodeDescription = "Add Originators Tenant Attributes or Latest Telemetry into Message Metadata",
  29 + nodeDetails = "If Attributes enrichment configured, server scope attributes are added into Message metadata. " +
  30 + "To access those attributes in other nodes this template can be used " +
  31 + "'meta.temperature'. If Latest Telemetry enrichment configured, latest telemetry added into metadata")
28 32 public class TbGetTenantAttributeNode extends TbEntityGetAttrNode<TenantId> {
29 33
30 34 @Override
... ...
... ... @@ -32,7 +32,10 @@ import org.thingsboard.server.common.msg.TbMsg;
32 32 import java.util.HashSet;
33 33
34 34 @Slf4j
35   -@EnrichmentNode(name = "Change Originator Node")
  35 +@TransformationNode(name="change originator",
  36 + nodeDescription = "Change Message Originator To Tenant/Customer/Related Entity",
  37 + nodeDetails = "Related Entity found using configured relation direction and Relation Type. " +
  38 + "If multiple Related Entities are found, only first Entity is used as new Originator, other entities are discarded. ")
36 39 public class TbChangeOriginatorNode extends TbAbstractTransformNode {
37 40
38 41 protected static final String CUSTOMER_SOURCE = "CUSTOMER";
... ...
... ... @@ -23,7 +23,11 @@ import org.thingsboard.server.common.msg.TbMsg;
23 23
24 24 import javax.script.Bindings;
25 25
26   -@EnrichmentNode(name = "Transformation Node")
  26 +@TransformationNode(name = "script",
  27 + nodeDescription = "Change Message payload and Metadata using JavaScript",
  28 + nodeDetails = "JavaScript function recieve 2 input parameters that can be changed inside. " +
  29 + "'meta' - is a Message metadata. " +
  30 + "'msg' - is a Message payload. Any properties can be changed/removed/added in those objects.")
27 31 public class TbTransformMsgNode extends TbAbstractTransformNode {
28 32
29 33 private TbTransformMsgNodeConfiguration config;
... ...