|
|
|
@ -24,6 +24,7 @@ import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.ConcurrentReferenceHashMap; |
|
|
|
import org.thingsboard.server.actors.ActorSystemContext; |
|
|
|
import org.thingsboard.server.common.data.EntityType; |
|
|
|
import org.thingsboard.server.common.data.TenantProfile; |
|
|
|
import org.thingsboard.server.common.data.cf.CalculatedField; |
|
|
|
import org.thingsboard.server.common.data.cf.CalculatedFieldLink; |
|
|
|
import org.thingsboard.server.common.data.cf.CalculatedFieldType; |
|
|
|
@ -33,8 +34,10 @@ import org.thingsboard.server.common.data.id.CalculatedFieldId; |
|
|
|
import org.thingsboard.server.common.data.id.DeviceId; |
|
|
|
import org.thingsboard.server.common.data.id.EntityId; |
|
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
|
import org.thingsboard.server.common.data.id.TenantProfileId; |
|
|
|
import org.thingsboard.server.common.data.page.PageDataIterable; |
|
|
|
import org.thingsboard.server.dao.cf.CalculatedFieldService; |
|
|
|
import org.thingsboard.server.dao.tenant.TbTenantProfileCache; |
|
|
|
import org.thingsboard.server.queue.util.AfterStartUp; |
|
|
|
import org.thingsboard.server.service.cf.ctx.state.CalculatedFieldCtx; |
|
|
|
import org.thingsboard.server.service.profile.TbAssetProfileCache; |
|
|
|
@ -61,6 +64,7 @@ public class DefaultCalculatedFieldCache implements CalculatedFieldCache { |
|
|
|
private final CalculatedFieldService calculatedFieldService; |
|
|
|
private final TbAssetProfileCache assetProfileCache; |
|
|
|
private final TbDeviceProfileCache deviceProfileCache; |
|
|
|
private final TbTenantProfileCache tenantProfileCache; |
|
|
|
@Lazy |
|
|
|
private final ActorSystemContext systemContext; |
|
|
|
private final OwnerService ownerService; |
|
|
|
@ -228,8 +232,13 @@ public class DefaultCalculatedFieldCache implements CalculatedFieldCache { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void handleTenantProfileUpdate() { |
|
|
|
calculatedFieldsCtx.values().forEach(CalculatedFieldCtx::updateTenantProfileProperties); |
|
|
|
public void handleTenantProfileUpdate(TenantProfileId tenantProfileId) { |
|
|
|
calculatedFieldsCtx.values().stream() |
|
|
|
.filter(ctx -> { |
|
|
|
TenantProfile tenantProfile = tenantProfileCache.get(ctx.getTenantId()); |
|
|
|
return tenantProfile != null && tenantProfileId.equals(tenantProfile.getId()); |
|
|
|
}) |
|
|
|
.forEach(CalculatedFieldCtx::updateTenantProfileProperties); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
|