Fix interface panel is blank when switched to a different version of a VFC 98/129198/6
authorJvD_Ericsson <jeff.van.dam@est.tech>
Wed, 11 May 2022 09:18:18 +0000 (10:18 +0100)
committerMichael Morris <michael.morris@est.tech>
Tue, 17 May 2022 08:27:02 +0000 (08:27 +0000)
Issue-ID: SDC-3997
Change-Id: Ibedd863fee39766cdf42edd32bdad7a67f9331cb
Signed-off-by: JvD_Ericsson <jeff.van.dam@est.tech>
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/merge/instance/ComponentInstanceInterfacesMerge.java

index 8d12751..ef55381 100644 (file)
@@ -2853,6 +2853,16 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
                 } else {
                     origComponent = getOriginComponentFromComponentInstance(newComponentInstance);
                     newComponentInstance.setName(resResourceInfo.getName());
+                    final Either<Component, StorageOperationStatus> getComponentRes = toscaOperationFacade
+                            .getToscaFullElement(newComponentInstance.getComponentUid());
+                    if (getComponentRes.isRight()) {
+                        throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getComponentRes.right().value()));
+                    }
+                    final Component component = getComponentRes.left().value();
+                    final Map<String, InterfaceDefinition> componentInterfaces = component.getInterfaces();
+                    if (MapUtils.isNotEmpty(componentInterfaces)) {
+                        componentInterfaces.forEach(newComponentInstance::addInterface);
+                    }
                 }
 
                 newComponentInstance.setInvariantName(resResourceInfo.getInvariantName());
index 2d49eae..43da618 100644 (file)
@@ -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<OperationInputDefinition> origInputs,
                                                 ListDataDefinition<OperationInputDefinition> 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));
     }
 }