Search in sources :

Example 1 with TbAlarmUpdateProto

use of org.thingsboard.server.gen.transport.TransportProtos.TbAlarmUpdateProto in project thingsboard by thingsboard.

the class DefaultTbCoreConsumerService method forwardToSubMgrService.

private void forwardToSubMgrService(SubscriptionMgrMsgProto msg, TbCallback callback) {
    if (msg.hasAttributeSub()) {
        subscriptionManagerService.addSubscription(TbSubscriptionUtils.fromProto(msg.getAttributeSub()), callback);
    } else if (msg.hasTelemetrySub()) {
        subscriptionManagerService.addSubscription(TbSubscriptionUtils.fromProto(msg.getTelemetrySub()), callback);
    } else if (msg.hasAlarmSub()) {
        subscriptionManagerService.addSubscription(TbSubscriptionUtils.fromProto(msg.getAlarmSub()), callback);
    } else if (msg.hasSubClose()) {
        TbSubscriptionCloseProto closeProto = msg.getSubClose();
        subscriptionManagerService.cancelSubscription(closeProto.getSessionId(), closeProto.getSubscriptionId(), callback);
    } else if (msg.hasTsUpdate()) {
        TbTimeSeriesUpdateProto proto = msg.getTsUpdate();
        subscriptionManagerService.onTimeSeriesUpdate(TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())), TbSubscriptionUtils.toEntityId(proto.getEntityType(), proto.getEntityIdMSB(), proto.getEntityIdLSB()), TbSubscriptionUtils.toTsKvEntityList(proto.getDataList()), callback);
    } else if (msg.hasAttrUpdate()) {
        TbAttributeUpdateProto proto = msg.getAttrUpdate();
        subscriptionManagerService.onAttributesUpdate(TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())), TbSubscriptionUtils.toEntityId(proto.getEntityType(), proto.getEntityIdMSB(), proto.getEntityIdLSB()), proto.getScope(), TbSubscriptionUtils.toAttributeKvList(proto.getDataList()), callback);
    } else if (msg.hasAttrDelete()) {
        TbAttributeDeleteProto proto = msg.getAttrDelete();
        subscriptionManagerService.onAttributesDelete(TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())), TbSubscriptionUtils.toEntityId(proto.getEntityType(), proto.getEntityIdMSB(), proto.getEntityIdLSB()), proto.getScope(), proto.getKeysList(), callback);
    } else if (msg.hasTsDelete()) {
        TbTimeSeriesDeleteProto proto = msg.getTsDelete();
        subscriptionManagerService.onTimeSeriesDelete(TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())), TbSubscriptionUtils.toEntityId(proto.getEntityType(), proto.getEntityIdMSB(), proto.getEntityIdLSB()), proto.getKeysList(), callback);
    } else if (msg.hasAlarmUpdate()) {
        TbAlarmUpdateProto proto = msg.getAlarmUpdate();
        subscriptionManagerService.onAlarmUpdate(TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())), TbSubscriptionUtils.toEntityId(proto.getEntityType(), proto.getEntityIdMSB(), proto.getEntityIdLSB()), JacksonUtil.fromString(proto.getAlarm(), Alarm.class), callback);
    } else if (msg.hasAlarmDelete()) {
        TbAlarmDeleteProto proto = msg.getAlarmDelete();
        subscriptionManagerService.onAlarmDeleted(TenantId.fromUUID(new UUID(proto.getTenantIdMSB(), proto.getTenantIdLSB())), TbSubscriptionUtils.toEntityId(proto.getEntityType(), proto.getEntityIdMSB(), proto.getEntityIdLSB()), JacksonUtil.fromString(proto.getAlarm(), Alarm.class), callback);
    } else {
        throwNotHandled(msg, callback);
    }
    if (statsEnabled) {
        stats.log(msg);
    }
}
Also used : TbAlarmUpdateProto(org.thingsboard.server.gen.transport.TransportProtos.TbAlarmUpdateProto) TbSubscriptionCloseProto(org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionCloseProto) TbAlarmDeleteProto(org.thingsboard.server.gen.transport.TransportProtos.TbAlarmDeleteProto) TbAttributeUpdateProto(org.thingsboard.server.gen.transport.TransportProtos.TbAttributeUpdateProto) Alarm(org.thingsboard.server.common.data.alarm.Alarm) TbTimeSeriesUpdateProto(org.thingsboard.server.gen.transport.TransportProtos.TbTimeSeriesUpdateProto) TbAttributeDeleteProto(org.thingsboard.server.gen.transport.TransportProtos.TbAttributeDeleteProto) UUID(java.util.UUID) TbTimeSeriesDeleteProto(org.thingsboard.server.gen.transport.TransportProtos.TbTimeSeriesDeleteProto)

Aggregations

UUID (java.util.UUID)1 Alarm (org.thingsboard.server.common.data.alarm.Alarm)1 TbAlarmDeleteProto (org.thingsboard.server.gen.transport.TransportProtos.TbAlarmDeleteProto)1 TbAlarmUpdateProto (org.thingsboard.server.gen.transport.TransportProtos.TbAlarmUpdateProto)1 TbAttributeDeleteProto (org.thingsboard.server.gen.transport.TransportProtos.TbAttributeDeleteProto)1 TbAttributeUpdateProto (org.thingsboard.server.gen.transport.TransportProtos.TbAttributeUpdateProto)1 TbSubscriptionCloseProto (org.thingsboard.server.gen.transport.TransportProtos.TbSubscriptionCloseProto)1 TbTimeSeriesDeleteProto (org.thingsboard.server.gen.transport.TransportProtos.TbTimeSeriesDeleteProto)1 TbTimeSeriesUpdateProto (org.thingsboard.server.gen.transport.TransportProtos.TbTimeSeriesUpdateProto)1