Fix ComponentLifecycleMsg: message and builder
This commit is contained in:
parent
85f2fcd4d5
commit
44a7bf82c4
@ -26,6 +26,7 @@ import org.thingsboard.server.common.msg.MsgType;
|
|||||||
import org.thingsboard.server.common.msg.aware.TenantAwareMsg;
|
import org.thingsboard.server.common.msg.aware.TenantAwareMsg;
|
||||||
import org.thingsboard.server.common.msg.cluster.ToAllNodesMsg;
|
import org.thingsboard.server.common.msg.cluster.ToAllNodesMsg;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +34,8 @@ import java.util.Optional;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class ComponentLifecycleMsg implements TenantAwareMsg, ToAllNodesMsg {
|
public class ComponentLifecycleMsg implements TenantAwareMsg, ToAllNodesMsg {
|
||||||
|
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -5303421482781273062L;
|
private static final long serialVersionUID = -5303421482781273062L;
|
||||||
|
|
||||||
private final TenantId tenantId;
|
private final TenantId tenantId;
|
||||||
@ -66,4 +69,5 @@ public class ComponentLifecycleMsg implements TenantAwareMsg, ToAllNodesMsg {
|
|||||||
public MsgType getMsgType() {
|
public MsgType getMsgType() {
|
||||||
return MsgType.COMPONENT_LIFE_CYCLE_MSG;
|
return MsgType.COMPONENT_LIFE_CYCLE_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,7 +134,7 @@ public class ProtoUtils {
|
|||||||
builder.setName(msg.getName());
|
builder.setName(msg.getName());
|
||||||
}
|
}
|
||||||
if (msg.getOldName() != null) {
|
if (msg.getOldName() != null) {
|
||||||
builder.setName(msg.getOldName());
|
builder.setOldName(msg.getOldName());
|
||||||
}
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
@ -149,8 +149,8 @@ public class ProtoUtils {
|
|||||||
.tenantId(TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())))
|
.tenantId(TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())))
|
||||||
.entityId(entityId)
|
.entityId(entityId)
|
||||||
.event(ComponentLifecycleEvent.values()[proto.getEventValue()])
|
.event(ComponentLifecycleEvent.values()[proto.getEventValue()])
|
||||||
.name(proto.getName())
|
.name(proto.hasName() ? proto.getName() : null)
|
||||||
.oldName(proto.getOldName());
|
.oldName(proto.hasOldName() ? proto.getOldName() : null);
|
||||||
if (proto.getProfileIdMSB() != 0 || proto.getProfileIdLSB() != 0) {
|
if (proto.getProfileIdMSB() != 0 || proto.getProfileIdLSB() != 0) {
|
||||||
var profileType = EntityType.DEVICE.equals(entityId.getEntityType()) ? EntityType.DEVICE_PROFILE : EntityType.ASSET_PROFILE;
|
var profileType = EntityType.DEVICE.equals(entityId.getEntityType()) ? EntityType.DEVICE_PROFILE : EntityType.ASSET_PROFILE;
|
||||||
builder.profileId(EntityIdFactory.getByTypeAndUuid(profileType, new UUID(proto.getProfileIdMSB(), proto.getProfileIdLSB())));
|
builder.profileId(EntityIdFactory.getByTypeAndUuid(profileType, new UUID(proto.getProfileIdMSB(), proto.getProfileIdLSB())));
|
||||||
@ -166,7 +166,6 @@ public class ProtoUtils {
|
|||||||
return entityTypeByProtoNumber[entityType.getNumber()];
|
return entityTypeByProtoNumber[entityType.getNumber()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static TransportProtos.ToEdgeSyncRequestMsgProto toProto(ToEdgeSyncRequest request) {
|
public static TransportProtos.ToEdgeSyncRequestMsgProto toProto(ToEdgeSyncRequest request) {
|
||||||
return TransportProtos.ToEdgeSyncRequestMsgProto.newBuilder()
|
return TransportProtos.ToEdgeSyncRequestMsgProto.newBuilder()
|
||||||
.setTenantIdMSB(request.getTenantId().getId().getMostSignificantBits())
|
.setTenantIdMSB(request.getTenantId().getId().getMostSignificantBits())
|
||||||
|
|||||||
@ -1188,8 +1188,8 @@ message ComponentLifecycleMsgProto {
|
|||||||
int64 entityIdLSB = 5;
|
int64 entityIdLSB = 5;
|
||||||
ComponentLifecycleEvent event = 6;
|
ComponentLifecycleEvent event = 6;
|
||||||
//Since 4.0. To replace the
|
//Since 4.0. To replace the
|
||||||
string oldName = 7;
|
optional string oldName = 7;
|
||||||
string name = 8;
|
optional string name = 8;
|
||||||
int64 oldProfileIdMSB = 9;
|
int64 oldProfileIdMSB = 9;
|
||||||
int64 oldProfileIdLSB = 10;
|
int64 oldProfileIdLSB = 10;
|
||||||
int64 profileIdMSB = 11;
|
int64 profileIdMSB = 11;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user