From: JvD_Ericsson Date: Wed, 11 May 2022 09:18:18 +0000 (+0100) Subject: Fix interface panel is blank when switched to a different version of a VFC X-Git-Tag: 1.11.3~6 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F98%2F129198%2F6;p=sdc.git Fix interface panel is blank when switched to a different version of a VFC Issue-ID: SDC-3997 Change-Id: Ibedd863fee39766cdf42edd32bdad7a67f9331cb Signed-off-by: JvD_Ericsson --- 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 8d12751c07..ef55381974 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 @@ -2853,6 +2853,16 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { } else { origComponent = getOriginComponentFromComponentInstance(newComponentInstance); newComponentInstance.setName(resResourceInfo.getName()); + final Either getComponentRes = toscaOperationFacade + .getToscaFullElement(newComponentInstance.getComponentUid()); + if (getComponentRes.isRight()) { + throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getComponentRes.right().value())); + } + final Component component = getComponentRes.left().value(); + final Map componentInterfaces = component.getInterfaces(); + if (MapUtils.isNotEmpty(componentInterfaces)) { + componentInterfaces.forEach(newComponentInstance::addInterface); + } } newComponentInstance.setInvariantName(resResourceInfo.getInvariantName()); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInterfacesMerge.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInterfacesMerge.java index 2d49eaeffe..43da6181cd 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInterfacesMerge.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInterfacesMerge.java @@ -74,18 +74,29 @@ public class ComponentInstanceInterfacesMerge implements ComponentInstanceMergeI newOperationDef -> prevInstanceInterfaces.stream().filter(in -> in.getUniqueId().equals(newInterfaceDef.getUniqueId())).forEach( prevInterfaceDef -> prevInterfaceDef.getOperationsMap().values().stream() .filter(in1 -> in1.getUniqueId().equals(newOperationDef.getUniqueId())) - .forEach(oldOperationDef -> mergeOperationInputDefinitions(oldOperationDef.getInputs(), newOperationDef.getInputs()))))); + .forEach(oldOperationDef -> { + if(oldOperationDef.getInputs() != null) { + if(newOperationDef.getInputs() == null) { + newOperationDef.setInputs(new ListDataDefinition<>()); + } + mergeOperationInputDefinitions(oldOperationDef.getInputs(), newOperationDef.getInputs()); + } + })))); StorageOperationStatus updateStatus = toscaOperationFacade.updateComponentInstanceInterfaces(currentComponent, instanceId); return componentsUtils.convertFromStorageResponse(updateStatus); } private void mergeOperationInputDefinitions(ListDataDefinition origInputs, ListDataDefinition newInputs) { - newInputs.getListToscaDataDefinition() - .forEach(inp -> origInputs.getListToscaDataDefinition().stream().filter(in -> in.getInputId().equals(inp.getInputId())).forEach(in -> { - inp.setSourceProperty(in.getSourceProperty()); - inp.setSource(in.getSource()); - inp.setValue(in.getValue()); - })); + newInputs.getListToscaDataDefinition(). + forEach(inp -> origInputs.getListToscaDataDefinition().stream().filter(in -> in.getInputId().equals(inp.getInputId())). + forEach(in -> { + inp.setSourceProperty(in.getSourceProperty()); + inp.setSource(in.getSource()); + inp.setValue(in.getValue()); + })); + origInputs.getListToscaDataDefinition().stream(). + filter(inp -> newInputs.getListToscaDataDefinition().stream().noneMatch(in -> in.getInputId().equals(inp.getInputId()))). + forEach(inp -> newInputs.getListToscaDataDefinition().add(inp)); } }