|
|
|
@ -81,13 +81,16 @@ public class CustomerEdgeProcessor extends BaseEdgeProcessor { |
|
|
|
UUID uuid = new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB()); |
|
|
|
CustomerId customerId = new CustomerId(EntityIdFactory.getByEdgeEventTypeAndUuid(type, uuid).getId()); |
|
|
|
switch (actionType) { |
|
|
|
case UPDATED: |
|
|
|
List<ListenableFuture<Void>> futures = new ArrayList<>(); |
|
|
|
PageDataIterable<Edge> edges = new PageDataIterable<>(link -> edgeCtx.getEdgeService().findEdgesByTenantIdAndCustomerId(tenantId, customerId, link), 1024); |
|
|
|
for (Edge edge : edges) { |
|
|
|
futures.add(saveEdgeEvent(tenantId, edge.getId(), type, actionType, customerId, null)); |
|
|
|
case ADDED: |
|
|
|
Customer customerById = edgeCtx.getCustomerService().findCustomerById(tenantId, customerId); |
|
|
|
if (customerById != null && customerById.isPublic()) { |
|
|
|
return findEdgesAndSaveEdgeEvents(link -> edgeCtx.getEdgeService().findEdgesByTenantId(tenantId, link), |
|
|
|
tenantId, type, actionType, customerId); |
|
|
|
} |
|
|
|
return Futures.transform(Futures.allAsList(futures), voids -> null, dbCallbackExecutorService); |
|
|
|
return Futures.immediateFuture(null); |
|
|
|
case UPDATED: |
|
|
|
return findEdgesAndSaveEdgeEvents(link -> edgeCtx.getEdgeService().findEdgesByTenantIdAndCustomerId(tenantId, customerId, link), |
|
|
|
tenantId, type, actionType, customerId); |
|
|
|
case DELETED: |
|
|
|
EdgeId edgeId = new EdgeId(new UUID(edgeNotificationMsg.getEdgeIdMSB(), edgeNotificationMsg.getEdgeIdLSB())); |
|
|
|
return saveEdgeEvent(tenantId, edgeId, type, actionType, customerId, null); |
|
|
|
@ -96,6 +99,16 @@ public class CustomerEdgeProcessor extends BaseEdgeProcessor { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ListenableFuture<Void> findEdgesAndSaveEdgeEvents(PageDataIterable.FetchFunction<Edge> edgeFetcher, TenantId tenantId, |
|
|
|
EdgeEventType type, EdgeEventActionType actionType, CustomerId customerId) { |
|
|
|
List<ListenableFuture<Void>> futures = new ArrayList<>(); |
|
|
|
PageDataIterable<Edge> edges = new PageDataIterable<>(edgeFetcher, 1024); |
|
|
|
for (Edge edge : edges) { |
|
|
|
futures.add(saveEdgeEvent(tenantId, edge.getId(), type, actionType, customerId, null)); |
|
|
|
} |
|
|
|
return Futures.transform(Futures.allAsList(futures), voids -> null, dbCallbackExecutorService); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public EdgeEventType getEdgeEventType() { |
|
|
|
return EdgeEventType.CUSTOMER; |
|
|
|
|