Minor refactoring
This commit is contained in:
parent
41117aff2d
commit
29211774f5
@ -41,6 +41,7 @@ import org.thingsboard.server.gen.transport.TransportProtos.AttributeScopeProto;
|
|||||||
import org.thingsboard.server.gen.transport.TransportProtos.AttributeValueProto;
|
import org.thingsboard.server.gen.transport.TransportProtos.AttributeValueProto;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos.CalculatedFieldTelemetryMsgProto;
|
import org.thingsboard.server.gen.transport.TransportProtos.CalculatedFieldTelemetryMsgProto;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos.ToCalculatedFieldMsg;
|
import org.thingsboard.server.gen.transport.TransportProtos.ToCalculatedFieldMsg;
|
||||||
|
import org.thingsboard.server.gen.transport.TransportProtos.TsKvProto;
|
||||||
import org.thingsboard.server.queue.TbQueueCallback;
|
import org.thingsboard.server.queue.TbQueueCallback;
|
||||||
import org.thingsboard.server.queue.TbQueueMsgMetadata;
|
import org.thingsboard.server.queue.TbQueueMsgMetadata;
|
||||||
import org.thingsboard.server.service.cf.ctx.state.CalculatedFieldCtx;
|
import org.thingsboard.server.service.cf.ctx.state.CalculatedFieldCtx;
|
||||||
@ -200,11 +201,11 @@ public class DefaultCalculatedFieldQueueService implements CalculatedFieldQueueS
|
|||||||
List<Long> versions = result != null ? result.getVersions() : Collections.emptyList();
|
List<Long> versions = result != null ? result.getVersions() : Collections.emptyList();
|
||||||
|
|
||||||
for (int i = 0; i < entries.size(); i++) {
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
TsKvEntry tsKvEntry = entries.get(i);
|
TsKvProto.Builder tsProtoBuilder = toTsKvProto(entries.get(i)).toBuilder();
|
||||||
if (versions != null && !versions.isEmpty() && versions.get(i) != null) {
|
if (versions != null && !versions.isEmpty() && versions.get(i) != null) {
|
||||||
tsKvEntry.setVersion(versions.get(i));
|
tsProtoBuilder.setVersion(versions.get(i));
|
||||||
}
|
}
|
||||||
telemetryMsg.addTsData(toTsKvProto(tsKvEntry));
|
telemetryMsg.addTsData(tsProtoBuilder.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
return ToCalculatedFieldMsg.newBuilder().setTelemetryMsg(telemetryMsg).build();
|
return ToCalculatedFieldMsg.newBuilder().setTelemetryMsg(telemetryMsg).build();
|
||||||
|
|||||||
@ -185,10 +185,8 @@ public class CalculatedFieldCtx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lookupKey = new ReferencedEntityKey(null, ArgumentType.ATTRIBUTE, scope);
|
|
||||||
for (AttributeKvEntry attrKv : values) {
|
for (AttributeKvEntry attrKv : values) {
|
||||||
lookupKey.setKey(attrKv.getKey());
|
if (argMap.containsKey(new ReferencedEntityKey(attrKv.getKey(), ArgumentType.ATTRIBUTE, scope))) {
|
||||||
if (argMap.containsKey(lookupKey)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,17 +199,15 @@ public class CalculatedFieldCtx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lookupKey = new ReferencedEntityKey(null, null, null);
|
|
||||||
for (TsKvEntry tsKv : values) {
|
for (TsKvEntry tsKv : values) {
|
||||||
lookupKey.setKey(tsKv.getKey());
|
|
||||||
|
|
||||||
lookupKey.setType(ArgumentType.TS_LATEST);
|
ReferencedEntityKey latestKey = new ReferencedEntityKey(tsKv.getKey(), ArgumentType.TS_LATEST, null);
|
||||||
if (argMap.containsKey(lookupKey)) {
|
if (argMap.containsKey(latestKey)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
lookupKey.setType(ArgumentType.TS_ROLLING);
|
ReferencedEntityKey rollingKey = new ReferencedEntityKey(tsKv.getKey(), ArgumentType.TS_ROLLING, null);
|
||||||
if (argMap.containsKey(lookupKey)) {
|
if (argMap.containsKey(rollingKey)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,10 +228,9 @@ public class CalculatedFieldCtx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lookupKey = new ReferencedEntityKey(null, ArgumentType.ATTRIBUTE, scope);
|
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
lookupKey.setKey(key);
|
ReferencedEntityKey attrKey = new ReferencedEntityKey(key, ArgumentType.ATTRIBUTE, scope);
|
||||||
if (argMap.containsKey(lookupKey)) {
|
if (argMap.containsKey(attrKey)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -248,17 +243,15 @@ public class CalculatedFieldCtx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lookupKey = new ReferencedEntityKey(null, null, null);
|
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
lookupKey.setKey(key);
|
|
||||||
|
|
||||||
lookupKey.setType(ArgumentType.TS_LATEST);
|
ReferencedEntityKey latestKey = new ReferencedEntityKey(key, ArgumentType.TS_LATEST, null);
|
||||||
if (argMap.containsKey(lookupKey)) {
|
if (argMap.containsKey(latestKey)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
lookupKey.setType(ArgumentType.TS_ROLLING);
|
ReferencedEntityKey rollingKey = new ReferencedEntityKey(key, ArgumentType.TS_ROLLING, null);
|
||||||
if (argMap.containsKey(lookupKey)) {
|
if (argMap.containsKey(rollingKey)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user