Provide better naming for edgeVersion boolean version check. Minor refactoring
This commit is contained in:
parent
a8aeaa80c1
commit
286c46f8c6
@ -18,6 +18,7 @@ package org.thingsboard.server.service.edge.rpc.constructor;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.thingsboard.common.util.JacksonUtil;
|
import org.thingsboard.common.util.JacksonUtil;
|
||||||
import org.thingsboard.server.common.data.AdminSettings;
|
import org.thingsboard.server.common.data.AdminSettings;
|
||||||
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.gen.edge.v1.AdminSettingsUpdateMsg;
|
import org.thingsboard.server.gen.edge.v1.AdminSettingsUpdateMsg;
|
||||||
import org.thingsboard.server.gen.edge.v1.EdgeVersion;
|
import org.thingsboard.server.gen.edge.v1.EdgeVersion;
|
||||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||||
@ -29,16 +30,16 @@ public class AdminSettingsMsgConstructor {
|
|||||||
|
|
||||||
public AdminSettingsUpdateMsg constructAdminSettingsUpdateMsg(AdminSettings adminSettings, EdgeVersion edgeVersion) {
|
public AdminSettingsUpdateMsg constructAdminSettingsUpdateMsg(AdminSettings adminSettings, EdgeVersion edgeVersion) {
|
||||||
if (EdgeVersionUtils.isEdgeVersionOlderThan_3_6_2(edgeVersion)) {
|
if (EdgeVersionUtils.isEdgeVersionOlderThan_3_6_2(edgeVersion)) {
|
||||||
return constructDeprecatedWidgetTypeUpdateMsg(adminSettings);
|
return constructDeprecatedAdminSettingsUpdateMsg(adminSettings);
|
||||||
}
|
}
|
||||||
return AdminSettingsUpdateMsg.newBuilder().setEntity(JacksonUtil.toString(adminSettings)).build();
|
return AdminSettingsUpdateMsg.newBuilder().setEntity(JacksonUtil.toString(adminSettings)).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private AdminSettingsUpdateMsg constructDeprecatedWidgetTypeUpdateMsg(AdminSettings adminSettings) {
|
private AdminSettingsUpdateMsg constructDeprecatedAdminSettingsUpdateMsg(AdminSettings adminSettings) {
|
||||||
AdminSettingsUpdateMsg.Builder builder = AdminSettingsUpdateMsg.newBuilder()
|
AdminSettingsUpdateMsg.Builder builder = AdminSettingsUpdateMsg.newBuilder()
|
||||||
.setKey(adminSettings.getKey())
|
.setKey(adminSettings.getKey())
|
||||||
.setJsonValue(JacksonUtil.toString(adminSettings.getJsonValue()));
|
.setJsonValue(JacksonUtil.toString(adminSettings.getJsonValue()));
|
||||||
if (adminSettings.getId() != null) {
|
if (TenantId.SYS_TENANT_ID.equals(adminSettings.getTenantId())) {
|
||||||
builder.setIsSystem(true);
|
builder.setIsSystem(true);
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
|
|||||||
@ -74,5 +74,4 @@ public class AssetProfileMsgConstructor {
|
|||||||
.setIdMSB(assetProfileId.getId().getMostSignificantBits())
|
.setIdMSB(assetProfileId.getId().getMostSignificantBits())
|
||||||
.setIdLSB(assetProfileId.getId().getLeastSignificantBits()).build();
|
.setIdLSB(assetProfileId.getId().getLeastSignificantBits()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,9 +35,9 @@ public class TenantProfileMsgConstructor {
|
|||||||
private DataDecodingEncodingService dataDecodingEncodingService;
|
private DataDecodingEncodingService dataDecodingEncodingService;
|
||||||
|
|
||||||
public TenantProfileUpdateMsg constructTenantProfileUpdateMsg(UpdateMsgType msgType, TenantProfile tenantProfile, EdgeVersion edgeVersion) {
|
public TenantProfileUpdateMsg constructTenantProfileUpdateMsg(UpdateMsgType msgType, TenantProfile tenantProfile, EdgeVersion edgeVersion) {
|
||||||
ByteString profileData = EdgeVersionUtils.isEdgeVersionOlderThan(edgeVersion, EdgeVersion.V_3_6_1) ?
|
|
||||||
ByteString.empty() : ByteString.copyFrom(dataDecodingEncodingService.encode(tenantProfile.getProfileData()));
|
|
||||||
if (EdgeVersionUtils.isEdgeVersionOlderThan_3_6_2(edgeVersion)) {
|
if (EdgeVersionUtils.isEdgeVersionOlderThan_3_6_2(edgeVersion)) {
|
||||||
|
ByteString profileData = EdgeVersionUtils.isEdgeVersionOlderThan(edgeVersion, EdgeVersion.V_3_6_1) ?
|
||||||
|
ByteString.empty() : ByteString.copyFrom(dataDecodingEncodingService.encode(tenantProfile.getProfileData()));
|
||||||
return constructDeprecatedTenantProfileUpdateMsg(msgType, tenantProfile, profileData);
|
return constructDeprecatedTenantProfileUpdateMsg(msgType, tenantProfile, profileData);
|
||||||
}
|
}
|
||||||
return TenantProfileUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(tenantProfile)).build();
|
return TenantProfileUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(tenantProfile)).build();
|
||||||
|
|||||||
@ -38,8 +38,9 @@ public class WidgetsBundleMsgConstructor {
|
|||||||
if (EdgeVersionUtils.isEdgeVersionOlderThan_3_6_2(edgeVersion)) {
|
if (EdgeVersionUtils.isEdgeVersionOlderThan_3_6_2(edgeVersion)) {
|
||||||
return constructDeprecatedWidgetsBundleUpdateMsg(msgType, widgetsBundle, widgets);
|
return constructDeprecatedWidgetsBundleUpdateMsg(msgType, widgetsBundle, widgets);
|
||||||
}
|
}
|
||||||
return WidgetsBundleUpdateMsg.newBuilder().setWidgets(JacksonUtil.toString(widgets)).setEntity(JacksonUtil.toString(widgetsBundle))
|
return WidgetsBundleUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(widgetsBundle))
|
||||||
.setMsgType(msgType).setIdMSB(widgetsBundle.getId().getId().getMostSignificantBits())
|
.setWidgets(JacksonUtil.toString(widgets))
|
||||||
|
.setIdMSB(widgetsBundle.getId().getId().getMostSignificantBits())
|
||||||
.setIdLSB(widgetsBundle.getId().getId().getLeastSignificantBits()).build();
|
.setIdLSB(widgetsBundle.getId().getId().getLeastSignificantBits()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -148,8 +148,8 @@ public class AssetEdgeProcessor extends BaseAssetProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setCustomerId(TenantId tenantId, CustomerId customerId, Asset asset, AssetUpdateMsg assetUpdateMsg, boolean isEdgeVersionDeprecated) {
|
protected void setCustomerId(TenantId tenantId, CustomerId customerId, Asset asset, AssetUpdateMsg assetUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2) {
|
||||||
CustomerId customerUUID = isEdgeVersionDeprecated
|
CustomerId customerUUID = isEdgeVersionOlderThan_3_6_2
|
||||||
? safeGetCustomerId(assetUpdateMsg.getCustomerIdMSB(), assetUpdateMsg.getCustomerIdLSB())
|
? safeGetCustomerId(assetUpdateMsg.getCustomerIdMSB(), assetUpdateMsg.getCustomerIdLSB())
|
||||||
: asset.getCustomerId() != null ? asset.getCustomerId() : customerId;
|
: asset.getCustomerId() != null ? asset.getCustomerId() : customerId;
|
||||||
asset.setCustomerId(customerUUID);
|
asset.setCustomerId(customerUUID);
|
||||||
|
|||||||
@ -134,16 +134,16 @@ public class AssetProfileEdgeProcessor extends BaseAssetProfileProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setDefaultEdgeRuleChainId(AssetProfile assetProfile, RuleChainId ruleChainId, AssetProfileUpdateMsg assetProfileUpdateMsg, boolean isEdgeVersionDeprecated) {
|
protected void setDefaultEdgeRuleChainId(AssetProfile assetProfile, RuleChainId ruleChainId, AssetProfileUpdateMsg assetProfileUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2) {
|
||||||
UUID defaultEdgeRuleChainUUID = isEdgeVersionDeprecated
|
UUID defaultEdgeRuleChainUUID = isEdgeVersionOlderThan_3_6_2
|
||||||
? safeGetUUID(assetProfileUpdateMsg.getDefaultRuleChainIdMSB(), assetProfileUpdateMsg.getDefaultRuleChainIdLSB())
|
? safeGetUUID(assetProfileUpdateMsg.getDefaultRuleChainIdMSB(), assetProfileUpdateMsg.getDefaultRuleChainIdLSB())
|
||||||
: ruleChainId != null ? ruleChainId.getId() : null;
|
: ruleChainId != null ? ruleChainId.getId() : null;
|
||||||
assetProfile.setDefaultEdgeRuleChainId(defaultEdgeRuleChainUUID != null ? new RuleChainId(defaultEdgeRuleChainUUID) : null);
|
assetProfile.setDefaultEdgeRuleChainId(defaultEdgeRuleChainUUID != null ? new RuleChainId(defaultEdgeRuleChainUUID) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setDefaultDashboardId(TenantId tenantId, DashboardId dashboardId, AssetProfile assetProfile, AssetProfileUpdateMsg assetProfileUpdateMsg, boolean isEdgeVersionDeprecated) {
|
protected void setDefaultDashboardId(TenantId tenantId, DashboardId dashboardId, AssetProfile assetProfile, AssetProfileUpdateMsg assetProfileUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2) {
|
||||||
UUID defaultDashboardUUID = isEdgeVersionDeprecated
|
UUID defaultDashboardUUID = isEdgeVersionOlderThan_3_6_2
|
||||||
? safeGetUUID(assetProfileUpdateMsg.getDefaultDashboardIdMSB(), assetProfileUpdateMsg.getDefaultDashboardIdLSB())
|
? safeGetUUID(assetProfileUpdateMsg.getDefaultDashboardIdMSB(), assetProfileUpdateMsg.getDefaultDashboardIdLSB())
|
||||||
: assetProfile.getDefaultDashboardId() != null ? assetProfile.getDefaultDashboardId().getId() : (dashboardId != null ? dashboardId.getId() : null);
|
: assetProfile.getDefaultDashboardId() != null ? assetProfile.getDefaultDashboardId().getId() : (dashboardId != null ? dashboardId.getId() : null);
|
||||||
assetProfile.setDefaultDashboardId(defaultDashboardUUID != null ? new DashboardId(defaultDashboardUUID) : null);
|
assetProfile.setDefaultDashboardId(defaultDashboardUUID != null ? new DashboardId(defaultDashboardUUID) : null);
|
||||||
|
|||||||
@ -94,6 +94,5 @@ public abstract class BaseAssetProcessor extends BaseEdgeProcessor {
|
|||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void setCustomerId(TenantId tenantId, CustomerId customerId, Asset asset, AssetUpdateMsg assetUpdateMsg, boolean isEdgeVersionDeprecated);
|
protected abstract void setCustomerId(TenantId tenantId, CustomerId customerId, Asset asset, AssetUpdateMsg assetUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,7 @@ public abstract class BaseAssetProfileProcessor extends BaseEdgeProcessor {
|
|||||||
|
|
||||||
protected abstract void setDefaultRuleChainId(TenantId tenantId, AssetProfile assetProfile, RuleChainId ruleChainId);
|
protected abstract void setDefaultRuleChainId(TenantId tenantId, AssetProfile assetProfile, RuleChainId ruleChainId);
|
||||||
|
|
||||||
protected abstract void setDefaultEdgeRuleChainId(AssetProfile assetProfile, RuleChainId ruleChainId, AssetProfileUpdateMsg assetProfileUpdateMsg, boolean isEdgeVersionDeprecated);
|
protected abstract void setDefaultEdgeRuleChainId(AssetProfile assetProfile, RuleChainId ruleChainId, AssetProfileUpdateMsg assetProfileUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2);
|
||||||
|
|
||||||
protected abstract void setDefaultDashboardId(TenantId tenantId, DashboardId dashboardId, AssetProfile assetProfile, AssetProfileUpdateMsg assetProfileUpdateMsg, boolean isEdgeVersionDeprecated);
|
protected abstract void setDefaultDashboardId(TenantId tenantId, DashboardId dashboardId, AssetProfile assetProfile, AssetProfileUpdateMsg assetProfileUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -159,5 +159,5 @@ public abstract class BaseDeviceProcessor extends BaseEdgeProcessor {
|
|||||||
return deviceCredentials;
|
return deviceCredentials;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void setCustomerId(TenantId tenantId, CustomerId customerId, Device device, DeviceUpdateMsg deviceUpdateMsg, boolean isEdgeVersionDeprecated);
|
protected abstract void setCustomerId(TenantId tenantId, CustomerId customerId, Device device, DeviceUpdateMsg deviceUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,12 +45,12 @@ public abstract class BaseDeviceProfileProcessor extends BaseEdgeProcessor {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private DataDecodingEncodingService dataDecodingEncodingService;
|
private DataDecodingEncodingService dataDecodingEncodingService;
|
||||||
|
|
||||||
protected Pair<Boolean, Boolean> saveOrUpdateDeviceProfile(TenantId tenantId, DeviceProfileId deviceProfileId, DeviceProfileUpdateMsg deviceProfileUpdateMsg, boolean isEdgeVersionProtoDeprecated) {
|
protected Pair<Boolean, Boolean> saveOrUpdateDeviceProfile(TenantId tenantId, DeviceProfileId deviceProfileId, DeviceProfileUpdateMsg deviceProfileUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2) {
|
||||||
boolean created = false;
|
boolean created = false;
|
||||||
boolean deviceProfileNameUpdated = false;
|
boolean deviceProfileNameUpdated = false;
|
||||||
deviceCreationLock.lock();
|
deviceCreationLock.lock();
|
||||||
try {
|
try {
|
||||||
DeviceProfile deviceProfile = isEdgeVersionProtoDeprecated
|
DeviceProfile deviceProfile = isEdgeVersionOlderThan_3_6_2
|
||||||
? createDeviceProfile(tenantId, deviceProfileId, deviceProfileUpdateMsg)
|
? createDeviceProfile(tenantId, deviceProfileId, deviceProfileUpdateMsg)
|
||||||
: JacksonUtil.fromStringIgnoreUnknownProperties(deviceProfileUpdateMsg.getEntity(), DeviceProfile.class);
|
: JacksonUtil.fromStringIgnoreUnknownProperties(deviceProfileUpdateMsg.getEntity(), DeviceProfile.class);
|
||||||
if (deviceProfile == null) {
|
if (deviceProfile == null) {
|
||||||
@ -75,8 +75,8 @@ public abstract class BaseDeviceProfileProcessor extends BaseEdgeProcessor {
|
|||||||
|
|
||||||
RuleChainId ruleChainId = deviceProfile.getDefaultRuleChainId();
|
RuleChainId ruleChainId = deviceProfile.getDefaultRuleChainId();
|
||||||
setDefaultRuleChainId(tenantId, deviceProfile, created ? null : deviceProfileById.getDefaultRuleChainId());
|
setDefaultRuleChainId(tenantId, deviceProfile, created ? null : deviceProfileById.getDefaultRuleChainId());
|
||||||
setDefaultEdgeRuleChainId(deviceProfile, ruleChainId, deviceProfileUpdateMsg, isEdgeVersionProtoDeprecated);
|
setDefaultEdgeRuleChainId(deviceProfile, ruleChainId, deviceProfileUpdateMsg, isEdgeVersionOlderThan_3_6_2);
|
||||||
setDefaultDashboardId(tenantId, created ? null : deviceProfileById.getDefaultDashboardId(), deviceProfile, deviceProfileUpdateMsg, isEdgeVersionProtoDeprecated);
|
setDefaultDashboardId(tenantId, created ? null : deviceProfileById.getDefaultDashboardId(), deviceProfile, deviceProfileUpdateMsg, isEdgeVersionOlderThan_3_6_2);
|
||||||
|
|
||||||
deviceProfileValidator.validate(deviceProfile, DeviceProfile::getTenantId);
|
deviceProfileValidator.validate(deviceProfile, DeviceProfile::getTenantId);
|
||||||
if (created) {
|
if (created) {
|
||||||
@ -127,7 +127,7 @@ public abstract class BaseDeviceProfileProcessor extends BaseEdgeProcessor {
|
|||||||
|
|
||||||
protected abstract void setDefaultRuleChainId(TenantId tenantId, DeviceProfile deviceProfile, RuleChainId ruleChainId);
|
protected abstract void setDefaultRuleChainId(TenantId tenantId, DeviceProfile deviceProfile, RuleChainId ruleChainId);
|
||||||
|
|
||||||
protected abstract void setDefaultEdgeRuleChainId(DeviceProfile deviceProfile, RuleChainId ruleChainId, DeviceProfileUpdateMsg deviceProfileUpdateMsg, boolean isEdgeVersionDeprecated);
|
protected abstract void setDefaultEdgeRuleChainId(DeviceProfile deviceProfile, RuleChainId ruleChainId, DeviceProfileUpdateMsg deviceProfileUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2);
|
||||||
|
|
||||||
protected abstract void setDefaultDashboardId(TenantId tenantId, DashboardId dashboardId, DeviceProfile deviceProfile, DeviceProfileUpdateMsg deviceProfileUpdateMsg, boolean isEdgeVersionDeprecated);
|
protected abstract void setDefaultDashboardId(TenantId tenantId, DashboardId dashboardId, DeviceProfile deviceProfile, DeviceProfileUpdateMsg deviceProfileUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -289,8 +289,8 @@ public class DeviceEdgeProcessor extends BaseDeviceProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setCustomerId(TenantId tenantId, CustomerId customerId, Device device, DeviceUpdateMsg deviceUpdateMsg, boolean isEdgeVersionDeprecated) {
|
protected void setCustomerId(TenantId tenantId, CustomerId customerId, Device device, DeviceUpdateMsg deviceUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2) {
|
||||||
CustomerId customerUUID = isEdgeVersionDeprecated
|
CustomerId customerUUID = isEdgeVersionOlderThan_3_6_2
|
||||||
? safeGetCustomerId(deviceUpdateMsg.getCustomerIdMSB(), deviceUpdateMsg.getCustomerIdLSB())
|
? safeGetCustomerId(deviceUpdateMsg.getCustomerIdMSB(), deviceUpdateMsg.getCustomerIdLSB())
|
||||||
: device.getCustomerId() != null ? device.getCustomerId() : customerId;
|
: device.getCustomerId() != null ? device.getCustomerId() : customerId;
|
||||||
device.setCustomerId(customerUUID);
|
device.setCustomerId(customerUUID);
|
||||||
|
|||||||
@ -134,16 +134,16 @@ public class DeviceProfileEdgeProcessor extends BaseDeviceProfileProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setDefaultEdgeRuleChainId(DeviceProfile deviceProfile, RuleChainId ruleChainId, DeviceProfileUpdateMsg deviceProfileUpdateMsg, boolean isEdgeVersionDeprecated) {
|
protected void setDefaultEdgeRuleChainId(DeviceProfile deviceProfile, RuleChainId ruleChainId, DeviceProfileUpdateMsg deviceProfileUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2) {
|
||||||
UUID defaultEdgeRuleChainUUID = isEdgeVersionDeprecated
|
UUID defaultEdgeRuleChainUUID = isEdgeVersionOlderThan_3_6_2
|
||||||
? safeGetUUID(deviceProfileUpdateMsg.getDefaultRuleChainIdMSB(), deviceProfileUpdateMsg.getDefaultRuleChainIdLSB())
|
? safeGetUUID(deviceProfileUpdateMsg.getDefaultRuleChainIdMSB(), deviceProfileUpdateMsg.getDefaultRuleChainIdLSB())
|
||||||
: ruleChainId != null ? ruleChainId.getId() : null;
|
: ruleChainId != null ? ruleChainId.getId() : null;
|
||||||
deviceProfile.setDefaultEdgeRuleChainId(defaultEdgeRuleChainUUID != null ? new RuleChainId(defaultEdgeRuleChainUUID) : null);
|
deviceProfile.setDefaultEdgeRuleChainId(defaultEdgeRuleChainUUID != null ? new RuleChainId(defaultEdgeRuleChainUUID) : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setDefaultDashboardId(TenantId tenantId, DashboardId dashboardId, DeviceProfile deviceProfile, DeviceProfileUpdateMsg deviceProfileUpdateMsg, boolean isEdgeVersionDeprecated) {
|
protected void setDefaultDashboardId(TenantId tenantId, DashboardId dashboardId, DeviceProfile deviceProfile, DeviceProfileUpdateMsg deviceProfileUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2) {
|
||||||
UUID defaultDashboardUUID = isEdgeVersionDeprecated
|
UUID defaultDashboardUUID = isEdgeVersionOlderThan_3_6_2
|
||||||
? safeGetUUID(deviceProfileUpdateMsg.getDefaultDashboardIdMSB(), deviceProfileUpdateMsg.getDefaultDashboardIdLSB())
|
? safeGetUUID(deviceProfileUpdateMsg.getDefaultDashboardIdMSB(), deviceProfileUpdateMsg.getDefaultDashboardIdLSB())
|
||||||
: deviceProfile.getDefaultDashboardId() != null ? deviceProfile.getDefaultDashboardId().getId() : (dashboardId != null ? dashboardId.getId() : null);
|
: deviceProfile.getDefaultDashboardId() != null ? deviceProfile.getDefaultDashboardId().getId() : (dashboardId != null ? dashboardId.getId() : null);
|
||||||
deviceProfile.setDefaultDashboardId(defaultDashboardUUID != null ? new DashboardId(defaultDashboardUUID) : null);
|
deviceProfile.setDefaultDashboardId(defaultDashboardUUID != null ? new DashboardId(defaultDashboardUUID) : null);
|
||||||
|
|||||||
@ -92,5 +92,5 @@ public abstract class BaseEntityViewProcessor extends BaseEdgeProcessor {
|
|||||||
return entityView;
|
return entityView;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void setCustomerId(TenantId tenantId, CustomerId customerId, EntityView entityView, EntityViewUpdateMsg entityViewUpdateMsg, boolean isEdgeVersionDeprecated);
|
protected abstract void setCustomerId(TenantId tenantId, CustomerId customerId, EntityView entityView, EntityViewUpdateMsg entityViewUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,8 +140,8 @@ public class EntityViewEdgeProcessor extends BaseEntityViewProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setCustomerId(TenantId tenantId, CustomerId customerId, EntityView entityView, EntityViewUpdateMsg entityViewUpdateMsg, boolean isEdgeVersionDeprecated) {
|
protected void setCustomerId(TenantId tenantId, CustomerId customerId, EntityView entityView, EntityViewUpdateMsg entityViewUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2) {
|
||||||
CustomerId customerUUID = isEdgeVersionDeprecated
|
CustomerId customerUUID = isEdgeVersionOlderThan_3_6_2
|
||||||
? safeGetCustomerId(entityViewUpdateMsg.getCustomerIdMSB(), entityViewUpdateMsg.getCustomerIdLSB())
|
? safeGetCustomerId(entityViewUpdateMsg.getCustomerIdMSB(), entityViewUpdateMsg.getCustomerIdLSB())
|
||||||
: entityView.getCustomerId() != null ? entityView.getCustomerId() : customerId;
|
: entityView.getCustomerId() != null ? entityView.getCustomerId() : customerId;
|
||||||
entityView.setCustomerId(customerUUID);
|
entityView.setCustomerId(customerUUID);
|
||||||
|
|||||||
@ -61,5 +61,4 @@ public class QueueEdgeProcessor extends BaseEdgeProcessor {
|
|||||||
}
|
}
|
||||||
return downlinkMsg;
|
return downlinkMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,20 +25,18 @@ import org.thingsboard.server.common.data.id.EntityIdFactory;
|
|||||||
import org.thingsboard.server.common.data.id.TenantId;
|
import org.thingsboard.server.common.data.id.TenantId;
|
||||||
import org.thingsboard.server.common.data.relation.EntityRelation;
|
import org.thingsboard.server.common.data.relation.EntityRelation;
|
||||||
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
|
import org.thingsboard.server.common.data.relation.RelationTypeGroup;
|
||||||
import org.thingsboard.server.gen.edge.v1.EdgeVersion;
|
|
||||||
import org.thingsboard.server.gen.edge.v1.RelationUpdateMsg;
|
import org.thingsboard.server.gen.edge.v1.RelationUpdateMsg;
|
||||||
import org.thingsboard.server.service.edge.rpc.processor.BaseEdgeProcessor;
|
import org.thingsboard.server.service.edge.rpc.processor.BaseEdgeProcessor;
|
||||||
import org.thingsboard.server.service.edge.rpc.utils.EdgeVersionUtils;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class BaseRelationProcessor extends BaseEdgeProcessor {
|
public abstract class BaseRelationProcessor extends BaseEdgeProcessor {
|
||||||
|
|
||||||
protected ListenableFuture<Void> processRelationMsg(TenantId tenantId, RelationUpdateMsg relationUpdateMsg, EdgeVersion edgeVersion) {
|
protected ListenableFuture<Void> processRelationMsg(TenantId tenantId, RelationUpdateMsg relationUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2) {
|
||||||
log.trace("[{}] processRelationMsg [{}]", tenantId, relationUpdateMsg);
|
log.trace("[{}] processRelationMsg [{}]", tenantId, relationUpdateMsg);
|
||||||
try {
|
try {
|
||||||
EntityRelation entityRelation = EdgeVersionUtils.isEdgeVersionOlderThan_3_6_2(edgeVersion)
|
EntityRelation entityRelation = isEdgeVersionOlderThan_3_6_2
|
||||||
? createEntityRelation(relationUpdateMsg)
|
? createEntityRelation(relationUpdateMsg)
|
||||||
: JacksonUtil.fromStringIgnoreUnknownProperties(relationUpdateMsg.getEntity(), EntityRelation.class);
|
: JacksonUtil.fromStringIgnoreUnknownProperties(relationUpdateMsg.getEntity(), EntityRelation.class);
|
||||||
if (entityRelation == null) {
|
if (entityRelation == null) {
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import org.thingsboard.server.gen.edge.v1.RelationUpdateMsg;
|
|||||||
import org.thingsboard.server.gen.edge.v1.UpdateMsgType;
|
import org.thingsboard.server.gen.edge.v1.UpdateMsgType;
|
||||||
import org.thingsboard.server.gen.transport.TransportProtos;
|
import org.thingsboard.server.gen.transport.TransportProtos;
|
||||||
import org.thingsboard.server.queue.util.TbCoreComponent;
|
import org.thingsboard.server.queue.util.TbCoreComponent;
|
||||||
|
import org.thingsboard.server.service.edge.rpc.utils.EdgeVersionUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -50,8 +51,7 @@ public class RelationEdgeProcessor extends BaseRelationProcessor {
|
|||||||
log.trace("[{}] executing processRelationMsgFromEdge [{}] from edge [{}]", tenantId, relationUpdateMsg, edge.getId());
|
log.trace("[{}] executing processRelationMsgFromEdge [{}] from edge [{}]", tenantId, relationUpdateMsg, edge.getId());
|
||||||
try {
|
try {
|
||||||
edgeSynchronizationManager.getEdgeId().set(edge.getId());
|
edgeSynchronizationManager.getEdgeId().set(edge.getId());
|
||||||
|
return processRelationMsg(tenantId, relationUpdateMsg, EdgeVersionUtils.isEdgeVersionOlderThan_3_6_2(edgeVersion));
|
||||||
return processRelationMsg(tenantId, relationUpdateMsg, edgeVersion);
|
|
||||||
} finally {
|
} finally {
|
||||||
edgeSynchronizationManager.getEdgeId().remove();
|
edgeSynchronizationManager.getEdgeId().remove();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,10 +31,10 @@ import org.thingsboard.server.service.edge.rpc.processor.BaseEdgeProcessor;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class BaseResourceProcessor extends BaseEdgeProcessor {
|
public abstract class BaseResourceProcessor extends BaseEdgeProcessor {
|
||||||
|
|
||||||
protected boolean saveOrUpdateTbResource(TenantId tenantId, TbResourceId tbResourceId, ResourceUpdateMsg resourceUpdateMsg, boolean isEdgeDeprecated) {
|
protected boolean saveOrUpdateTbResource(TenantId tenantId, TbResourceId tbResourceId, ResourceUpdateMsg resourceUpdateMsg, boolean isEdgeVersionOlderThan_3_6_2) {
|
||||||
boolean resourceKeyUpdated = false;
|
boolean resourceKeyUpdated = false;
|
||||||
try {
|
try {
|
||||||
TbResource resource = isEdgeDeprecated
|
TbResource resource = isEdgeVersionOlderThan_3_6_2
|
||||||
? createTbResource(tenantId, resourceUpdateMsg)
|
? createTbResource(tenantId, resourceUpdateMsg)
|
||||||
: JacksonUtil.fromStringIgnoreUnknownProperties(resourceUpdateMsg.getEntity(), TbResource.class);
|
: JacksonUtil.fromStringIgnoreUnknownProperties(resourceUpdateMsg.getEntity(), TbResource.class);
|
||||||
if (resource == null) {
|
if (resource == null) {
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.thingsboard.server.service.edge.rpc.processor.telemetry;
|
package org.thingsboard.server.service.edge.rpc.processor.telemetry;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.google.common.util.concurrent.FutureCallback;
|
import com.google.common.util.concurrent.FutureCallback;
|
||||||
import com.google.common.util.concurrent.Futures;
|
import com.google.common.util.concurrent.Futures;
|
||||||
@ -28,7 +27,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.thingsboard.common.util.JacksonUtil;
|
import org.thingsboard.common.util.JacksonUtil;
|
||||||
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
|
|
||||||
import org.thingsboard.server.common.data.DataConstants;
|
import org.thingsboard.server.common.data.DataConstants;
|
||||||
import org.thingsboard.server.common.data.Device;
|
import org.thingsboard.server.common.data.Device;
|
||||||
import org.thingsboard.server.common.data.DeviceProfile;
|
import org.thingsboard.server.common.data.DeviceProfile;
|
||||||
@ -54,6 +52,7 @@ import org.thingsboard.server.common.msg.TbMsg;
|
|||||||
import org.thingsboard.server.common.msg.TbMsgMetaData;
|
import org.thingsboard.server.common.msg.TbMsgMetaData;
|
||||||
import org.thingsboard.server.common.msg.queue.ServiceType;
|
import org.thingsboard.server.common.msg.queue.ServiceType;
|
||||||
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
|
import org.thingsboard.server.common.msg.queue.TopicPartitionInfo;
|
||||||
|
import org.thingsboard.server.common.msg.rule.engine.DeviceAttributesEventNotificationMsg;
|
||||||
import org.thingsboard.server.common.transport.adaptor.JsonConverter;
|
import org.thingsboard.server.common.transport.adaptor.JsonConverter;
|
||||||
import org.thingsboard.server.common.transport.util.JsonUtils;
|
import org.thingsboard.server.common.transport.util.JsonUtils;
|
||||||
import org.thingsboard.server.dao.model.ModelConstants;
|
import org.thingsboard.server.dao.model.ModelConstants;
|
||||||
@ -349,5 +348,4 @@ public abstract class BaseTelemetryProcessor extends BaseEdgeProcessor {
|
|||||||
return bodyJackson == null ? null :
|
return bodyJackson == null ? null :
|
||||||
entityDataMsgConstructor.constructEntityDataMsg(tenantId, entityId, actionType, JsonParser.parseString(bodyJackson));
|
entityDataMsgConstructor.constructEntityDataMsg(tenantId, entityId, actionType, JsonParser.parseString(bodyJackson));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,5 +69,4 @@ public class UserEdgeProcessor extends BaseEdgeProcessor {
|
|||||||
}
|
}
|
||||||
return downlinkMsg;
|
return downlinkMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user