diff --git a/application/src/main/java/org/thingsboard/server/service/cf/CalculatedFieldCache.java b/application/src/main/java/org/thingsboard/server/service/cf/CalculatedFieldCache.java index 17d9c1672b..3ea6925695 100644 --- a/application/src/main/java/org/thingsboard/server/service/cf/CalculatedFieldCache.java +++ b/application/src/main/java/org/thingsboard/server/service/cf/CalculatedFieldCache.java @@ -33,13 +33,13 @@ public interface CalculatedFieldCache { CalculatedField getCalculatedField(CalculatedFieldId calculatedFieldId); - List getCalculatedFieldsByEntityId(TenantId tenantId, EntityId entityId); + List getCalculatedFieldsByEntityId(EntityId entityId); - List getCalculatedFieldLinksByEntityId(TenantId tenantId, EntityId entityId); + List getCalculatedFieldLinksByEntityId(EntityId entityId); CalculatedFieldCtx getCalculatedFieldCtx(CalculatedFieldId calculatedFieldId); - List getCalculatedFieldCtxsByEntityId(TenantId tenantId, EntityId entityId); + List getCalculatedFieldCtxsByEntityId(EntityId entityId); Stream getCalculatedFieldCtxsByType(TenantId tenantId, CalculatedFieldType cfType); diff --git a/application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldCache.java b/application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldCache.java index b52a989c64..8a7d38970f 100644 --- a/application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldCache.java +++ b/application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldCache.java @@ -108,17 +108,13 @@ public class DefaultCalculatedFieldCache implements CalculatedFieldCache { } @Override - public List getCalculatedFieldsByEntityId(TenantId tenantId, EntityId entityId) { - return entityIdCalculatedFields.getOrDefault(entityId, Collections.emptyList()).stream() - .filter(cf -> cf.getTenantId().equals(tenantId)) - .toList(); + public List getCalculatedFieldsByEntityId(EntityId entityId) { + return entityIdCalculatedFields.getOrDefault(entityId, Collections.emptyList()); } @Override - public List getCalculatedFieldLinksByEntityId(TenantId tenantId, EntityId entityId) { - return entityIdCalculatedFieldLinks.getOrDefault(entityId, Collections.emptyList()).stream() - .filter(link -> link.tenantId().equals(tenantId)) - .toList(); + public List getCalculatedFieldLinksByEntityId(EntityId entityId) { + return entityIdCalculatedFieldLinks.getOrDefault(entityId, Collections.emptyList()); } @Override @@ -146,11 +142,11 @@ public class DefaultCalculatedFieldCache implements CalculatedFieldCache { } @Override - public List getCalculatedFieldCtxsByEntityId(TenantId tenantId, EntityId entityId) { + public List getCalculatedFieldCtxsByEntityId(EntityId entityId) { if (entityId == null) { return Collections.emptyList(); } - return getCalculatedFieldsByEntityId(tenantId, entityId).stream() + return getCalculatedFieldsByEntityId(entityId).stream() .map(cf -> getCalculatedFieldCtx(cf.getId())) .toList(); } @@ -164,7 +160,7 @@ public class DefaultCalculatedFieldCache implements CalculatedFieldCache { @Override public boolean hasCalculatedFields(TenantId tenantId, EntityId entityId, Predicate filter) { - List entityCfs = getCalculatedFieldCtxsByEntityId(tenantId, entityId); + List entityCfs = getCalculatedFieldCtxsByEntityId(entityId); for (CalculatedFieldCtx ctx : entityCfs) { if (filter.test(ctx)) { return true; @@ -177,7 +173,7 @@ public class DefaultCalculatedFieldCache implements CalculatedFieldCache { public boolean hasCalculatedFieldsByProfile(TenantId tenantId, EntityId entityId, Predicate filter) { EntityId profileId = getProfileId(tenantId, entityId); if (profileId != null) { - List profileCfs = getCalculatedFieldCtxsByEntityId(tenantId, profileId); + List profileCfs = getCalculatedFieldCtxsByEntityId(profileId); for (CalculatedFieldCtx ctx : profileCfs) { if (filter.test(ctx)) { return true; diff --git a/application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldQueueService.java b/application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldQueueService.java index 4dae1c6549..4c6128f4ba 100644 --- a/application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldQueueService.java +++ b/application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldQueueService.java @@ -171,7 +171,7 @@ public class DefaultCalculatedFieldQueueService implements CalculatedFieldQueueS return true; } - List links = calculatedFieldCache.getCalculatedFieldLinksByEntityId(tenantId, entityId); + List links = calculatedFieldCache.getCalculatedFieldLinksByEntityId(entityId); for (CalculatedFieldLink link : links) { CalculatedFieldCtx ctx = calculatedFieldCache.getCalculatedFieldCtx(link.calculatedFieldId()); if (ctx != null && linkedEntityFilter.test(ctx)) { @@ -180,11 +180,11 @@ public class DefaultCalculatedFieldQueueService implements CalculatedFieldQueueS } for (EntityId dynamicEntity : calculatedFieldCache.getDynamicEntities(tenantId, entityId)) { - if (calculatedFieldCache.getCalculatedFieldCtxsByEntityId(tenantId, dynamicEntity).stream().anyMatch(dynamicSourceFilter)) { + if (calculatedFieldCache.getCalculatedFieldCtxsByEntityId(dynamicEntity).stream().anyMatch(dynamicSourceFilter)) { return true; } EntityId dynamicEntityProfileId = calculatedFieldCache.getProfileId(tenantId, dynamicEntity); - if (calculatedFieldCache.getCalculatedFieldCtxsByEntityId(tenantId, dynamicEntityProfileId).stream().anyMatch(dynamicSourceFilter)) { + if (calculatedFieldCache.getCalculatedFieldCtxsByEntityId(dynamicEntityProfileId).stream().anyMatch(dynamicSourceFilter)) { return true; } }