use of org.thingsboard.server.gen.edge.v1.EdgeEntityType in project thingsboard by thingsboard.
the class EntityViewMsgConstructor method constructEntityViewUpdatedMsg.
public EntityViewUpdateMsg constructEntityViewUpdatedMsg(UpdateMsgType msgType, EntityView entityView, CustomerId customerId) {
EdgeEntityType entityType;
switch(entityView.getEntityId().getEntityType()) {
case DEVICE:
entityType = EdgeEntityType.DEVICE;
break;
case ASSET:
entityType = EdgeEntityType.ASSET;
break;
default:
throw new RuntimeException("Unsupported entity type [" + entityView.getEntityId().getEntityType() + "]");
}
EntityViewUpdateMsg.Builder builder = EntityViewUpdateMsg.newBuilder().setMsgType(msgType).setIdMSB(entityView.getId().getId().getMostSignificantBits()).setIdLSB(entityView.getId().getId().getLeastSignificantBits()).setName(entityView.getName()).setType(entityView.getType()).setEntityIdMSB(entityView.getEntityId().getId().getMostSignificantBits()).setEntityIdLSB(entityView.getEntityId().getId().getLeastSignificantBits()).setEntityType(entityType);
if (customerId != null) {
builder.setCustomerIdMSB(customerId.getId().getMostSignificantBits());
builder.setCustomerIdLSB(customerId.getId().getLeastSignificantBits());
}
if (entityView.getAdditionalInfo() != null) {
builder.setAdditionalInfo(JacksonUtil.toString(entityView.getAdditionalInfo()));
}
return builder.build();
}
Aggregations