From 9111b2e07b29258b7640fb9fcbac08dcc3441cda Mon Sep 17 00:00:00 2001 From: Krzysztof Gajewski Date: Fri, 19 Jun 2020 17:07:02 +0200 Subject: WorkflowAction, traverseNetworkCollection refactoring stage 5 - extract method - invert if - method rename Issue-ID: SO-2634 Signed-off-by: Krzysztof Gajewski Change-Id: Iab2e5694fd2d3b7913bc27f9d4a846d84764c576 --- .../workflow/tasks/WorkflowAction.java | 49 ++++++++++++---------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'bpmn/so-bpmn-tasks/src/main/java/org/onap') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 09c7a661e0..8fdc340b54 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -75,6 +75,7 @@ import org.onap.so.db.catalog.beans.CollectionResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.CvnfcCustomization; +import org.onap.so.db.catalog.beans.InstanceGroup; import org.onap.so.db.catalog.beans.VfModuleCustomization; import org.onap.so.db.catalog.beans.macro.NorthBoundRequest; import org.onap.so.db.catalog.beans.macro.OrchestrationFlow; @@ -802,20 +803,19 @@ public class WorkflowAction { protected void traverseNetworkCollection(DelegateExecution execution, List resourceList, org.onap.so.db.catalog.beans.Service service) { - if (isVnfCustomizationsEmpty(service)) { - List customizations = service.getCollectionResourceCustomizations(); - if (customizations.isEmpty()) { - logger.debug("No Collections found. CollectionResourceCustomization list is empty."); - } else { - CollectionResourceCustomization collectionResourceCustomization = - findCatalogNetworkCollection(execution, service); - traverseNetworkCollectionResourceCustomization(resourceList, collectionResourceCustomization); - } - traverseNetworkCollectionCustomization(resourceList, service); - } else { + if (isVnfCustomizationsInTheService(service)) { buildAndThrowException(execution, "Cannot orchestrate Service-Macro-Create without user params with a vnf. Please update ASDC model for new macro orchestration support or add service_recipe records to route to old macro flows"); } + List customizations = service.getCollectionResourceCustomizations(); + if (customizations.isEmpty()) { + logger.debug("No Collections found. CollectionResourceCustomization list is empty."); + } else { + CollectionResourceCustomization collectionResourceCustomization = + findCatalogNetworkCollection(execution, service); + traverseNetworkCollectionResourceCustomization(resourceList, collectionResourceCustomization); + } + traverseNetworkCollectionCustomization(resourceList, service); } private void traverseNetworkCollectionResourceCustomization(List resourceList, @@ -840,6 +840,20 @@ public class WorkflowAction { } } logger.debug("minNetworks: {}", minNetworks); + CollectionNetworkResourceCustomization collectionNetworkResourceCust = + getCollectionNetworkResourceCustomization(collectionResourceCustomization, instanceGroup); + for (int i = 0; i < minNetworks; i++) { + if (collectionNetworkResourceCust != null && collectionInstCust != null) { + Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, + collectionNetworkResourceCust.getModelCustomizationUUID(), false); + resource.setVirtualLinkKey(Integer.toString(i)); + resourceList.add(resource); + } + } + } + + private CollectionNetworkResourceCustomization getCollectionNetworkResourceCustomization( + CollectionResourceCustomization collectionResourceCustomization, InstanceGroup instanceGroup) { CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup .getCollectionNetworkResourceCustomizations()) { @@ -849,14 +863,7 @@ public class WorkflowAction { break; } } - for (int i = 0; i < minNetworks; i++) { - if (collectionNetworkResourceCust != null && collectionInstCust != null) { - Resource resource = new Resource(WorkflowType.VIRTUAL_LINK, - collectionNetworkResourceCust.getModelCustomizationUUID(), false); - resource.setVirtualLinkKey(Integer.toString(i)); - resourceList.add(resource); - } - } + return collectionNetworkResourceCust; } private boolean collectionResourceCustomizationShouldNotBeProcessed(List resourceList, @@ -914,8 +921,8 @@ public class WorkflowAction { .collect(Collectors.toList()).isEmpty()); } - private boolean isVnfCustomizationsEmpty(org.onap.so.db.catalog.beans.Service service) { - return service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty(); + private boolean isVnfCustomizationsInTheService(org.onap.so.db.catalog.beans.Service service) { + return !(service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()); } protected void traverseAAIService(DelegateExecution execution, List resourceList, String resourceId, -- cgit 1.2.3-korg