Search in sources :

Example 1 with EdgeEntityType

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();
}
Also used : EntityViewUpdateMsg(org.thingsboard.server.gen.edge.v1.EntityViewUpdateMsg) EdgeEntityType(org.thingsboard.server.gen.edge.v1.EdgeEntityType)

Aggregations

EdgeEntityType (org.thingsboard.server.gen.edge.v1.EdgeEntityType)1 EntityViewUpdateMsg (org.thingsboard.server.gen.edge.v1.EntityViewUpdateMsg)1