aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main
diff options
context:
space:
mode:
authorandre.schmid <andre.schmid@est.tech>2022-06-20 14:59:26 +0100
committerandre.schmid <andre.schmid@est.tech>2022-06-20 14:59:26 +0100
commitce3e2816ec3aa034bdef323c1a33b71485e87eb0 (patch)
tree06a0a2a442c1662dc7e646c7f3217eb390cc4f31 /catalog-model/src/main
parent097ca1640d7fe865649827635118bfa633fed805 (diff)
Allow to delete an interface operation from VFC
Issue-ID: SDC-4055 Change-Id: I43e79315dce12e2060f8b1dbdfcae29da46fc02e Signed-off-by: stasys10 <stasys.jurgaitis@est.tech> Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Signed-off-by: andre.schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-model/src/main')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java73
1 files changed, 52 insertions, 21 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java
index bc67281035..786c98d1a7 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/InterfaceOperation.java
@@ -26,27 +26,40 @@ import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
+import org.openecomp.sdc.be.model.Component;
import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
@org.springframework.stereotype.Component("interfaces-operation")
public class InterfaceOperation extends BaseOperation {
- public Either<List<InterfaceDefinition>, StorageOperationStatus> addInterfaces(String componentId,
+ public Either<List<InterfaceDefinition>, StorageOperationStatus> addInterfaces(final Component component,
List<InterfaceDefinition> interfaceDefinitions) {
- return addOrUpdateInterfaces(false, componentId, interfaceDefinitions);
+ final String componentId = component.getUniqueId();
+ if (isVfc(component)) {
+ return addOrUpdateInterfaces(componentId, VertexTypeEnum.INTERFACE_ARTIFACTS, EdgeLabelEnum.INTERFACE_ARTIFACTS, interfaceDefinitions,
+ false);
+ } else {
+ return addOrUpdateInterfaces(componentId, VertexTypeEnum.INTERFACE, EdgeLabelEnum.INTERFACE, interfaceDefinitions, false);
+ }
}
- private Either<List<InterfaceDefinition>, StorageOperationStatus> addOrUpdateInterfaces(boolean isUpdateAction, String componentId,
- List<InterfaceDefinition> interfaceDefinitions) {
- List<ToscaDataDefinition> interfaceDataDefinitions = interfaceDefinitions.stream().map(InterfaceDataDefinition::new)
+ private Either<List<InterfaceDefinition>, StorageOperationStatus> addOrUpdateInterfaces(final String componentId,
+ final VertexTypeEnum vertexTypeEnum,
+ final EdgeLabelEnum edgeLabelEnum,
+ final List<InterfaceDefinition> interfaceDefinitions,
+ final boolean isUpdateAction) {
+ final List<ToscaDataDefinition> interfaceDataDefinitions = interfaceDefinitions.stream()
+ .map(InterfaceDataDefinition::new)
.collect(Collectors.toList());
- StorageOperationStatus statusRes = performUpdateToscaAction(isUpdateAction, componentId, interfaceDataDefinitions, EdgeLabelEnum.INTERFACE,
- VertexTypeEnum.INTERFACE);
- if (!statusRes.equals(StorageOperationStatus.OK)) {
- return Either.right(statusRes);
+ final StorageOperationStatus status = performUpdateToscaAction(isUpdateAction, componentId, interfaceDataDefinitions, edgeLabelEnum,
+ vertexTypeEnum);
+ if (!status.equals(StorageOperationStatus.OK)) {
+ return Either.right(status);
}
return Either.left(interfaceDefinitions);
}
@@ -60,25 +73,43 @@ public class InterfaceOperation extends BaseOperation {
}
}
- public Either<List<InterfaceDefinition>, StorageOperationStatus> updateInterfaces(String componentId,
- List<InterfaceDefinition> interfaceDefinitions) {
- return addOrUpdateInterfaces(true, componentId, interfaceDefinitions);
+ public Either<List<InterfaceDefinition>, StorageOperationStatus> updateInterfaces(final Component component,
+ final List<InterfaceDefinition> interfaceDefinitions) {
+ final String componentId = component.getUniqueId();
+ if (isVfc(component)) {
+ return addOrUpdateInterfaces(componentId, VertexTypeEnum.INTERFACE_ARTIFACTS, EdgeLabelEnum.INTERFACE_ARTIFACTS, interfaceDefinitions,
+ true);
+ } else {
+ return addOrUpdateInterfaces(componentId, VertexTypeEnum.INTERFACE, EdgeLabelEnum.INTERFACE, interfaceDefinitions, true);
+ }
+ }
+
+ public Either<String, StorageOperationStatus> deleteInterface(final Component component, final String interfacesToDelete) {
+ final String componentId = component.getUniqueId();
+ if (isVfc(component)) {
+ return deleteInterface(componentId, interfacesToDelete, EdgeLabelEnum.INTERFACE_ARTIFACTS, VertexTypeEnum.INTERFACE_ARTIFACTS);
+ } else {
+ return deleteInterface(componentId, interfacesToDelete, EdgeLabelEnum.INTERFACE, VertexTypeEnum.INTERFACE);
+ }
+ }
+
+ private boolean isVfc(Component component) {
+ return component instanceof Resource && ((Resource) component).getResourceType() == ResourceTypeEnum.VFC;
}
- public Either<String, StorageOperationStatus> deleteInterface(String componentId, String interfacesToDelete) {
- StorageOperationStatus statusRes = deleteToscaDataElements(componentId, EdgeLabelEnum.INTERFACE,
- Collections.singletonList(interfacesToDelete));
+ private Either<String, StorageOperationStatus> deleteInterface(final String componentId, final String interfacesToDelete,
+ final EdgeLabelEnum edgeLabel, final VertexTypeEnum vertexType) {
+ StorageOperationStatus statusRes = deleteToscaDataElements(componentId, edgeLabel, Collections.singletonList(interfacesToDelete));
if (!statusRes.equals(StorageOperationStatus.OK)) {
return Either.right(statusRes);
}
- Either<Map<String, InterfaceDataDefinition>, JanusGraphOperationStatus> componentEither = getDataFromGraph(componentId,
- EdgeLabelEnum.INTERFACE);
- if (componentEither.isRight()) {
- return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(componentEither.right().value()));
+ Either<Map<String, InterfaceDataDefinition>, JanusGraphOperationStatus> interfaceEither = getDataFromGraph(componentId, edgeLabel);
+ if (interfaceEither.isRight()) {
+ return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(interfaceEither.right().value()));
}
- Map<String, InterfaceDataDefinition> interfaceDataDefinitionMap = componentEither.left().value();
+ final Map<String, InterfaceDataDefinition> interfaceDataDefinitionMap = interfaceEither.left().value();
if (MapUtils.isEmpty(interfaceDataDefinitionMap)) {
- statusRes = removeToscaData(componentId, EdgeLabelEnum.INTERFACE, VertexTypeEnum.INTERFACE);
+ statusRes = removeToscaData(componentId, edgeLabel, vertexType);
if (!statusRes.equals(StorageOperationStatus.OK)) {
return Either.right(statusRes);
}