From c255bbeb22eed021d9da071c567908e507200bbc Mon Sep 17 00:00:00 2001 From: priyanshu Date: Wed, 19 Sep 2018 16:00:48 +0530 Subject: Interface Operation disappears on VSP update Interface Operation disappears on VSP update Change-Id: I209e8a41292aa2ccfa4466b3f383d53005b7b08b Issue-ID: SDC-1772 Signed-off-by: priyanshu --- .../operations/TopologyTemplateOperation.java | 41 ++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'catalog-model/src/main/java/org') diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java index 0f124fd2eb..9a87874b2a 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java @@ -173,7 +173,7 @@ public class TopologyTemplateOperation extends ToscaElementOperation { return result; } - StorageOperationStatus associateInterfaces = associateInterfacesToResource(topologyTemplateVertex, topologyTemplate); + StorageOperationStatus associateInterfaces = associateInterfacesToComponent(topologyTemplateVertex, topologyTemplate); if (associateInterfaces != StorageOperationStatus.OK) { result = Either.right(associateInterfaces); return result; @@ -721,19 +721,23 @@ public class TopologyTemplateOperation extends ToscaElementOperation { } return TitanOperationStatus.OK; } - - private StorageOperationStatus associateInterfacesToResource(GraphVertex topologyTemplateVertex, - TopologyTemplate topologyTemplate) { - Map interfaces = topologyTemplate.getInterfaces(); - return associateInterfacesToComponent(topologyTemplateVertex,interfaces); - } - - public StorageOperationStatus associateInterfacesToComponent(GraphVertex nodeTypeVertex, Map interfaceMap) { + + private StorageOperationStatus associateInterfacesToComponent(GraphVertex topologyTemplateVertex, TopologyTemplate topologyTemplate) { + Map interfaceMap = topologyTemplate.getInterfaces(); if (interfaceMap != null && !interfaceMap.isEmpty()) { - Either assosiateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.INTERFACE, EdgeLabelEnum.INTERFACE, interfaceMap); + Either assosiateElementToData = associateElementToData(topologyTemplateVertex, VertexTypeEnum.INTERFACE, EdgeLabelEnum.INTERFACE, interfaceMap); if (assosiateElementToData.isRight()) { return assosiateElementToData.right().value(); } + else { + Map operationMap = interfaceMap.values().stream().filter(op -> MapUtils.isNotEmpty(op.getOperations())).flatMap(a -> a.getOperations().entrySet().stream()).collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue())); + if(MapUtils.isNotEmpty(operationMap)) { + Either assosiateOpToInterface = associateElementToData(assosiateElementToData.left().value(), VertexTypeEnum.INTERFACE_OPERATION, EdgeLabelEnum.INTERFACE_OPERATION, operationMap); + if (assosiateOpToInterface.isRight()) { + return assosiateOpToInterface.right().value(); + } + } + } } return StorageOperationStatus.OK; } @@ -1059,6 +1063,23 @@ public class TopologyTemplateOperation extends ToscaElementOperation { Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status)); } + Either getInterfaceVertex = titanDao.getChildVertex(toscaElementVertex, EdgeLabelEnum.INTERFACE, JsonParseFlagEnum.NoParse); + if (getInterfaceVertex.isLeft()) { + status = titanDao.disassociateAndDeleteLast(getInterfaceVertex.left().value(), Direction.OUT, EdgeLabelEnum.INTERFACE_OPERATION); + if (status != TitanOperationStatus.OK) { + log.debug("Failed to disassociate interface operations for {} error {}", getInterfaceVertex.left().value().getUniqueId(), status); + Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status)); + } + else { + status = titanDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INTERFACE); + if (status != TitanOperationStatus.OK) { + log.debug("Failed to disassociate interfaces for {} error {}", toscaElementVertex.getUniqueId(), status); + Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(status)); + } + } + + } + titanDao.disassociateAndDeleteLast(toscaElementVertex, Direction.OUT, EdgeLabelEnum.INSTANCE_ARTIFACTS); toscaElementVertex.getVertex().remove(); log.trace("Tosca element vertex for {} was removed", toscaElementVertex.getUniqueId()); -- cgit 1.2.3-korg