summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperation.java41
2 files changed, 36 insertions, 10 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 6bb8c5c613..4bceb0cc99 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -3306,6 +3306,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (newResource.getToscaArtifacts() == null || newResource.getToscaArtifacts().isEmpty()) {
setToscaArtifactsPlaceHolders(newResource, user);
}
+
+ if (newResource.getInterfaces() == null || newResource.getInterfaces().isEmpty()) {
+ newResource.setInterfaces(oldResource.getInterfaces());
+ }
+
Either<Resource, StorageOperationStatus> overrideResource = toscaOperationFacade
.overrideComponent(newResource, oldResource);
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<String, InterfaceDataDefinition> interfaces = topologyTemplate.getInterfaces();
- return associateInterfacesToComponent(topologyTemplateVertex,interfaces);
- }
-
- public StorageOperationStatus associateInterfacesToComponent(GraphVertex nodeTypeVertex, Map<String, InterfaceDataDefinition> interfaceMap) {
+
+ private StorageOperationStatus associateInterfacesToComponent(GraphVertex topologyTemplateVertex, TopologyTemplate topologyTemplate) {
+ Map<String, InterfaceDataDefinition> interfaceMap = topologyTemplate.getInterfaces();
if (interfaceMap != null && !interfaceMap.isEmpty()) {
- Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(nodeTypeVertex, VertexTypeEnum.INTERFACE, EdgeLabelEnum.INTERFACE, interfaceMap);
+ Either<GraphVertex, StorageOperationStatus> assosiateElementToData = associateElementToData(topologyTemplateVertex, VertexTypeEnum.INTERFACE, EdgeLabelEnum.INTERFACE, interfaceMap);
if (assosiateElementToData.isRight()) {
return assosiateElementToData.right().value();
}
+ else {
+ Map<String, OperationDataDefinition> 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<GraphVertex, StorageOperationStatus> 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<GraphVertex, TitanOperationStatus> 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());