diff options
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java index 7ea00b1d46..392020be4d 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java @@ -2955,6 +2955,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { newComponentInstance.setInstanceCount(resResourceInfo.getInstanceCount()); newComponentInstance.setMaxOccurrences(resResourceInfo.getMaxOccurrences()); newComponentInstance.setMinOccurrences(resResourceInfo.getMinOccurrences()); + checkForExternalReqAndCapabilities(origComponent, resResourceInfo); ComponentInstance updatedComponentInstance = createComponentInstanceOnGraph(containerComponent, origComponent, newComponentInstance, user); @@ -2994,6 +2995,42 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } } + private void checkForExternalReqAndCapabilities(Component component, ComponentInstance resResourceInfo) { + Map<String, List<RequirementDefinition>> requirementsMap = resResourceInfo.getRequirements(); + Map<String, List<RequirementDefinition>> externalRequirementsMap = new HashMap<>(); + List<RequirementDefinition> externalRequirementList = new ArrayList<>(); + if (requirementsMap != null && !requirementsMap.isEmpty()) { + requirementsMap.forEach((type, requirementDefinitions) -> { + if (requirementDefinitions != null && !requirementDefinitions.isEmpty()) { + for (final RequirementDefinition requirementDefinition : requirementDefinitions) { + if (requirementDefinition.isExternal()) { + externalRequirementList.add(requirementDefinition); + externalRequirementsMap.put(type, externalRequirementList); + } + } + } + }); + } + + Map<String, List<CapabilityDefinition>> capabilitiesMap = resResourceInfo.getCapabilities(); + Map<String, List<CapabilityDefinition>> externalCapabilitiesMap = new HashMap<>(); + List<CapabilityDefinition> externalCapabilitiesList = new ArrayList<>(); + if (capabilitiesMap != null && !capabilitiesMap.isEmpty()) { + capabilitiesMap.forEach((type, capabilityDefinitions) -> { + if (capabilityDefinitions != null && !capabilityDefinitions.isEmpty()) { + for (final CapabilityDefinition capabilityDefinition : capabilityDefinitions) { + if (capabilityDefinition.isExternal()) { + externalCapabilitiesList.add(capabilityDefinition); + externalCapabilitiesMap.put(type, externalCapabilitiesList); + } + } + } + }); + } + component.setCapabilities(externalCapabilitiesMap); + component.setRequirements(externalRequirementsMap); + } + private boolean isFillProxyRes(StorageOperationStatus fillProxyRes) { if (fillProxyRes != StorageOperationStatus.OK) { log.debug("Failed to fill service proxy resource data with data from service, error {}", fillProxyRes); |