Commit 37b4db02133824e793c847c830160e55d5d584be

Authored by Volodymyr Babak
1 parent 6682d66b

Moved duplicate code to a separate method

@@ -263,19 +263,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { @@ -263,19 +263,7 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
263 case ADDED: 263 case ADDED:
264 case UPDATED: 264 case UPDATED:
265 case DELETED: 265 case DELETED:
266 - TextPageLink pageLink = new TextPageLink(DEFAULT_LIMIT);  
267 - TextPageData<Edge> pageData;  
268 - do {  
269 - pageData = edgeService.findEdgesByTenantId(tenantId, pageLink);  
270 - if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {  
271 - for (Edge edge : pageData.getData()) {  
272 - saveEdgeEvent(tenantId, edge.getId(), type, actionType, entityId, null);  
273 - }  
274 - if (pageData.hasNext()) {  
275 - pageLink = pageData.getNextPageLink();  
276 - }  
277 - }  
278 - } while (pageData != null && pageData.hasNext()); 266 + processActionForAllEdges(tenantId, type, actionType, entityId);
279 break; 267 break;
280 } 268 }
281 } 269 }
@@ -501,6 +489,22 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService { @@ -501,6 +489,22 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
501 }, dbCallbackExecutorService); 489 }, dbCallbackExecutorService);
502 } 490 }
503 } 491 }
  492 +
  493 + private void processActionForAllEdges(TenantId tenantId, EdgeEventType type, EdgeEventActionType actionType, EntityId entityId) {
  494 + TextPageLink pageLink = new TextPageLink(DEFAULT_LIMIT);
  495 + TextPageData<Edge> pageData;
  496 + do {
  497 + pageData = edgeService.findEdgesByTenantId(tenantId, pageLink);
  498 + if (pageData != null && pageData.getData() != null && !pageData.getData().isEmpty()) {
  499 + for (Edge edge : pageData.getData()) {
  500 + saveEdgeEvent(tenantId, edge.getId(), type, actionType, entityId, null);
  501 + }
  502 + if (pageData.hasNext()) {
  503 + pageLink = pageData.getNextPageLink();
  504 + }
  505 + }
  506 + } while (pageData != null && pageData.hasNext());
  507 + }
504 } 508 }
505 509
506 510