WorkflowAction, traverseNetworkCollection refactoring stage 4 87/109587/3
authorKrzysztof Gajewski <krzysztof.gajewski@nokia.com>
Fri, 19 Jun 2020 15:07:02 +0000 (17:07 +0200)
committerKrzysztof Gajewski <krzysztof.gajewski@nokia.com>
Mon, 29 Jun 2020 09:58:54 +0000 (11:58 +0200)
- extract if's to method
- extract one logical function;

Issue-ID: SO-2634
Signed-off-by: Krzysztof Gajewski <krzysztof.gajewski@nokia.com>
Change-Id: Ia31184383814a408d91d7e951e7df944647454ca

bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java

index 99a8250..b64f62a 100644 (file)
@@ -848,27 +848,8 @@ public class WorkflowAction {
 
     private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList,
             CollectionResourceCustomization collectionResourceCustomization) {
-        if (collectionResourceCustomization == null) {
-            logger.debug("No Network Collection Customization found");
-            return;
-        }
-        resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION,
-                collectionResourceCustomization.getModelCustomizationUUID(), false));
-        logger.debug("Found a network collection");
-        if (collectionResourceCustomization.getCollectionResource() == null) {
-            logger.debug("No Network Collection found. collectionResource is null");
-            return;
-        }
-        if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() == null) {
-            logger.debug("No Instance Group found for network collection.");
+        if (collectionResourceCustomizationShouldNotBeProcessed(resourceList, collectionResourceCustomization))
             return;
-        }
-        String toscaNodeType =
-                collectionResourceCustomization.getCollectionResource().getInstanceGroup().getToscaNodeType();
-        if (!toscaNodeTypeHasNetworkCollection(toscaNodeType)) {
-            logger.debug("Instance Group tosca node type does not contain NetworkCollection:  {}", toscaNodeType);
-            return;
-        }
         int minNetworks = 0;
         org.onap.so.db.catalog.beans.InstanceGroup instanceGroup =
                 collectionResourceCustomization.getCollectionResource().getInstanceGroup();
@@ -882,7 +863,7 @@ public class WorkflowAction {
                     break;
                 }
             }
-            if (collectionInstCust != null && collectionInstCust.getSubInterfaceNetworkQuantity() != null) {
+            if (interfaceNetworkQuantityIsAvailableInCollection(collectionInstCust)) {
                 minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity();
             }
         }
@@ -906,6 +887,37 @@ public class WorkflowAction {
         }
     }
 
+    private boolean collectionResourceCustomizationShouldNotBeProcessed(List<Resource> resourceList,
+            CollectionResourceCustomization collectionResourceCustomization) {
+        if (collectionResourceCustomization == null) {
+            logger.debug("No Network Collection Customization found");
+            return true;
+        }
+        resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION,
+                collectionResourceCustomization.getModelCustomizationUUID(), false));
+        logger.debug("Found a network collection");
+        if (collectionResourceCustomization.getCollectionResource() == null) {
+            logger.debug("No Network Collection found. collectionResource is null");
+            return true;
+        }
+        if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() == null) {
+            logger.debug("No Instance Group found for network collection.");
+            return true;
+        }
+        String toscaNodeType =
+                collectionResourceCustomization.getCollectionResource().getInstanceGroup().getToscaNodeType();
+        if (!toscaNodeTypeHasNetworkCollection(toscaNodeType)) {
+            logger.debug("Instance Group tosca node type does not contain NetworkCollection:  {}", toscaNodeType);
+            return true;
+        }
+        return false;
+    }
+
+    private boolean interfaceNetworkQuantityIsAvailableInCollection(
+            CollectionResourceInstanceGroupCustomization collectionInstCust) {
+        return collectionInstCust != null && collectionInstCust.getSubInterfaceNetworkQuantity() != null;
+    }
+
     private boolean toscaNodeTypeHasNetworkCollection(String toscaNodeType) {
         return toscaNodeType != null && toscaNodeType.contains(NETWORKCOLLECTION);
     }