From ca487f60c2ca67794b16c0ff0cf5cc6deca556fc Mon Sep 17 00:00:00 2001 From: imamSidero Date: Tue, 20 Sep 2022 16:29:19 +0100 Subject: Fix for VFC version update on composition window On add service - composition window VFC version update/change is fixed by mapping appropriate requirements and capabilities Issue-ID: SDC-4185 Signed-off-by: Imam hussain Change-Id: I0de616510ca27c511179f1f34cf7290cd584c7c5 --- .../impl/ComponentInstanceBusinessLogic.java | 47 ++++++++++------------ 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'catalog-be/src/main/java/org') 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 ac01be010d..1d10c92313 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 @@ -3068,39 +3068,36 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } private void checkForExternalReqAndCapabilities(Component component, ComponentInstance resResourceInfo) { - Map> requirementsMap = resResourceInfo.getRequirements(); - Map> externalRequirementsMap = new HashMap<>(); - List 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); - } + if (MapUtils.isNotEmpty(component.getRequirements())) { + component.getRequirements().entrySet().forEach(requirementsMap -> { + if (MapUtils.isNotEmpty(resResourceInfo.getRequirements()) && resResourceInfo.getRequirements().containsKey(requirementsMap.getKey())) { + List resourceReqList = resResourceInfo.getRequirements().get(requirementsMap.getKey()); + for (RequirementDefinition requirements : requirementsMap.getValue()) { + String requirementName = requirements.getName(); + resourceReqList.forEach(requirementDefinition -> { + if (requirementName.equals(requirementDefinition.getName()) && requirementDefinition.isExternal()) { + requirements.setExternal(requirementDefinition.isExternal()); + } + }); } } }); } - - Map> capabilitiesMap = resResourceInfo.getCapabilities(); - Map> externalCapabilitiesMap = new HashMap<>(); - List 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); + if (MapUtils.isNotEmpty(component.getCapabilities())) { + component.getCapabilities().entrySet().forEach(capabilityMap -> { + if (MapUtils.isNotEmpty(resResourceInfo.getCapabilities()) && resResourceInfo.getCapabilities().containsKey(capabilityMap.getKey())) { + List resourceCapList = resResourceInfo.getCapabilities().get(capabilityMap.getKey()); + capabilityMap.getValue().forEach(capabilities -> { + String capabilityName = capabilities.getName(); + for (CapabilityDefinition capDef : resourceCapList) { + if (capabilityName.equals(capDef.getName()) && capDef.isExternal()) { + capabilities.setExternal(capDef.isExternal()); + } } - } + }); } }); } - component.setCapabilities(externalCapabilitiesMap); - component.setRequirements(externalRequirementsMap); } private boolean isFillProxyRes(StorageOperationStatus fillProxyRes) { -- cgit 1.2.3-korg