Merge pull request #7678 from thingsboard/feature/attribute_nodes_add_options_send_notification
Backport ability to specify scope in the metadata
This commit is contained in:
commit
c35c4e991b
@ -51,8 +51,8 @@ import java.util.List;
|
|||||||
public class TbMsgAttributesNode implements TbNode {
|
public class TbMsgAttributesNode implements TbNode {
|
||||||
|
|
||||||
private TbMsgAttributesNodeConfiguration config;
|
private TbMsgAttributesNodeConfiguration config;
|
||||||
private String scope;
|
|
||||||
private boolean sendAttributesUpdateNotification;
|
private static final String SCOPE = "scope";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
|
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
|
||||||
@ -60,10 +60,6 @@ public class TbMsgAttributesNode implements TbNode {
|
|||||||
if (config.getNotifyDevice() == null) {
|
if (config.getNotifyDevice() == null) {
|
||||||
config.setNotifyDevice(true);
|
config.setNotifyDevice(true);
|
||||||
}
|
}
|
||||||
this.scope = config.getScope();
|
|
||||||
this.sendAttributesUpdateNotification = config.isSendAttributesUpdatedNotification()
|
|
||||||
&& !DataConstants.CLIENT_SCOPE.equals(scope);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -78,7 +74,12 @@ public class TbMsgAttributesNode implements TbNode {
|
|||||||
ctx.tellSuccess(msg);
|
ctx.tellSuccess(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String scope = msg.getMetaData().getValue(SCOPE);
|
||||||
|
if (StringUtils.isEmpty(scope)) {
|
||||||
|
scope = config.getScope();
|
||||||
|
}
|
||||||
String notifyDeviceStr = msg.getMetaData().getValue("notifyDevice");
|
String notifyDeviceStr = msg.getMetaData().getValue("notifyDevice");
|
||||||
|
boolean sendAttributesUpdateNotification = checkSendNotification(scope);
|
||||||
ctx.getTelemetryService().saveAndNotify(
|
ctx.getTelemetryService().saveAndNotify(
|
||||||
ctx.getTenantId(),
|
ctx.getTenantId(),
|
||||||
msg.getOriginator(),
|
msg.getOriginator(),
|
||||||
@ -91,4 +92,8 @@ public class TbMsgAttributesNode implements TbNode {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkSendNotification(String scope){
|
||||||
|
return config.isSendAttributesUpdatedNotification() && !DataConstants.CLIENT_SCOPE.equals(scope);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user