Merge branch 'develop/1.5' of github.com:thingsboard/thingsboard into develop/1.5
This commit is contained in:
commit
a8f5b0d140
@ -16,7 +16,6 @@
|
|||||||
package org.thingsboard.rule.engine.api;
|
package org.thingsboard.rule.engine.api;
|
||||||
|
|
||||||
import org.thingsboard.server.common.data.plugin.ComponentScope;
|
import org.thingsboard.server.common.data.plugin.ComponentScope;
|
||||||
import org.thingsboard.server.extensions.api.component.EmptyComponentConfiguration;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@ -32,6 +31,14 @@ public @interface EnrichmentNode {
|
|||||||
|
|
||||||
String name();
|
String name();
|
||||||
|
|
||||||
|
String nodeDescription();
|
||||||
|
|
||||||
|
String nodeDetails();
|
||||||
|
|
||||||
|
boolean inEnabled() default true;
|
||||||
|
|
||||||
|
boolean outEnabled() default true;
|
||||||
|
|
||||||
ComponentScope scope() default ComponentScope.TENANT;
|
ComponentScope scope() default ComponentScope.TENANT;
|
||||||
|
|
||||||
String descriptor() default "EmptyNodeDescriptor.json";
|
String descriptor() default "EmptyNodeDescriptor.json";
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
package org.thingsboard.rule.engine.api;
|
package org.thingsboard.rule.engine.api;
|
||||||
|
|
||||||
import org.thingsboard.server.common.data.plugin.ComponentScope;
|
import org.thingsboard.server.common.data.plugin.ComponentScope;
|
||||||
import org.thingsboard.server.extensions.api.component.EmptyComponentConfiguration;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@ -32,6 +31,14 @@ public @interface FilterNode {
|
|||||||
|
|
||||||
String name();
|
String name();
|
||||||
|
|
||||||
|
String nodeDescription();
|
||||||
|
|
||||||
|
String nodeDetails();
|
||||||
|
|
||||||
|
boolean inEnabled() default true;
|
||||||
|
|
||||||
|
boolean outEnabled() default true;
|
||||||
|
|
||||||
ComponentScope scope() default ComponentScope.TENANT;
|
ComponentScope scope() default ComponentScope.TENANT;
|
||||||
|
|
||||||
String descriptor() default "EmptyNodeDescriptor.json";
|
String descriptor() default "EmptyNodeDescriptor.json";
|
||||||
|
|||||||
@ -32,6 +32,14 @@ public @interface TransformationNode {
|
|||||||
|
|
||||||
String name();
|
String name();
|
||||||
|
|
||||||
|
String nodeDescription();
|
||||||
|
|
||||||
|
String nodeDetails();
|
||||||
|
|
||||||
|
boolean inEnabled() default true;
|
||||||
|
|
||||||
|
boolean outEnabled() default true;
|
||||||
|
|
||||||
ComponentScope scope() default ComponentScope.TENANT;
|
ComponentScope scope() default ComponentScope.TENANT;
|
||||||
|
|
||||||
String descriptor() default "EmptyNodeDescriptor.json";
|
String descriptor() default "EmptyNodeDescriptor.json";
|
||||||
|
|||||||
@ -26,7 +26,12 @@ import javax.script.Bindings;
|
|||||||
import static org.thingsboard.rule.engine.DonAsynchron.withCallback;
|
import static org.thingsboard.rule.engine.DonAsynchron.withCallback;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@FilterNode(name = "Filter Node", relationTypes = {"True", "False", "Failure"})
|
@FilterNode(name = "script", relationTypes = {"True", "False", "Failure"},
|
||||||
|
nodeDescription = "Filter incoming messages using JS script",
|
||||||
|
nodeDetails = "Evaluate incoming Message with configured JS condition. " +
|
||||||
|
"If 'True' - send Message via 'True' chain, otherwise 'False' chain is used." +
|
||||||
|
"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';'")
|
||||||
public class TbJsFilterNode implements TbNode {
|
public class TbJsFilterNode implements TbNode {
|
||||||
|
|
||||||
private TbJsFilterNodeConfiguration config;
|
private TbJsFilterNodeConfiguration config;
|
||||||
|
|||||||
@ -27,7 +27,12 @@ import java.util.Set;
|
|||||||
import static org.thingsboard.rule.engine.DonAsynchron.withCallback;
|
import static org.thingsboard.rule.engine.DonAsynchron.withCallback;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@FilterNode(name = "Switch Node", customRelations = true)
|
@FilterNode(name = "switch", customRelations = true,
|
||||||
|
nodeDescription = "Route incoming Message to one or multiple output chains",
|
||||||
|
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';' ")
|
||||||
public class TbJsSwitchNode implements TbNode {
|
public class TbJsSwitchNode implements TbNode {
|
||||||
|
|
||||||
private TbJsSwitchNodeConfiguration config;
|
private TbJsSwitchNodeConfiguration config;
|
||||||
|
|||||||
@ -24,7 +24,10 @@ import org.thingsboard.server.common.msg.TbMsg;
|
|||||||
* Created by ashvayka on 19.01.18.
|
* Created by ashvayka on 19.01.18.
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@FilterNode(name = "Message Type Filter Node")
|
@FilterNode(name = "message type",
|
||||||
|
nodeDescription = "Filter incoming messages by Message Type",
|
||||||
|
nodeDetails = "Evaluate incoming Message with configured JS condition. " +
|
||||||
|
"If incoming MessageType is expected - send Message via 'Success' chain, otherwise 'Failure' chain is used.")
|
||||||
public class TbMsgTypeFilterNode implements TbNode {
|
public class TbMsgTypeFilterNode implements TbNode {
|
||||||
|
|
||||||
TbMsgTypeFilterNodeConfiguration config;
|
TbMsgTypeFilterNodeConfiguration config;
|
||||||
|
|||||||
@ -21,12 +21,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.thingsboard.rule.engine.TbNodeUtils;
|
import org.thingsboard.rule.engine.TbNodeUtils;
|
||||||
import org.thingsboard.rule.engine.api.TbContext;
|
import org.thingsboard.rule.engine.api.*;
|
||||||
import org.thingsboard.rule.engine.api.TbNodeConfiguration;
|
|
||||||
import org.thingsboard.rule.engine.api.TbNodeException;
|
|
||||||
import org.thingsboard.rule.engine.api.TbNodeState;
|
|
||||||
import org.thingsboard.rule.engine.api.TbNode;
|
|
||||||
import org.thingsboard.rule.engine.api.EnrichmentNode;
|
|
||||||
import org.thingsboard.server.common.data.kv.AttributeKvEntry;
|
import org.thingsboard.server.common.data.kv.AttributeKvEntry;
|
||||||
import org.thingsboard.server.common.data.kv.TsKvEntry;
|
import org.thingsboard.server.common.data.kv.TsKvEntry;
|
||||||
import org.thingsboard.server.common.msg.TbMsg;
|
import org.thingsboard.server.common.msg.TbMsg;
|
||||||
@ -40,7 +35,12 @@ import static org.thingsboard.server.common.data.DataConstants.*;
|
|||||||
* Created by ashvayka on 19.01.18.
|
* Created by ashvayka on 19.01.18.
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@EnrichmentNode(name = "Get Attributes Node")
|
@EnrichmentNode(name = "originator attributes",
|
||||||
|
nodeDescription = "Add Message Originator Attributes or Latest Telemetry into Message Metadata",
|
||||||
|
nodeDetails = "If Attributes enrichment configured, CLIENT/SHARED/SERVER attributes are added into Message metadata " +
|
||||||
|
"with specific prefix: cs/shared/ss. To access those attributes in other nodes this template can be used " +
|
||||||
|
"'meta.cs.temperature' or 'meta.shared.limit' " +
|
||||||
|
"If Latest Telemetry enrichment configured, latest telemetry added into metadata without prefix.")
|
||||||
public class TbGetAttributesNode implements TbNode {
|
public class TbGetAttributesNode implements TbNode {
|
||||||
|
|
||||||
private TbGetAttributesNodeConfiguration config;
|
private TbGetAttributesNodeConfiguration config;
|
||||||
|
|||||||
@ -22,7 +22,11 @@ import org.thingsboard.rule.engine.util.EntitiesCustomerIdAsyncLoader;
|
|||||||
import org.thingsboard.server.common.data.id.CustomerId;
|
import org.thingsboard.server.common.data.id.CustomerId;
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
|
|
||||||
@EnrichmentNode(name="Get Customer Attributes Node")
|
@EnrichmentNode(name="customer attributes",
|
||||||
|
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")
|
||||||
public class TbGetCustomerAttributeNode extends TbEntityGetAttrNode<CustomerId> {
|
public class TbGetCustomerAttributeNode extends TbEntityGetAttrNode<CustomerId> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -26,7 +26,13 @@ import org.thingsboard.rule.engine.util.EntitiesRelatedEntityIdAsyncLoader;
|
|||||||
|
|
||||||
import org.thingsboard.server.common.data.id.EntityId;
|
import org.thingsboard.server.common.data.id.EntityId;
|
||||||
|
|
||||||
@EnrichmentNode(name="Get Related Entity Attributes Node")
|
@EnrichmentNode(name="related attributes",
|
||||||
|
nodeDescription = "Add Originators Related Entity Attributes or Latest Telemetry into Message Metadata",
|
||||||
|
nodeDetails = "Related Entity found using configured relation direction and Relation Type. " +
|
||||||
|
"If multiple Related Entities are found, only first Entity is used for attributes enrichment, other entities are discarded. " +
|
||||||
|
"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")
|
||||||
public class TbGetRelatedAttributeNode extends TbEntityGetAttrNode<EntityId> {
|
public class TbGetRelatedAttributeNode extends TbEntityGetAttrNode<EntityId> {
|
||||||
|
|
||||||
private TbGetRelatedAttrNodeConfiguration config;
|
private TbGetRelatedAttrNodeConfiguration config;
|
||||||
|
|||||||
@ -24,7 +24,11 @@ import org.thingsboard.server.common.data.id.EntityId;
|
|||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@EnrichmentNode(name="Get Tenant Attributes Node")
|
@EnrichmentNode(name="tenant attributes",
|
||||||
|
nodeDescription = "Add Originators Tenant 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")
|
||||||
public class TbGetTenantAttributeNode extends TbEntityGetAttrNode<TenantId> {
|
public class TbGetTenantAttributeNode extends TbEntityGetAttrNode<TenantId> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -32,7 +32,10 @@ import org.thingsboard.server.common.msg.TbMsg;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@EnrichmentNode(name = "Change Originator Node")
|
@TransformationNode(name="change originator",
|
||||||
|
nodeDescription = "Change Message Originator To Tenant/Customer/Related Entity",
|
||||||
|
nodeDetails = "Related Entity found using configured relation direction and Relation Type. " +
|
||||||
|
"If multiple Related Entities are found, only first Entity is used as new Originator, other entities are discarded. ")
|
||||||
public class TbChangeOriginatorNode extends TbAbstractTransformNode {
|
public class TbChangeOriginatorNode extends TbAbstractTransformNode {
|
||||||
|
|
||||||
protected static final String CUSTOMER_SOURCE = "CUSTOMER";
|
protected static final String CUSTOMER_SOURCE = "CUSTOMER";
|
||||||
|
|||||||
@ -23,7 +23,11 @@ import org.thingsboard.server.common.msg.TbMsg;
|
|||||||
|
|
||||||
import javax.script.Bindings;
|
import javax.script.Bindings;
|
||||||
|
|
||||||
@EnrichmentNode(name = "Transformation Node")
|
@TransformationNode(name = "script",
|
||||||
|
nodeDescription = "Change Message payload and Metadata using JavaScript",
|
||||||
|
nodeDetails = "JavaScript function recieve 2 input parameters that can be changed inside. " +
|
||||||
|
"'meta' - is a Message metadata. " +
|
||||||
|
"'msg' - is a Message payload. Any properties can be changed/removed/added in those objects.")
|
||||||
public class TbTransformMsgNode extends TbAbstractTransformNode {
|
public class TbTransformMsgNode extends TbAbstractTransformNode {
|
||||||
|
|
||||||
private TbTransformMsgNodeConfiguration config;
|
private TbTransformMsgNodeConfiguration config;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user