added previousCalculatedFields property to delete requests
This commit is contained in:
		
							parent
							
								
									729d8c0a78
								
							
						
					
					
						commit
						b2c58a519c
					
				@ -156,6 +156,8 @@ public class SystemInfoController extends BaseController {
 | 
				
			|||||||
            if (debugModeRateLimitsConfig.isCalculatedFieldDebugPerTenantLimitsEnabled()) {
 | 
					            if (debugModeRateLimitsConfig.isCalculatedFieldDebugPerTenantLimitsEnabled()) {
 | 
				
			||||||
                systemParams.setCalculatedFieldDebugPerTenantLimitsConfiguration(debugModeRateLimitsConfig.getCalculatedFieldDebugPerTenantLimitsConfiguration());
 | 
					                systemParams.setCalculatedFieldDebugPerTenantLimitsConfiguration(debugModeRateLimitsConfig.getCalculatedFieldDebugPerTenantLimitsConfiguration());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            systemParams.setMaxArgumentsPerCF(tenantProfileConfiguration.getMaxArgumentsPerCF());
 | 
				
			||||||
 | 
					            systemParams.setMaxDataPointsPerRollingArg(tenantProfileConfiguration.getMaxDataPointsPerRollingArg());
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        systemParams.setMobileQrEnabled(Optional.ofNullable(qrCodeSettingService.findQrCodeSettings(TenantId.SYS_TENANT_ID))
 | 
					        systemParams.setMobileQrEnabled(Optional.ofNullable(qrCodeSettingService.findQrCodeSettings(TenantId.SYS_TENANT_ID))
 | 
				
			||||||
                .map(QrCodeSettings::getQrCodeConfig).map(QRCodeConfig::isShowOnHomePage)
 | 
					                .map(QrCodeSettings::getQrCodeConfig).map(QRCodeConfig::isShowOnHomePage)
 | 
				
			||||||
 | 
				
			|||||||
@ -50,7 +50,6 @@ import org.thingsboard.server.service.cf.ctx.state.CalculatedFieldCtx;
 | 
				
			|||||||
import org.thingsboard.server.service.profile.TbAssetProfileCache;
 | 
					import org.thingsboard.server.service.profile.TbAssetProfileCache;
 | 
				
			||||||
import org.thingsboard.server.service.profile.TbDeviceProfileCache;
 | 
					import org.thingsboard.server.service.profile.TbDeviceProfileCache;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.ArrayList;
 | 
					 | 
				
			||||||
import java.util.EnumSet;
 | 
					import java.util.EnumSet;
 | 
				
			||||||
import java.util.List;
 | 
					import java.util.List;
 | 
				
			||||||
import java.util.Set;
 | 
					import java.util.Set;
 | 
				
			||||||
@ -195,7 +194,7 @@ public class DefaultCalculatedFieldQueueService implements CalculatedFieldQueueS
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private ToCalculatedFieldMsg toCalculatedFieldTelemetryMsgProto(AttributesDeleteRequest request, List<String> removedKeys) {
 | 
					    private ToCalculatedFieldMsg toCalculatedFieldTelemetryMsgProto(AttributesDeleteRequest request, List<String> removedKeys) {
 | 
				
			||||||
        CalculatedFieldTelemetryMsgProto telemetryMsg = buildTelemetryMsgProto(request.getTenantId(), request.getEntityId(), new ArrayList<>(), request.getTbMsgId(), request.getTbMsgType())
 | 
					        CalculatedFieldTelemetryMsgProto telemetryMsg = buildTelemetryMsgProto(request.getTenantId(), request.getEntityId(), request.getPreviousCalculatedFieldIds(), request.getTbMsgId(), request.getTbMsgType())
 | 
				
			||||||
                .setScope(AttributeScopeProto.valueOf(request.getScope().name()))
 | 
					                .setScope(AttributeScopeProto.valueOf(request.getScope().name()))
 | 
				
			||||||
                .addAllRemovedAttrKeys(removedKeys).build();
 | 
					                .addAllRemovedAttrKeys(removedKeys).build();
 | 
				
			||||||
        return ToCalculatedFieldMsg.newBuilder()
 | 
					        return ToCalculatedFieldMsg.newBuilder()
 | 
				
			||||||
@ -204,7 +203,7 @@ public class DefaultCalculatedFieldQueueService implements CalculatedFieldQueueS
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private ToCalculatedFieldMsg toCalculatedFieldTelemetryMsgProto(TimeseriesDeleteRequest request, List<String> removedKeys) {
 | 
					    private ToCalculatedFieldMsg toCalculatedFieldTelemetryMsgProto(TimeseriesDeleteRequest request, List<String> removedKeys) {
 | 
				
			||||||
        CalculatedFieldTelemetryMsgProto telemetryMsg = buildTelemetryMsgProto(request.getTenantId(), request.getEntityId(), new ArrayList<>(), request.getTbMsgId(), request.getTbMsgType())
 | 
					        CalculatedFieldTelemetryMsgProto telemetryMsg = buildTelemetryMsgProto(request.getTenantId(), request.getEntityId(), request.getPreviousCalculatedFieldIds(), request.getTbMsgId(), request.getTbMsgType())
 | 
				
			||||||
                .addAllRemovedTsKeys(removedKeys).build();
 | 
					                .addAllRemovedTsKeys(removedKeys).build();
 | 
				
			||||||
        return ToCalculatedFieldMsg.newBuilder()
 | 
					        return ToCalculatedFieldMsg.newBuilder()
 | 
				
			||||||
                .setTelemetryMsg(telemetryMsg)
 | 
					                .setTelemetryMsg(telemetryMsg)
 | 
				
			||||||
 | 
				
			|||||||
@ -35,4 +35,6 @@ public class SystemParams {
 | 
				
			|||||||
    int maxDebugModeDurationMinutes;
 | 
					    int maxDebugModeDurationMinutes;
 | 
				
			||||||
    String ruleChainDebugPerTenantLimitsConfiguration;
 | 
					    String ruleChainDebugPerTenantLimitsConfiguration;
 | 
				
			||||||
    String calculatedFieldDebugPerTenantLimitsConfiguration;
 | 
					    String calculatedFieldDebugPerTenantLimitsConfiguration;
 | 
				
			||||||
 | 
					    long maxArgumentsPerCF;
 | 
				
			||||||
 | 
					    long maxDataPointsPerRollingArg;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -22,6 +22,7 @@ import lombok.AllArgsConstructor;
 | 
				
			|||||||
import lombok.Getter;
 | 
					import lombok.Getter;
 | 
				
			||||||
import lombok.ToString;
 | 
					import lombok.ToString;
 | 
				
			||||||
import org.thingsboard.server.common.data.AttributeScope;
 | 
					import org.thingsboard.server.common.data.AttributeScope;
 | 
				
			||||||
 | 
					import org.thingsboard.server.common.data.id.CalculatedFieldId;
 | 
				
			||||||
import org.thingsboard.server.common.data.id.EntityId;
 | 
					import org.thingsboard.server.common.data.id.EntityId;
 | 
				
			||||||
import org.thingsboard.server.common.data.id.TenantId;
 | 
					import org.thingsboard.server.common.data.id.TenantId;
 | 
				
			||||||
import org.thingsboard.server.common.data.msg.TbMsgType;
 | 
					import org.thingsboard.server.common.data.msg.TbMsgType;
 | 
				
			||||||
@ -32,13 +33,14 @@ import java.util.UUID;
 | 
				
			|||||||
@Getter
 | 
					@Getter
 | 
				
			||||||
@ToString
 | 
					@ToString
 | 
				
			||||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
 | 
					@AllArgsConstructor(access = AccessLevel.PRIVATE)
 | 
				
			||||||
public class AttributesDeleteRequest {
 | 
					public class AttributesDeleteRequest implements CalculatedFieldSystemAwareRequest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final TenantId tenantId;
 | 
					    private final TenantId tenantId;
 | 
				
			||||||
    private final EntityId entityId;
 | 
					    private final EntityId entityId;
 | 
				
			||||||
    private final AttributeScope scope;
 | 
					    private final AttributeScope scope;
 | 
				
			||||||
    private final List<String> keys;
 | 
					    private final List<String> keys;
 | 
				
			||||||
    private final boolean notifyDevice;
 | 
					    private final boolean notifyDevice;
 | 
				
			||||||
 | 
					    private final List<CalculatedFieldId> previousCalculatedFieldIds;
 | 
				
			||||||
    private final UUID tbMsgId;
 | 
					    private final UUID tbMsgId;
 | 
				
			||||||
    private final TbMsgType tbMsgType;
 | 
					    private final TbMsgType tbMsgType;
 | 
				
			||||||
    private final FutureCallback<Void> callback;
 | 
					    private final FutureCallback<Void> callback;
 | 
				
			||||||
@ -54,6 +56,7 @@ public class AttributesDeleteRequest {
 | 
				
			|||||||
        private AttributeScope scope;
 | 
					        private AttributeScope scope;
 | 
				
			||||||
        private List<String> keys;
 | 
					        private List<String> keys;
 | 
				
			||||||
        private boolean notifyDevice;
 | 
					        private boolean notifyDevice;
 | 
				
			||||||
 | 
					        private List<CalculatedFieldId> previousCalculatedFieldIds;
 | 
				
			||||||
        private UUID tbMsgId;
 | 
					        private UUID tbMsgId;
 | 
				
			||||||
        private TbMsgType tbMsgType;
 | 
					        private TbMsgType tbMsgType;
 | 
				
			||||||
        private FutureCallback<Void> callback;
 | 
					        private FutureCallback<Void> callback;
 | 
				
			||||||
@ -96,6 +99,11 @@ public class AttributesDeleteRequest {
 | 
				
			|||||||
            return this;
 | 
					            return this;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public Builder previousCalculatedFieldIds(List<CalculatedFieldId> previousCalculatedFieldIds) {
 | 
				
			||||||
 | 
					            this.previousCalculatedFieldIds = previousCalculatedFieldIds;
 | 
				
			||||||
 | 
					            return this;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Builder tbMsgId(UUID tbMsgId) {
 | 
					        public Builder tbMsgId(UUID tbMsgId) {
 | 
				
			||||||
            this.tbMsgId = tbMsgId;
 | 
					            this.tbMsgId = tbMsgId;
 | 
				
			||||||
            return this;
 | 
					            return this;
 | 
				
			||||||
@ -126,7 +134,7 @@ public class AttributesDeleteRequest {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public AttributesDeleteRequest build() {
 | 
					        public AttributesDeleteRequest build() {
 | 
				
			||||||
            return new AttributesDeleteRequest(tenantId, entityId, scope, keys, notifyDevice, tbMsgId, tbMsgType, callback);
 | 
					            return new AttributesDeleteRequest(tenantId, entityId, scope, keys, notifyDevice, previousCalculatedFieldIds, tbMsgId, tbMsgType, callback);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -36,7 +36,7 @@ import java.util.UUID;
 | 
				
			|||||||
@Getter
 | 
					@Getter
 | 
				
			||||||
@ToString
 | 
					@ToString
 | 
				
			||||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
 | 
					@AllArgsConstructor(access = AccessLevel.PRIVATE)
 | 
				
			||||||
public class AttributesSaveRequest {
 | 
					public class AttributesSaveRequest implements CalculatedFieldSystemAwareRequest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final TenantId tenantId;
 | 
					    private final TenantId tenantId;
 | 
				
			||||||
    private final EntityId entityId;
 | 
					    private final EntityId entityId;
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Copyright © 2016-2025 The Thingsboard Authors
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
 | 
					 * you may not use this file except in compliance with the License.
 | 
				
			||||||
 | 
					 * You may obtain a copy of the License at
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 *     http://www.apache.org/licenses/LICENSE-2.0
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Unless required by applicable law or agreed to in writing, software
 | 
				
			||||||
 | 
					 * distributed under the License is distributed on an "AS IS" BASIS,
 | 
				
			||||||
 | 
					 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
				
			||||||
 | 
					 * See the License for the specific language governing permissions and
 | 
				
			||||||
 | 
					 * limitations under the License.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					package org.thingsboard.rule.engine.api;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.thingsboard.server.common.data.id.CalculatedFieldId;
 | 
				
			||||||
 | 
					import org.thingsboard.server.common.data.msg.TbMsgType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.UUID;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public interface CalculatedFieldSystemAwareRequest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    List<CalculatedFieldId> getPreviousCalculatedFieldIds();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    UUID getTbMsgId();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    TbMsgType getTbMsgType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -20,6 +20,7 @@ import lombok.AccessLevel;
 | 
				
			|||||||
import lombok.AllArgsConstructor;
 | 
					import lombok.AllArgsConstructor;
 | 
				
			||||||
import lombok.Getter;
 | 
					import lombok.Getter;
 | 
				
			||||||
import lombok.ToString;
 | 
					import lombok.ToString;
 | 
				
			||||||
 | 
					import org.thingsboard.server.common.data.id.CalculatedFieldId;
 | 
				
			||||||
import org.thingsboard.server.common.data.id.EntityId;
 | 
					import org.thingsboard.server.common.data.id.EntityId;
 | 
				
			||||||
import org.thingsboard.server.common.data.id.TenantId;
 | 
					import org.thingsboard.server.common.data.id.TenantId;
 | 
				
			||||||
import org.thingsboard.server.common.data.kv.DeleteTsKvQuery;
 | 
					import org.thingsboard.server.common.data.kv.DeleteTsKvQuery;
 | 
				
			||||||
@ -31,12 +32,13 @@ import java.util.UUID;
 | 
				
			|||||||
@Getter
 | 
					@Getter
 | 
				
			||||||
@ToString
 | 
					@ToString
 | 
				
			||||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
 | 
					@AllArgsConstructor(access = AccessLevel.PRIVATE)
 | 
				
			||||||
public class TimeseriesDeleteRequest {
 | 
					public class TimeseriesDeleteRequest implements CalculatedFieldSystemAwareRequest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final TenantId tenantId;
 | 
					    private final TenantId tenantId;
 | 
				
			||||||
    private final EntityId entityId;
 | 
					    private final EntityId entityId;
 | 
				
			||||||
    private final List<String> keys;
 | 
					    private final List<String> keys;
 | 
				
			||||||
    private final List<DeleteTsKvQuery> deleteHistoryQueries;
 | 
					    private final List<DeleteTsKvQuery> deleteHistoryQueries;
 | 
				
			||||||
 | 
					    private final List<CalculatedFieldId> previousCalculatedFieldIds;
 | 
				
			||||||
    private final UUID tbMsgId;
 | 
					    private final UUID tbMsgId;
 | 
				
			||||||
    private final TbMsgType tbMsgType;
 | 
					    private final TbMsgType tbMsgType;
 | 
				
			||||||
    private final FutureCallback<List<String>> callback;
 | 
					    private final FutureCallback<List<String>> callback;
 | 
				
			||||||
@ -51,6 +53,7 @@ public class TimeseriesDeleteRequest {
 | 
				
			|||||||
        private EntityId entityId;
 | 
					        private EntityId entityId;
 | 
				
			||||||
        private List<String> keys;
 | 
					        private List<String> keys;
 | 
				
			||||||
        private List<DeleteTsKvQuery> deleteHistoryQueries;
 | 
					        private List<DeleteTsKvQuery> deleteHistoryQueries;
 | 
				
			||||||
 | 
					        private List<CalculatedFieldId> previousCalculatedFieldIds;
 | 
				
			||||||
        private UUID tbMsgId;
 | 
					        private UUID tbMsgId;
 | 
				
			||||||
        private TbMsgType tbMsgType;
 | 
					        private TbMsgType tbMsgType;
 | 
				
			||||||
        private FutureCallback<List<String>> callback;
 | 
					        private FutureCallback<List<String>> callback;
 | 
				
			||||||
@ -78,6 +81,11 @@ public class TimeseriesDeleteRequest {
 | 
				
			|||||||
            return this;
 | 
					            return this;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        public Builder previousCalculatedFieldIds(List<CalculatedFieldId> previousCalculatedFieldIds) {
 | 
				
			||||||
 | 
					            this.previousCalculatedFieldIds = previousCalculatedFieldIds;
 | 
				
			||||||
 | 
					            return this;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public Builder tbMsgId(UUID tbMsgId) {
 | 
					        public Builder tbMsgId(UUID tbMsgId) {
 | 
				
			||||||
            this.tbMsgId = tbMsgId;
 | 
					            this.tbMsgId = tbMsgId;
 | 
				
			||||||
            return this;
 | 
					            return this;
 | 
				
			||||||
@ -94,7 +102,7 @@ public class TimeseriesDeleteRequest {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public TimeseriesDeleteRequest build() {
 | 
					        public TimeseriesDeleteRequest build() {
 | 
				
			||||||
            return new TimeseriesDeleteRequest(tenantId, entityId, keys, deleteHistoryQueries, tbMsgId, tbMsgType, callback);
 | 
					            return new TimeseriesDeleteRequest(tenantId, entityId, keys, deleteHistoryQueries, previousCalculatedFieldIds, tbMsgId, tbMsgType, callback);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -37,7 +37,7 @@ import static java.util.Objects.requireNonNullElse;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
@Getter
 | 
					@Getter
 | 
				
			||||||
@AllArgsConstructor(access = AccessLevel.PRIVATE)
 | 
					@AllArgsConstructor(access = AccessLevel.PRIVATE)
 | 
				
			||||||
public class TimeseriesSaveRequest {
 | 
					public class TimeseriesSaveRequest implements CalculatedFieldSystemAwareRequest {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private final TenantId tenantId;
 | 
					    private final TenantId tenantId;
 | 
				
			||||||
    private final CustomerId customerId;
 | 
					    private final CustomerId customerId;
 | 
				
			||||||
 | 
				
			|||||||
@ -76,6 +76,7 @@ public class TbMsgDeleteAttributesNode implements TbNode {
 | 
				
			|||||||
                    .scope(scope)
 | 
					                    .scope(scope)
 | 
				
			||||||
                    .keys(keysToDelete)
 | 
					                    .keys(keysToDelete)
 | 
				
			||||||
                    .notifyDevice(checkNotifyDevice(msg.getMetaData().getValue(NOTIFY_DEVICE_METADATA_KEY), scope))
 | 
					                    .notifyDevice(checkNotifyDevice(msg.getMetaData().getValue(NOTIFY_DEVICE_METADATA_KEY), scope))
 | 
				
			||||||
 | 
					                    .previousCalculatedFieldIds(msg.getPreviousCalculatedFieldIds())
 | 
				
			||||||
                    .tbMsgId(msg.getId())
 | 
					                    .tbMsgId(msg.getId())
 | 
				
			||||||
                    .tbMsgType(msg.getInternalType())
 | 
					                    .tbMsgType(msg.getInternalType())
 | 
				
			||||||
                    .callback(config.isSendAttributesDeletedNotification() ?
 | 
					                    .callback(config.isSendAttributesDeletedNotification() ?
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user