Browse Source
Merge pull request #1695 from ShvaykaD/update/TbAbstractGetAttributesNode
change parameter of method findEntityIdAsync
pull/1728/head
Andrew Shvayka
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
10 additions and
6 deletions
-
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbAbstractGetAttributesNode.java
-
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbGetAttributesNode.java
-
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/metadata/TbGetDeviceAttrNode.java
|
|
|
@ -51,7 +51,7 @@ public abstract class TbAbstractGetAttributesNode<C extends TbGetAttributesNodeC |
|
|
|
public void onMsg(TbContext ctx, TbMsg msg) throws TbNodeException { |
|
|
|
try { |
|
|
|
withCallback( |
|
|
|
findEntityIdAsync(ctx, msg.getOriginator()), |
|
|
|
findEntityIdAsync(ctx, msg), |
|
|
|
entityId -> safePutAttributes(ctx, msg, entityId), |
|
|
|
t -> ctx.tellFailure(msg, t), ctx.getDbCallbackExecutor()); |
|
|
|
} catch (Throwable th) { |
|
|
|
@ -112,5 +112,5 @@ public abstract class TbAbstractGetAttributesNode<C extends TbGetAttributesNodeC |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
protected abstract ListenableFuture<T> findEntityIdAsync(TbContext ctx, EntityId originator); |
|
|
|
protected abstract ListenableFuture<T> findEntityIdAsync(TbContext ctx, TbMsg msg); |
|
|
|
} |
|
|
|
|
|
|
|
@ -25,6 +25,7 @@ import org.thingsboard.rule.engine.api.TbNodeConfiguration; |
|
|
|
import org.thingsboard.rule.engine.api.TbNodeException; |
|
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
|
import org.thingsboard.server.common.data.plugin.ComponentType; |
|
|
|
import org.thingsboard.server.common.msg.TbMsg; |
|
|
|
|
|
|
|
/** |
|
|
|
* Created by ashvayka on 19.01.18. |
|
|
|
@ -48,7 +49,8 @@ public class TbGetAttributesNode extends TbAbstractGetAttributesNode<TbGetAttrib |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected ListenableFuture<EntityId> findEntityIdAsync(TbContext ctx, EntityId originator) { |
|
|
|
return Futures.immediateFuture(originator); |
|
|
|
protected ListenableFuture<EntityId> findEntityIdAsync(TbContext ctx, TbMsg msg) { |
|
|
|
return Futures.immediateFuture(msg.getOriginator()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -26,6 +26,7 @@ import org.thingsboard.rule.engine.util.EntitiesRelatedDeviceIdAsyncLoader; |
|
|
|
import org.thingsboard.server.common.data.id.DeviceId; |
|
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
|
import org.thingsboard.server.common.data.plugin.ComponentType; |
|
|
|
import org.thingsboard.server.common.msg.TbMsg; |
|
|
|
|
|
|
|
@Slf4j |
|
|
|
@RuleNode(type = ComponentType.ENRICHMENT, |
|
|
|
@ -46,7 +47,8 @@ public class TbGetDeviceAttrNode extends TbAbstractGetAttributesNode<TbGetDevice |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
protected ListenableFuture<DeviceId> findEntityIdAsync(TbContext ctx, EntityId originator) { |
|
|
|
return EntitiesRelatedDeviceIdAsyncLoader.findDeviceAsync(ctx, originator, config.getDeviceRelationsQuery()); |
|
|
|
protected ListenableFuture<DeviceId> findEntityIdAsync(TbContext ctx, TbMsg msg) { |
|
|
|
return EntitiesRelatedDeviceIdAsyncLoader.findDeviceAsync(ctx, msg.getOriginator(), config.getDeviceRelationsQuery()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|