Browse Source

Improvements for compatibility with PE

pull/14107/head
VIacheslavKlimov 1 year ago
parent
commit
ab77b5d6b7
  1. 5
      application/src/main/java/org/thingsboard/server/service/cf/AbstractCalculatedFieldProcessingService.java
  2. 2
      application/src/main/java/org/thingsboard/server/service/cf/CalculatedFieldCache.java
  3. 3
      application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldCache.java
  4. 7
      application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldProcessingService.java

5
application/src/main/java/org/thingsboard/server/service/cf/AbstractCalculatedFieldProcessingService.java

@ -60,7 +60,7 @@ import static org.thingsboard.server.utils.CalculatedFieldArgumentUtils.transfor
@Data @Data
@Slf4j @Slf4j
public abstract class AbstractCalculatedFieldProcessingService implements CalculatedFieldProcessingService { public abstract class AbstractCalculatedFieldProcessingService {
protected final AttributesService attributesService; protected final AttributesService attributesService;
protected final TimeseriesService timeseriesService; protected final TimeseriesService timeseriesService;
@ -84,8 +84,7 @@ public abstract class AbstractCalculatedFieldProcessingService implements Calcul
protected abstract String getExecutorNamePrefix(); protected abstract String getExecutorNamePrefix();
@Override protected ListenableFuture<Map<String, ArgumentEntry>> fetchArguments(CalculatedFieldCtx ctx, EntityId entityId) {
public ListenableFuture<Map<String, ArgumentEntry>> fetchArguments(CalculatedFieldCtx ctx, EntityId entityId) {
Map<String, ListenableFuture<ArgumentEntry>> argFutures = switch (ctx.getCalculatedField().getType()) { Map<String, ListenableFuture<ArgumentEntry>> argFutures = switch (ctx.getCalculatedField().getType()) {
case GEOFENCING -> fetchGeofencingCalculatedFieldArguments(ctx, entityId, false); case GEOFENCING -> fetchGeofencingCalculatedFieldArguments(ctx, entityId, false);
case SIMPLE, SCRIPT, ALARM -> { case SIMPLE, SCRIPT, ALARM -> {

2
application/src/main/java/org/thingsboard/server/service/cf/CalculatedFieldCache.java

@ -45,4 +45,6 @@ public interface CalculatedFieldCache {
void evict(CalculatedFieldId calculatedFieldId); void evict(CalculatedFieldId calculatedFieldId);
EntityId getProfileId(TenantId tenantId, EntityId entityId);
} }

3
application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldCache.java

@ -211,7 +211,8 @@ public class DefaultCalculatedFieldCache implements CalculatedFieldCache {
log.debug("[{}] evict calculated field links from cached links by entity id: {}", calculatedFieldId, oldCalculatedField); log.debug("[{}] evict calculated field links from cached links by entity id: {}", calculatedFieldId, oldCalculatedField);
} }
private EntityId getProfileId(TenantId tenantId, EntityId entityId) { @Override
public EntityId getProfileId(TenantId tenantId, EntityId entityId) {
return switch (entityId.getEntityType()) { return switch (entityId.getEntityType()) {
case ASSET -> assetProfileCache.get(tenantId, (AssetId) entityId).getId(); case ASSET -> assetProfileCache.get(tenantId, (AssetId) entityId).getId();
case DEVICE -> deviceProfileCache.get(tenantId, (DeviceId) entityId).getId(); case DEVICE -> deviceProfileCache.get(tenantId, (DeviceId) entityId).getId();

7
application/src/main/java/org/thingsboard/server/service/cf/DefaultCalculatedFieldProcessingService.java

@ -60,7 +60,7 @@ import static org.thingsboard.server.utils.CalculatedFieldUtils.toProto;
@TbRuleEngineComponent @TbRuleEngineComponent
@Service @Service
@Slf4j @Slf4j
public class DefaultCalculatedFieldProcessingService extends AbstractCalculatedFieldProcessingService { public class DefaultCalculatedFieldProcessingService extends AbstractCalculatedFieldProcessingService implements CalculatedFieldProcessingService {
private final TbClusterService clusterService; private final TbClusterService clusterService;
private final PartitionService partitionService; private final PartitionService partitionService;
@ -81,6 +81,11 @@ public class DefaultCalculatedFieldProcessingService extends AbstractCalculatedF
return "calculated-field-callback"; return "calculated-field-callback";
} }
@Override
public ListenableFuture<Map<String, ArgumentEntry>> fetchArguments(CalculatedFieldCtx ctx, EntityId entityId) {
return super.fetchArguments(ctx, entityId);
}
@Override @Override
public Map<String, ArgumentEntry> fetchDynamicArgsFromDb(CalculatedFieldCtx ctx, EntityId entityId) { public Map<String, ArgumentEntry> fetchDynamicArgsFromDb(CalculatedFieldCtx ctx, EntityId entityId) {
// only geofencing calculated fields supports dynamic arguments scheduled updates // only geofencing calculated fields supports dynamic arguments scheduled updates

Loading…
Cancel
Save