From 1622bbc20d2d55e1881e87de83ab6ae6d579d859 Mon Sep 17 00:00:00 2001 From: Krzysztof Gajewski Date: Mon, 15 Jun 2020 18:11:28 +0200 Subject: WorkflowAction, traverseNetworkCollection refactoring stage 1 - extract one function; if logic refactor - two boolean "ifs" function created Issue-ID: SO-2634 Signed-off-by: Krzysztof Gajewski Change-Id: Ia139d0a6f1b470c8e7fab77afc76937dac9f5364 Signed-off-by: Krzysztof Gajewski --- .../workflow/tasks/WorkflowAction.java | 41 ++++++++++++++-------- 1 file changed, 27 insertions(+), 14 deletions(-) (limited to 'bpmn') 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 b4eb97a187..fe45e1385e 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 @@ -338,8 +338,7 @@ public class WorkflowAction { } flowsToExecute = buildExecuteBuildingBlockList(orchFlows, resourceList, requestId, apiVersion, resourceId, requestAction, vnfType, workflowResourceIds, requestDetails, vnfReplace); - if (!resourceList.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) - .collect(Collectors.toList()).isEmpty()) { + if (isNetworkCollectionInTheResourceList(resourceList)) { logger.info("Sorting for Vlan Tagging"); flowsToExecute = sortExecutionPathByObjectForVlanTagging(flowsToExecute, requestAction); } @@ -799,7 +798,7 @@ public class WorkflowAction { protected void traverseNetworkCollection(DelegateExecution execution, List resourceList, org.onap.so.db.catalog.beans.Service service) { - if (service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty()) { + if (isVnfCustomizationsEmpty(service)) { List customizations = service.getCollectionResourceCustomizations(); if (customizations.isEmpty()) { logger.debug("No Collections found. CollectionResourceCustomization list is empty."); @@ -866,23 +865,37 @@ public class WorkflowAction { logger.debug("No Network Collection Customization found"); } } - if (resourceList.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) - .collect(Collectors.toList()).isEmpty()) { - if (service.getNetworkCustomizations() == null) { - logger.debug("No networks were found on this service model"); - } else { - for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { - resourceList.add(new Resource(WorkflowType.NETWORK, - service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false)); - } - } - } + traverseNetworkCollectionCustomization(resourceList, service); } else { 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"); } } + private void traverseNetworkCollectionCustomization(List resourceList, + org.onap.so.db.catalog.beans.Service service) { + if (isNetworkCollectionInTheResourceList(resourceList)) { + return; + } + if (service.getNetworkCustomizations() == null) { + logger.debug("No networks were found on this service model"); + return; + } + for (int i = 0; i < service.getNetworkCustomizations().size(); i++) { + resourceList.add(new Resource(WorkflowType.NETWORK, + service.getNetworkCustomizations().get(i).getModelCustomizationUUID(), false)); + } + } + + private boolean isNetworkCollectionInTheResourceList(List resourceList) { + return !(resourceList.stream().filter(x -> WorkflowType.NETWORKCOLLECTION == x.getResourceType()) + .collect(Collectors.toList()).isEmpty()); + } + + private boolean isVnfCustomizationsEmpty(org.onap.so.db.catalog.beans.Service service) { + return service.getVnfCustomizations() == null || service.getVnfCustomizations().isEmpty(); + } + protected void traverseAAIService(DelegateExecution execution, List resourceList, String resourceId, List> aaiResourceIds) { try { -- cgit 1.2.3-korg