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-25 10:06:44 +0200 |
commit | 7720ca05f69bc8bc62f8330232b7ad208b7434e4 (patch) | |
tree | 7d6802146cfff81e47b7563ef7d7bbcb778afc5e /bpmn/so-bpmn-tasks/src/main/java/org/onap | |
parent | c919ee261f665b824e716e77b5cc358ec15e44a9 (diff) |
WorkflowAction, traverseNetworkCollection refactoring stage 3
- invert if's;
- extract one logical function;
Issue-ID: SO-2634
Signed-off-by: Krzysztof Gajewski <krzysztof.gajewski@nokia.com>
Change-Id: I13ae784088fdbe1f4b6b16fc439d70597c1fe811
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java/org/onap')
-rw-r--r-- | bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java | 112 |
1 files changed, 57 insertions, 55 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 71e1abd564..99a825006e 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 @@ -848,64 +848,66 @@ public class WorkflowAction { private void traverseNetworkCollectionResourceCustomization(List<Resource> resourceList, CollectionResourceCustomization collectionResourceCustomization) { - if (collectionResourceCustomization != null) { - resourceList.add(new Resource(WorkflowType.NETWORKCOLLECTION, - collectionResourceCustomization.getModelCustomizationUUID(), false)); - logger.debug("Found a network collection"); - if (collectionResourceCustomization.getCollectionResource() != null) { - if (collectionResourceCustomization.getCollectionResource().getInstanceGroup() != null) { - String toscaNodeType = collectionResourceCustomization.getCollectionResource().getInstanceGroup() - .getToscaNodeType(); - if (toscaNodeType != null && toscaNodeType.contains(NETWORKCOLLECTION)) { - int minNetworks = 0; - org.onap.so.db.catalog.beans.InstanceGroup instanceGroup = - collectionResourceCustomization.getCollectionResource().getInstanceGroup(); - CollectionResourceInstanceGroupCustomization collectionInstCust = null; - if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) { - for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup - .getCollectionInstanceGroupCustomizations()) { - if (collectionInstanceGroupTemp.getModelCustomizationUUID().equalsIgnoreCase( - collectionResourceCustomization.getModelCustomizationUUID())) { - collectionInstCust = collectionInstanceGroupTemp; - break; - } - } - if (collectionInstCust != null - && collectionInstCust.getSubInterfaceNetworkQuantity() != null) { - minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); - } - } - logger.debug("minNetworks: {}", minNetworks); - CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; - for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup - .getCollectionNetworkResourceCustomizations()) { - if (collectionNetworkTemp.getNetworkResourceCustomization().getModelCustomizationUUID() - .equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) { - collectionNetworkResourceCust = collectionNetworkTemp; - 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); - } - } - } else { - logger.debug("Instance Group tosca node type does not contain NetworkCollection: {}", - toscaNodeType); - } - } else { - logger.debug("No Instance Group found for network collection."); + 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."); + 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(); + CollectionResourceInstanceGroupCustomization collectionInstCust = null; + if (!instanceGroup.getCollectionInstanceGroupCustomizations().isEmpty()) { + for (CollectionResourceInstanceGroupCustomization collectionInstanceGroupTemp : instanceGroup + .getCollectionInstanceGroupCustomizations()) { + if (collectionInstanceGroupTemp.getModelCustomizationUUID() + .equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) { + collectionInstCust = collectionInstanceGroupTemp; + break; } - } else { - logger.debug("No Network Collection found. collectionResource is null"); } - } else { - logger.debug("No Network Collection Customization found"); + if (collectionInstCust != null && collectionInstCust.getSubInterfaceNetworkQuantity() != null) { + minNetworks = collectionInstCust.getSubInterfaceNetworkQuantity(); + } + } + logger.debug("minNetworks: {}", minNetworks); + CollectionNetworkResourceCustomization collectionNetworkResourceCust = null; + for (CollectionNetworkResourceCustomization collectionNetworkTemp : instanceGroup + .getCollectionNetworkResourceCustomizations()) { + if (collectionNetworkTemp.getNetworkResourceCustomization().getModelCustomizationUUID() + .equalsIgnoreCase(collectionResourceCustomization.getModelCustomizationUUID())) { + collectionNetworkResourceCust = collectionNetworkTemp; + 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); + } + } + } + + private boolean toscaNodeTypeHasNetworkCollection(String toscaNodeType) { + return toscaNodeType != null && toscaNodeType.contains(NETWORKCOLLECTION); } private void traverseNetworkCollectionCustomization(List<Resource> resourceList, |