refactor code, update logic callback
This commit is contained in:
parent
29d3efa205
commit
e77c939b67
@ -71,10 +71,6 @@ public class TbMsgAttributesNode implements TbNode {
|
||||
ctx.tellSuccess(msg);
|
||||
return;
|
||||
}
|
||||
FutureCallback<Void> callback = new TelemetryNodeCallback(ctx, msg);
|
||||
if (config.isSendAttributesUpdatedNotification()) {
|
||||
callback = new AttributesUpdateNodeCallback(ctx, msg, config.getScope(), attributes);
|
||||
}
|
||||
String notifyDeviceStr = msg.getMetaData().getValue("notifyDevice");
|
||||
ctx.getTelemetryService().saveAndNotify(
|
||||
ctx.getTenantId(),
|
||||
@ -82,7 +78,9 @@ public class TbMsgAttributesNode implements TbNode {
|
||||
config.getScope(),
|
||||
attributes,
|
||||
config.getNotifyDevice() || StringUtils.isEmpty(notifyDeviceStr) || Boolean.parseBoolean(notifyDeviceStr),
|
||||
callback
|
||||
config.isSendAttributesUpdatedNotification() ?
|
||||
new AttributesUpdateNodeCallback(ctx, msg, config.getScope(), attributes) :
|
||||
new TelemetryNodeCallback(ctx, msg)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -50,14 +50,12 @@ public class TbMsgDeleteAttributes implements TbNode {
|
||||
private TbMsgDeleteAttributesConfiguration config;
|
||||
private String scope;
|
||||
private List<String> keys;
|
||||
private boolean sendAttributesDeletedNotification;
|
||||
|
||||
@Override
|
||||
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
|
||||
this.config = TbNodeUtils.convert(configuration, TbMsgDeleteAttributesConfiguration.class);
|
||||
this.scope = config.getScope();
|
||||
this.keys = config.getKeys();
|
||||
this.sendAttributesDeletedNotification = config.isSendAttributesDeletedNotification();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -70,11 +68,15 @@ public class TbMsgDeleteAttributes implements TbNode {
|
||||
if (keysToDelete.isEmpty()) {
|
||||
ctx.tellSuccess(msg);
|
||||
} else {
|
||||
FutureCallback<Void> callback = new TelemetryNodeCallback(ctx, msg);
|
||||
if (sendAttributesDeletedNotification) {
|
||||
callback = new AttributesDeleteNodeCallback(ctx, msg, scope, keysToDelete);
|
||||
}
|
||||
ctx.getTelemetryService().deleteAndNotify(ctx.getTenantId(), msg.getOriginator(), scope, keysToDelete, callback);
|
||||
ctx.getTelemetryService().deleteAndNotify(
|
||||
ctx.getTenantId(),
|
||||
msg.getOriginator(),
|
||||
scope,
|
||||
keysToDelete,
|
||||
config.isSendAttributesDeletedNotification() ?
|
||||
new AttributesDeleteNodeCallback(ctx, msg, scope, keysToDelete) :
|
||||
new TelemetryNodeCallback(ctx, msg)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user