diff options
author | Krzysztof Gajewski <krzysztof.gajewski@nokia.com> | 2020-06-19 17:07:02 +0200 |
---|---|---|
committer | Krzysztof Gajewski <krzysztof.gajewski@nokia.com> | 2020-06-30 17:46:36 +0200 |
commit | 9111b2e07b29258b7640fb9fcbac08dcc3441cda (patch) | |
tree | 950d13ba075cff7d8bc340524325e96d719e312d /bpmn/so-bpmn-tasks | |
parent | 670f246573516471bc8e76c51fd5fd17a24d3e43 (diff) |
WorkflowAction, traverseNetworkCollection refactoring stage 5
- extract method
- invert if
- method rename
Issue-ID: SO-2634
Signed-off-by: Krzysztof Gajewski <krzysztof.gajewski@nokia.com>
Change-Id: Iab2e5694fd2d3b7913bc27f9d4a846d84764c576
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r-- | bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java | 49 |
1 files changed, 28 insertions, 21 deletions
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<Resource> resourceList, org.onap.so.db.catalog.beans.Service service) { - if (isVnfCustomizationsEmpty(service)) { - List<CollectionResourceCustomization> 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<CollectionResourceCustomization> 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<Resource> 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<Resource> 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<Resource> resourceList, String resourceId, |