|
|
@ -46,10 +46,12 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback; |
|
|
public class TbGetOriginatorFieldsNode implements TbNode { |
|
|
public class TbGetOriginatorFieldsNode implements TbNode { |
|
|
|
|
|
|
|
|
private TbGetOriginatorFieldsConfiguration config; |
|
|
private TbGetOriginatorFieldsConfiguration config; |
|
|
|
|
|
private boolean ignoreNullStrings; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException { |
|
|
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException { |
|
|
config = TbNodeUtils.convert(configuration, TbGetOriginatorFieldsConfiguration.class); |
|
|
config = TbNodeUtils.convert(configuration, TbGetOriginatorFieldsConfiguration.class); |
|
|
|
|
|
ignoreNullStrings = config.isIgnoreNullStrings(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@ -69,7 +71,7 @@ public class TbGetOriginatorFieldsNode implements TbNode { |
|
|
return Futures.transform(EntitiesFieldsAsyncLoader.findAsync(ctx, entityId), |
|
|
return Futures.transform(EntitiesFieldsAsyncLoader.findAsync(ctx, entityId), |
|
|
data -> { |
|
|
data -> { |
|
|
config.getFieldsMapping().forEach((field, metaKey) -> { |
|
|
config.getFieldsMapping().forEach((field, metaKey) -> { |
|
|
String val = data.getFieldValue(field); |
|
|
String val = data.getFieldValue(field, ignoreNullStrings); |
|
|
if (val != null) { |
|
|
if (val != null) { |
|
|
msg.getMetaData().putValue(metaKey, val); |
|
|
msg.getMetaData().putValue(metaKey, val); |
|
|
} |
|
|
} |
|
|
|