use of org.thingsboard.server.gen.edge.v1.UpdateMsgType in project thingsboard by thingsboard.
the class AlarmMsgConstructor method constructAlarmUpdatedMsg.
public AlarmUpdateMsg constructAlarmUpdatedMsg(TenantId tenantId, UpdateMsgType msgType, Alarm alarm) {
String entityName = null;
switch(alarm.getOriginator().getEntityType()) {
case DEVICE:
entityName = deviceService.findDeviceById(tenantId, new DeviceId(alarm.getOriginator().getId())).getName();
break;
case ASSET:
entityName = assetService.findAssetById(tenantId, new AssetId(alarm.getOriginator().getId())).getName();
break;
case ENTITY_VIEW:
entityName = entityViewService.findEntityViewById(tenantId, new EntityViewId(alarm.getOriginator().getId())).getName();
break;
}
AlarmUpdateMsg.Builder builder = AlarmUpdateMsg.newBuilder().setMsgType(msgType).setIdMSB(alarm.getId().getId().getMostSignificantBits()).setIdLSB(alarm.getId().getId().getLeastSignificantBits()).setName(alarm.getName()).setType(alarm.getType()).setOriginatorName(entityName).setOriginatorType(alarm.getOriginator().getEntityType().name()).setSeverity(alarm.getSeverity().name()).setStatus(alarm.getStatus().name()).setStartTs(alarm.getStartTs()).setEndTs(alarm.getEndTs()).setAckTs(alarm.getAckTs()).setClearTs(alarm.getClearTs()).setDetails(JacksonUtil.toString(alarm.getDetails())).setPropagate(alarm.isPropagate()).setPropagateToOwner(alarm.isPropagateToOwner()).setPropagateToTenant(alarm.isPropagateToTenant());
return builder.build();
}
use of org.thingsboard.server.gen.edge.v1.UpdateMsgType in project thingsboard by thingsboard.
the class RelationEdgeProcessor method processRelationToEdge.
public DownlinkMsg processRelationToEdge(EdgeEvent edgeEvent, UpdateMsgType msgType) {
EntityRelation entityRelation = mapper.convertValue(edgeEvent.getBody(), EntityRelation.class);
RelationUpdateMsg relationUpdateMsg = relationMsgConstructor.constructRelationUpdatedMsg(msgType, entityRelation);
return DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addRelationUpdateMsg(relationUpdateMsg).build();
}
use of org.thingsboard.server.gen.edge.v1.UpdateMsgType in project thingsboard by thingsboard.
the class WidgetBundleEdgeProcessor method processWidgetsBundleToEdge.
public DownlinkMsg processWidgetsBundleToEdge(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType edgeEdgeEventActionType) {
WidgetsBundleId widgetsBundleId = new WidgetsBundleId(edgeEvent.getEntityId());
DownlinkMsg downlinkMsg = null;
switch(edgeEdgeEventActionType) {
case ADDED:
case UPDATED:
WidgetsBundle widgetsBundle = widgetsBundleService.findWidgetsBundleById(edgeEvent.getTenantId(), widgetsBundleId);
if (widgetsBundle != null) {
WidgetsBundleUpdateMsg widgetsBundleUpdateMsg = widgetsBundleMsgConstructor.constructWidgetsBundleUpdateMsg(msgType, widgetsBundle);
downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addWidgetsBundleUpdateMsg(widgetsBundleUpdateMsg).build();
}
break;
case DELETED:
WidgetsBundleUpdateMsg widgetsBundleUpdateMsg = widgetsBundleMsgConstructor.constructWidgetsBundleDeleteMsg(widgetsBundleId);
downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addWidgetsBundleUpdateMsg(widgetsBundleUpdateMsg).build();
break;
}
return downlinkMsg;
}
use of org.thingsboard.server.gen.edge.v1.UpdateMsgType in project thingsboard by thingsboard.
the class CustomerEdgeProcessor method processCustomerToEdge.
public DownlinkMsg processCustomerToEdge(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeEventActionType action) {
CustomerId customerId = new CustomerId(edgeEvent.getEntityId());
DownlinkMsg downlinkMsg = null;
switch(action) {
case ADDED:
case UPDATED:
Customer customer = customerService.findCustomerById(edgeEvent.getTenantId(), customerId);
if (customer != null) {
CustomerUpdateMsg customerUpdateMsg = customerMsgConstructor.constructCustomerUpdatedMsg(msgType, customer);
downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addCustomerUpdateMsg(customerUpdateMsg).build();
}
break;
case DELETED:
CustomerUpdateMsg customerUpdateMsg = customerMsgConstructor.constructCustomerDeleteMsg(customerId);
downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addCustomerUpdateMsg(customerUpdateMsg).build();
break;
}
return downlinkMsg;
}
use of org.thingsboard.server.gen.edge.v1.UpdateMsgType in project thingsboard by thingsboard.
the class RuleChainEdgeProcessor method processRuleChainMetadataToEdge.
public DownlinkMsg processRuleChainMetadataToEdge(EdgeEvent edgeEvent, UpdateMsgType msgType, EdgeVersion edgeVersion) {
RuleChainId ruleChainId = new RuleChainId(edgeEvent.getEntityId());
RuleChain ruleChain = ruleChainService.findRuleChainById(edgeEvent.getTenantId(), ruleChainId);
DownlinkMsg downlinkMsg = null;
if (ruleChain != null) {
RuleChainMetaData ruleChainMetaData = ruleChainService.loadRuleChainMetaData(edgeEvent.getTenantId(), ruleChainId);
RuleChainMetadataUpdateMsg ruleChainMetadataUpdateMsg = ruleChainMsgConstructor.constructRuleChainMetadataUpdatedMsg(msgType, ruleChainMetaData, edgeVersion);
if (ruleChainMetadataUpdateMsg != null) {
downlinkMsg = DownlinkMsg.newBuilder().setDownlinkMsgId(EdgeUtils.nextPositiveInt()).addRuleChainMetadataUpdateMsg(ruleChainMetadataUpdateMsg).build();
}
}
return downlinkMsg;
}
Aggregations