Commit a8f5b0d140dc8382854d107f3c5f0cfa68d3e9e2
Merge branch 'develop/1.5' of github.com:thingsboard/thingsboard into develop/1.5
Showing
12 changed files
with
75 additions
and
19 deletions
@@ -16,7 +16,6 @@ | @@ -16,7 +16,6 @@ | ||
16 | package org.thingsboard.rule.engine.api; | 16 | package org.thingsboard.rule.engine.api; |
17 | 17 | ||
18 | import org.thingsboard.server.common.data.plugin.ComponentScope; | 18 | import org.thingsboard.server.common.data.plugin.ComponentScope; |
19 | -import org.thingsboard.server.extensions.api.component.EmptyComponentConfiguration; | ||
20 | 19 | ||
21 | import java.lang.annotation.ElementType; | 20 | import java.lang.annotation.ElementType; |
22 | import java.lang.annotation.Retention; | 21 | import java.lang.annotation.Retention; |
@@ -32,11 +31,19 @@ public @interface EnrichmentNode { | @@ -32,11 +31,19 @@ public @interface EnrichmentNode { | ||
32 | 31 | ||
33 | String name(); | 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 | ComponentScope scope() default ComponentScope.TENANT; | 42 | ComponentScope scope() default ComponentScope.TENANT; |
36 | 43 | ||
37 | String descriptor() default "EmptyNodeDescriptor.json"; | 44 | String descriptor() default "EmptyNodeDescriptor.json"; |
38 | 45 | ||
39 | - String[] relationTypes() default {"Success","Failure"}; | 46 | + String[] relationTypes() default {"Success", "Failure"}; |
40 | 47 | ||
41 | boolean customRelations() default false; | 48 | boolean customRelations() default false; |
42 | } | 49 | } |
@@ -16,7 +16,6 @@ | @@ -16,7 +16,6 @@ | ||
16 | package org.thingsboard.rule.engine.api; | 16 | package org.thingsboard.rule.engine.api; |
17 | 17 | ||
18 | import org.thingsboard.server.common.data.plugin.ComponentScope; | 18 | import org.thingsboard.server.common.data.plugin.ComponentScope; |
19 | -import org.thingsboard.server.extensions.api.component.EmptyComponentConfiguration; | ||
20 | 19 | ||
21 | import java.lang.annotation.ElementType; | 20 | import java.lang.annotation.ElementType; |
22 | import java.lang.annotation.Retention; | 21 | import java.lang.annotation.Retention; |
@@ -32,11 +31,19 @@ public @interface FilterNode { | @@ -32,11 +31,19 @@ public @interface FilterNode { | ||
32 | 31 | ||
33 | String name(); | 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 | ComponentScope scope() default ComponentScope.TENANT; | 42 | ComponentScope scope() default ComponentScope.TENANT; |
36 | 43 | ||
37 | String descriptor() default "EmptyNodeDescriptor.json"; | 44 | String descriptor() default "EmptyNodeDescriptor.json"; |
38 | 45 | ||
39 | - String[] relationTypes() default {"Success","Failure"}; | 46 | + String[] relationTypes() default {"Success", "Failure"}; |
40 | 47 | ||
41 | boolean customRelations() default false; | 48 | boolean customRelations() default false; |
42 | 49 |
@@ -32,6 +32,14 @@ public @interface TransformationNode { | @@ -32,6 +32,14 @@ public @interface TransformationNode { | ||
32 | 32 | ||
33 | String name(); | 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 | ComponentScope scope() default ComponentScope.TENANT; | 43 | ComponentScope scope() default ComponentScope.TENANT; |
36 | 44 | ||
37 | String descriptor() default "EmptyNodeDescriptor.json"; | 45 | String descriptor() default "EmptyNodeDescriptor.json"; |
@@ -26,7 +26,12 @@ import javax.script.Bindings; | @@ -26,7 +26,12 @@ import javax.script.Bindings; | ||
26 | import static org.thingsboard.rule.engine.DonAsynchron.withCallback; | 26 | import static org.thingsboard.rule.engine.DonAsynchron.withCallback; |
27 | 27 | ||
28 | @Slf4j | 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 | public class TbJsFilterNode implements TbNode { | 35 | public class TbJsFilterNode implements TbNode { |
31 | 36 | ||
32 | private TbJsFilterNodeConfiguration config; | 37 | private TbJsFilterNodeConfiguration config; |
@@ -27,7 +27,12 @@ import java.util.Set; | @@ -27,7 +27,12 @@ import java.util.Set; | ||
27 | import static org.thingsboard.rule.engine.DonAsynchron.withCallback; | 27 | import static org.thingsboard.rule.engine.DonAsynchron.withCallback; |
28 | 28 | ||
29 | @Slf4j | 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 | public class TbJsSwitchNode implements TbNode { | 36 | public class TbJsSwitchNode implements TbNode { |
32 | 37 | ||
33 | private TbJsSwitchNodeConfiguration config; | 38 | private TbJsSwitchNodeConfiguration config; |
@@ -24,7 +24,10 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -24,7 +24,10 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
24 | * Created by ashvayka on 19.01.18. | 24 | * Created by ashvayka on 19.01.18. |
25 | */ | 25 | */ |
26 | @Slf4j | 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 | public class TbMsgTypeFilterNode implements TbNode { | 31 | public class TbMsgTypeFilterNode implements TbNode { |
29 | 32 | ||
30 | TbMsgTypeFilterNodeConfiguration config; | 33 | TbMsgTypeFilterNodeConfiguration config; |
@@ -21,12 +21,7 @@ import com.google.common.util.concurrent.ListenableFuture; | @@ -21,12 +21,7 @@ import com.google.common.util.concurrent.ListenableFuture; | ||
21 | import lombok.extern.slf4j.Slf4j; | 21 | import lombok.extern.slf4j.Slf4j; |
22 | import org.apache.commons.collections.CollectionUtils; | 22 | import org.apache.commons.collections.CollectionUtils; |
23 | import org.thingsboard.rule.engine.TbNodeUtils; | 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 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; | 25 | import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
31 | import org.thingsboard.server.common.data.kv.TsKvEntry; | 26 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
32 | import org.thingsboard.server.common.msg.TbMsg; | 27 | import org.thingsboard.server.common.msg.TbMsg; |
@@ -40,7 +35,12 @@ import static org.thingsboard.server.common.data.DataConstants.*; | @@ -40,7 +35,12 @@ import static org.thingsboard.server.common.data.DataConstants.*; | ||
40 | * Created by ashvayka on 19.01.18. | 35 | * Created by ashvayka on 19.01.18. |
41 | */ | 36 | */ |
42 | @Slf4j | 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 | public class TbGetAttributesNode implements TbNode { | 44 | public class TbGetAttributesNode implements TbNode { |
45 | 45 | ||
46 | private TbGetAttributesNodeConfiguration config; | 46 | private TbGetAttributesNodeConfiguration config; |
@@ -22,7 +22,11 @@ import org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader; | @@ -22,7 +22,11 @@ import org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader; | ||
22 | import org.thingsboard.server.common.data.id.CustomerId; | 22 | import org.thingsboard.server.common.data.id.CustomerId; |
23 | import org.thingsboard.server.common.data.id.EntityId; | 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 | public class TbGetCustomerAttributeNode extends TbEntityGetAttrNode<CustomerId> { | 30 | public class TbGetCustomerAttributeNode extends TbEntityGetAttrNode<CustomerId> { |
27 | 31 | ||
28 | @Override | 32 | @Override |
@@ -26,7 +26,13 @@ import org.thingsboard.rule.engine.util.EntitiesRelatedEntityIdAsyncLoader; | @@ -26,7 +26,13 @@ import org.thingsboard.rule.engine.util.EntitiesRelatedEntityIdAsyncLoader; | ||
26 | 26 | ||
27 | import org.thingsboard.server.common.data.id.EntityId; | 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 | public class TbGetRelatedAttributeNode extends TbEntityGetAttrNode<EntityId> { | 36 | public class TbGetRelatedAttributeNode extends TbEntityGetAttrNode<EntityId> { |
31 | 37 | ||
32 | private TbGetRelatedAttrNodeConfiguration config; | 38 | private TbGetRelatedAttrNodeConfiguration config; |
@@ -24,7 +24,11 @@ import org.thingsboard.server.common.data.id.EntityId; | @@ -24,7 +24,11 @@ import org.thingsboard.server.common.data.id.EntityId; | ||
24 | import org.thingsboard.server.common.data.id.TenantId; | 24 | import org.thingsboard.server.common.data.id.TenantId; |
25 | 25 | ||
26 | @Slf4j | 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 | public class TbGetTenantAttributeNode extends TbEntityGetAttrNode<TenantId> { | 32 | public class TbGetTenantAttributeNode extends TbEntityGetAttrNode<TenantId> { |
29 | 33 | ||
30 | @Override | 34 | @Override |
@@ -32,7 +32,10 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -32,7 +32,10 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
32 | import java.util.HashSet; | 32 | import java.util.HashSet; |
33 | 33 | ||
34 | @Slf4j | 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 | public class TbChangeOriginatorNode extends TbAbstractTransformNode { | 39 | public class TbChangeOriginatorNode extends TbAbstractTransformNode { |
37 | 40 | ||
38 | protected static final String CUSTOMER_SOURCE = "CUSTOMER"; | 41 | protected static final String CUSTOMER_SOURCE = "CUSTOMER"; |
@@ -23,7 +23,11 @@ import org.thingsboard.server.common.msg.TbMsg; | @@ -23,7 +23,11 @@ import org.thingsboard.server.common.msg.TbMsg; | ||
23 | 23 | ||
24 | import javax.script.Bindings; | 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 | public class TbTransformMsgNode extends TbAbstractTransformNode { | 31 | public class TbTransformMsgNode extends TbAbstractTransformNode { |
28 | 32 | ||
29 | private TbTransformMsgNodeConfiguration config; | 33 | private TbTransformMsgNodeConfiguration config; |