|
|
@ -41,6 +41,7 @@ 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; |
|
|
import org.thingsboard.server.common.data.EntityView; |
|
|
import org.thingsboard.server.common.data.EntityView; |
|
|
|
|
|
import org.thingsboard.server.common.data.HasVersion; |
|
|
import org.thingsboard.server.common.data.OtaPackage; |
|
|
import org.thingsboard.server.common.data.OtaPackage; |
|
|
import org.thingsboard.server.common.data.StringUtils; |
|
|
import org.thingsboard.server.common.data.StringUtils; |
|
|
import org.thingsboard.server.common.data.TbResource; |
|
|
import org.thingsboard.server.common.data.TbResource; |
|
|
@ -193,6 +194,10 @@ public class EdgeMsgConstructorUtils { |
|
|
) |
|
|
) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
private static void resetVersion(HasVersion entity) { |
|
|
|
|
|
entity.setVersion(null); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public static AlarmUpdateMsg constructAlarmUpdatedMsg(UpdateMsgType msgType, Alarm alarm) { |
|
|
public static AlarmUpdateMsg constructAlarmUpdatedMsg(UpdateMsgType msgType, Alarm alarm) { |
|
|
return AlarmUpdateMsg.newBuilder().setMsgType(msgType) |
|
|
return AlarmUpdateMsg.newBuilder().setMsgType(msgType) |
|
|
.setEntity(JacksonUtil.toString(alarm)) |
|
|
.setEntity(JacksonUtil.toString(alarm)) |
|
|
@ -205,6 +210,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static AssetUpdateMsg constructAssetUpdatedMsg(UpdateMsgType msgType, Asset asset) { |
|
|
public static AssetUpdateMsg constructAssetUpdatedMsg(UpdateMsgType msgType, Asset asset) { |
|
|
|
|
|
resetVersion(asset); |
|
|
return AssetUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(asset)) |
|
|
return AssetUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(asset)) |
|
|
.setIdMSB(asset.getUuidId().getMostSignificantBits()) |
|
|
.setIdMSB(asset.getUuidId().getMostSignificantBits()) |
|
|
.setIdLSB(asset.getUuidId().getLeastSignificantBits()).build(); |
|
|
.setIdLSB(asset.getUuidId().getLeastSignificantBits()).build(); |
|
|
@ -218,6 +224,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static AssetProfileUpdateMsg constructAssetProfileUpdatedMsg(UpdateMsgType msgType, AssetProfile assetProfile) { |
|
|
public static AssetProfileUpdateMsg constructAssetProfileUpdatedMsg(UpdateMsgType msgType, AssetProfile assetProfile) { |
|
|
|
|
|
resetVersion(assetProfile); |
|
|
return AssetProfileUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(assetProfile)) |
|
|
return AssetProfileUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(assetProfile)) |
|
|
.setIdMSB(assetProfile.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(assetProfile.getId().getId().getMostSignificantBits()) |
|
|
.setIdLSB(assetProfile.getId().getId().getLeastSignificantBits()).build(); |
|
|
.setIdLSB(assetProfile.getId().getId().getLeastSignificantBits()).build(); |
|
|
@ -231,6 +238,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static CustomerUpdateMsg constructCustomerUpdatedMsg(UpdateMsgType msgType, Customer customer) { |
|
|
public static CustomerUpdateMsg constructCustomerUpdatedMsg(UpdateMsgType msgType, Customer customer) { |
|
|
|
|
|
resetVersion(customer); |
|
|
return CustomerUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(customer)) |
|
|
return CustomerUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(customer)) |
|
|
.setIdMSB(customer.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(customer.getId().getId().getMostSignificantBits()) |
|
|
.setIdLSB(customer.getId().getId().getLeastSignificantBits()).build(); |
|
|
.setIdLSB(customer.getId().getId().getLeastSignificantBits()).build(); |
|
|
@ -244,6 +252,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static DashboardUpdateMsg constructDashboardUpdatedMsg(UpdateMsgType msgType, Dashboard dashboard) { |
|
|
public static DashboardUpdateMsg constructDashboardUpdatedMsg(UpdateMsgType msgType, Dashboard dashboard) { |
|
|
|
|
|
resetVersion(dashboard); |
|
|
return DashboardUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(dashboard)) |
|
|
return DashboardUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(dashboard)) |
|
|
.setIdMSB(dashboard.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(dashboard.getId().getId().getMostSignificantBits()) |
|
|
.setIdLSB(dashboard.getId().getId().getLeastSignificantBits()).build(); |
|
|
.setIdLSB(dashboard.getId().getId().getLeastSignificantBits()).build(); |
|
|
@ -257,6 +266,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static DeviceUpdateMsg constructDeviceUpdatedMsg(UpdateMsgType msgType, Device device) { |
|
|
public static DeviceUpdateMsg constructDeviceUpdatedMsg(UpdateMsgType msgType, Device device) { |
|
|
|
|
|
resetVersion(device); |
|
|
return DeviceUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(device)) |
|
|
return DeviceUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(device)) |
|
|
.setIdMSB(device.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(device.getId().getId().getMostSignificantBits()) |
|
|
.setIdLSB(device.getId().getId().getLeastSignificantBits()).build(); |
|
|
.setIdLSB(device.getId().getId().getLeastSignificantBits()).build(); |
|
|
@ -270,10 +280,12 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static DeviceCredentialsUpdateMsg constructDeviceCredentialsUpdatedMsg(DeviceCredentials deviceCredentials) { |
|
|
public static DeviceCredentialsUpdateMsg constructDeviceCredentialsUpdatedMsg(DeviceCredentials deviceCredentials) { |
|
|
|
|
|
resetVersion(deviceCredentials); |
|
|
return DeviceCredentialsUpdateMsg.newBuilder().setEntity(JacksonUtil.toString(deviceCredentials)).build(); |
|
|
return DeviceCredentialsUpdateMsg.newBuilder().setEntity(JacksonUtil.toString(deviceCredentials)).build(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static DeviceProfileUpdateMsg constructDeviceProfileUpdatedMsg(UpdateMsgType msgType, DeviceProfile deviceProfile, EdgeVersion edgeVersion) { |
|
|
public static DeviceProfileUpdateMsg constructDeviceProfileUpdatedMsg(UpdateMsgType msgType, DeviceProfile deviceProfile, EdgeVersion edgeVersion) { |
|
|
|
|
|
resetVersion(deviceProfile); |
|
|
String entity = getEntityAndFixLwm2mBootstrapShortServerId(deviceProfile, edgeVersion); |
|
|
String entity = getEntityAndFixLwm2mBootstrapShortServerId(deviceProfile, edgeVersion); |
|
|
return DeviceProfileUpdateMsg.newBuilder().setMsgType(msgType).setEntity(entity) |
|
|
return DeviceProfileUpdateMsg.newBuilder().setMsgType(msgType).setEntity(entity) |
|
|
.setIdMSB(deviceProfile.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(deviceProfile.getId().getId().getMostSignificantBits()) |
|
|
@ -387,6 +399,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static EntityViewUpdateMsg constructEntityViewUpdatedMsg(UpdateMsgType msgType, EntityView entityView) { |
|
|
public static EntityViewUpdateMsg constructEntityViewUpdatedMsg(UpdateMsgType msgType, EntityView entityView) { |
|
|
|
|
|
resetVersion(entityView); |
|
|
return EntityViewUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(entityView)) |
|
|
return EntityViewUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(entityView)) |
|
|
.setIdMSB(entityView.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(entityView.getId().getId().getMostSignificantBits()) |
|
|
.setIdLSB(entityView.getId().getId().getLeastSignificantBits()).build(); |
|
|
.setIdLSB(entityView.getId().getId().getLeastSignificantBits()).build(); |
|
|
@ -486,6 +499,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static RelationUpdateMsg constructRelationUpdatedMsg(UpdateMsgType msgType, EntityRelation entityRelation) { |
|
|
public static RelationUpdateMsg constructRelationUpdatedMsg(UpdateMsgType msgType, EntityRelation entityRelation) { |
|
|
|
|
|
resetVersion(entityRelation); |
|
|
return RelationUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(entityRelation)).build(); |
|
|
return RelationUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(entityRelation)).build(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -503,6 +517,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static RuleChainUpdateMsg constructRuleChainUpdatedMsg(UpdateMsgType msgType, RuleChain ruleChain, boolean isRoot) { |
|
|
public static RuleChainUpdateMsg constructRuleChainUpdatedMsg(UpdateMsgType msgType, RuleChain ruleChain, boolean isRoot) { |
|
|
|
|
|
resetVersion(ruleChain); |
|
|
boolean isTemplateRoot = ruleChain.isRoot(); |
|
|
boolean isTemplateRoot = ruleChain.isRoot(); |
|
|
ruleChain.setRoot(isRoot); |
|
|
ruleChain.setRoot(isRoot); |
|
|
RuleChainUpdateMsg result = RuleChainUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(ruleChain)) |
|
|
RuleChainUpdateMsg result = RuleChainUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(ruleChain)) |
|
|
@ -520,6 +535,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static RuleChainMetadataUpdateMsg constructRuleChainMetadataUpdatedMsg(UpdateMsgType msgType, RuleChainMetaData ruleChainMetaData, EdgeVersion edgeVersion) { |
|
|
public static RuleChainMetadataUpdateMsg constructRuleChainMetadataUpdatedMsg(UpdateMsgType msgType, RuleChainMetaData ruleChainMetaData, EdgeVersion edgeVersion) { |
|
|
|
|
|
resetVersion(ruleChainMetaData); |
|
|
String metaData = sanitizeMetadataForLegacyEdgeVersion(ruleChainMetaData, edgeVersion); |
|
|
String metaData = sanitizeMetadataForLegacyEdgeVersion(ruleChainMetaData, edgeVersion); |
|
|
|
|
|
|
|
|
return RuleChainMetadataUpdateMsg.newBuilder() |
|
|
return RuleChainMetadataUpdateMsg.newBuilder() |
|
|
@ -640,6 +656,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static TenantUpdateMsg constructTenantUpdateMsg(UpdateMsgType msgType, Tenant tenant) { |
|
|
public static TenantUpdateMsg constructTenantUpdateMsg(UpdateMsgType msgType, Tenant tenant) { |
|
|
|
|
|
resetVersion(tenant); |
|
|
return TenantUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(tenant)).build(); |
|
|
return TenantUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(tenant)).build(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -648,6 +665,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static UserUpdateMsg constructUserUpdatedMsg(UpdateMsgType msgType, User user) { |
|
|
public static UserUpdateMsg constructUserUpdatedMsg(UpdateMsgType msgType, User user) { |
|
|
|
|
|
resetVersion(user); |
|
|
return UserUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(user)) |
|
|
return UserUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(user)) |
|
|
.setIdMSB(user.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(user.getId().getId().getMostSignificantBits()) |
|
|
.setIdLSB(user.getId().getId().getLeastSignificantBits()).build(); |
|
|
.setIdLSB(user.getId().getId().getLeastSignificantBits()).build(); |
|
|
@ -665,6 +683,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static WidgetsBundleUpdateMsg constructWidgetsBundleUpdateMsg(UpdateMsgType msgType, WidgetsBundle widgetsBundle, List<String> widgets) { |
|
|
public static WidgetsBundleUpdateMsg constructWidgetsBundleUpdateMsg(UpdateMsgType msgType, WidgetsBundle widgetsBundle, List<String> widgets) { |
|
|
|
|
|
resetVersion(widgetsBundle); |
|
|
return WidgetsBundleUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(widgetsBundle)) |
|
|
return WidgetsBundleUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(widgetsBundle)) |
|
|
.setWidgets(JacksonUtil.toString(widgets)) |
|
|
.setWidgets(JacksonUtil.toString(widgets)) |
|
|
.setIdMSB(widgetsBundle.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(widgetsBundle.getId().getId().getMostSignificantBits()) |
|
|
@ -680,6 +699,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static WidgetTypeUpdateMsg constructWidgetTypeUpdateMsg(UpdateMsgType msgType, WidgetTypeDetails widgetTypeDetails) { |
|
|
public static WidgetTypeUpdateMsg constructWidgetTypeUpdateMsg(UpdateMsgType msgType, WidgetTypeDetails widgetTypeDetails) { |
|
|
|
|
|
resetVersion(widgetTypeDetails); |
|
|
return WidgetTypeUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(widgetTypeDetails)) |
|
|
return WidgetTypeUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(widgetTypeDetails)) |
|
|
.setIdMSB(widgetTypeDetails.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(widgetTypeDetails.getId().getId().getMostSignificantBits()) |
|
|
.setIdLSB(widgetTypeDetails.getId().getId().getLeastSignificantBits()).build(); |
|
|
.setIdLSB(widgetTypeDetails.getId().getId().getLeastSignificantBits()).build(); |
|
|
@ -694,6 +714,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static CalculatedFieldUpdateMsg constructCalculatedFieldUpdatedMsg(UpdateMsgType msgType, CalculatedField calculatedField) { |
|
|
public static CalculatedFieldUpdateMsg constructCalculatedFieldUpdatedMsg(UpdateMsgType msgType, CalculatedField calculatedField) { |
|
|
|
|
|
resetVersion(calculatedField); |
|
|
return CalculatedFieldUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(calculatedField)) |
|
|
return CalculatedFieldUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(calculatedField)) |
|
|
.setIdMSB(calculatedField.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(calculatedField.getId().getId().getMostSignificantBits()) |
|
|
.setIdLSB(calculatedField.getId().getId().getLeastSignificantBits()).build(); |
|
|
.setIdLSB(calculatedField.getId().getId().getLeastSignificantBits()).build(); |
|
|
@ -707,6 +728,7 @@ public class EdgeMsgConstructorUtils { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static AiModelUpdateMsg constructAiModelUpdatedMsg(UpdateMsgType msgType, AiModel aiModel) { |
|
|
public static AiModelUpdateMsg constructAiModelUpdatedMsg(UpdateMsgType msgType, AiModel aiModel) { |
|
|
|
|
|
resetVersion(aiModel); |
|
|
return AiModelUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(aiModel)) |
|
|
return AiModelUpdateMsg.newBuilder().setMsgType(msgType).setEntity(JacksonUtil.toString(aiModel)) |
|
|
.setIdMSB(aiModel.getId().getId().getMostSignificantBits()) |
|
|
.setIdMSB(aiModel.getId().getId().getMostSignificantBits()) |
|
|
.setIdLSB(aiModel.getId().getId().getLeastSignificantBits()).build(); |
|
|
.setIdLSB(aiModel.getId().getId().getLeastSignificantBits()).build(); |
|
|
|