Minor code clean up to be in sync with PE

This commit is contained in:
Volodymyr Babak 2022-10-11 12:52:37 +03:00
parent 6ecec3eefa
commit c491b3a787

View File

@ -102,7 +102,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS
List<EdgeId> relatedEdgeIds, List<EdgeId> relatedEdgeIds,
User user, Object... additionalInfo) { User user, Object... additionalInfo) {
logEntityAction(tenantId, entityId, entity, customerId, actionType, user, additionalInfo); logEntityAction(tenantId, entityId, entity, customerId, actionType, user, additionalInfo);
sendDeleteNotificationMsg(tenantId, entityId, entity, relatedEdgeIds); sendDeleteNotificationMsg(tenantId, entityId, relatedEdgeIds, null);
} }
@Override @Override
@ -245,13 +245,9 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS
ActionType actionType, Object... additionalInfo) { ActionType actionType, Object... additionalInfo) {
logEntityAction(tenantId, relation.getFrom(), null, customerId, actionType, user, additionalInfo); logEntityAction(tenantId, relation.getFrom(), null, customerId, actionType, user, additionalInfo);
logEntityAction(tenantId, relation.getTo(), null, customerId, actionType, user, additionalInfo); logEntityAction(tenantId, relation.getTo(), null, customerId, actionType, user, additionalInfo);
try { if (!EntityType.EDGE.equals(relation.getFrom().getEntityType()) && !EntityType.EDGE.equals(relation.getTo().getEntityType())) {
if (!relation.getFrom().getEntityType().equals(EntityType.EDGE) && !relation.getTo().getEntityType().equals(EntityType.EDGE)) { sendNotificationMsgToEdge(tenantId, null, null, JacksonUtil.toString(relation),
sendNotificationMsgToEdge(tenantId, null, null, JacksonUtil.toString(relation), EdgeEventType.RELATION, edgeTypeByActionType(actionType));
EdgeEventType.RELATION, edgeTypeByActionType(actionType));
}
} catch (Exception e) {
log.warn("Failed to push relation to core: {}", relation, e);
} }
} }
@ -260,19 +256,7 @@ public class DefaultTbNotificationEntityService implements TbNotificationEntityS
} }
private void sendAlarmDeleteNotificationMsg(TenantId tenantId, Alarm alarm, List<EdgeId> edgeIds, String body) { private void sendAlarmDeleteNotificationMsg(TenantId tenantId, Alarm alarm, List<EdgeId> edgeIds, String body) {
try { sendDeleteNotificationMsg(tenantId, alarm.getId(), edgeIds, body);
sendDeleteNotificationMsg(tenantId, alarm.getId(), edgeIds, body);
} catch (Exception e) {
log.warn("Failed to push delete msg to core: {}", alarm, e);
}
}
private <E extends HasName, I extends EntityId> void sendDeleteNotificationMsg(TenantId tenantId, I entityId, E entity, List<EdgeId> edgeIds) {
try {
sendDeleteNotificationMsg(tenantId, entityId, edgeIds, null);
} catch (Exception e) {
log.warn("Failed to push delete msg to core: {}", entity, e);
}
} }
private void sendDeleteNotificationMsg(TenantId tenantId, EntityId entityId, List<EdgeId> edgeIds, String body) { private void sendDeleteNotificationMsg(TenantId tenantId, EntityId entityId, List<EdgeId> edgeIds, String body) {