summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-model/src/main')
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java45
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java2
3 files changed, 40 insertions, 9 deletions
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java
index b8ddff9907..d8a2d44967 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/DataTypeOperation.java
@@ -325,7 +325,7 @@ public class DataTypeOperation extends AbstractOperation {
}
public void removeDataTypeFromAdditionalType(final DataTypeDataDefinition dataTypeDataDefinition) {
- modelOperation.removeDataTypeFromAdditionalType(ElementTypeEnum.DATA_TYPE, dataTypeDataDefinition.getModel(),
+ modelOperation.removeTypeFromAdditionalType(ElementTypeEnum.DATA_TYPE, dataTypeDataDefinition.getModel(),
dataTypeDataDefinition.getName());
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java
index 9299aec7e0..7fc97ccabc 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java
@@ -17,8 +17,10 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.openecomp.sdc.be.model.operations.impl;
+import fj.data.Either;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@@ -27,8 +29,9 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
-
+import javax.annotation.Resource;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
@@ -42,6 +45,7 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.normatives.ElementTypeEnum;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.resources.data.ArtifactData;
@@ -53,8 +57,6 @@ import org.openecomp.sdc.be.resources.data.UniqueIdData;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
-import fj.data.Either;
-
@Component("interface-operation")
public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation {
@@ -65,6 +67,9 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation
private ArtifactOperation artifactOperation;
@javax.annotation.Resource
private JanusGraphGenericDao janusGraphGenericDao;
+ @Resource
+ private ModelOperation modelOperation;
+
public InterfaceLifecycleOperation() {
super();
}
@@ -816,7 +821,8 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation
final GraphNode from = new UniqueIdData(NodeTypeEnum.Model, UniqueIdBuilder.buildModelUid(model));
final GraphNode to = new UniqueIdData(NodeTypeEnum.Interface, interfaceDefinition.getUniqueId());
log.info("Connecting model {} to type {}", from, to);
- return janusGraphGenericDao.createRelation(from , to, GraphEdgeLabels.MODEL_ELEMENT, Collections.emptyMap()).right().map(DaoStatusConverter::convertJanusGraphStatusToStorageStatus);
+ return janusGraphGenericDao.createRelation(from, to, GraphEdgeLabels.MODEL_ELEMENT, Collections.emptyMap()).right()
+ .map(DaoStatusConverter::convertJanusGraphStatusToStorageStatus);
}
@Override
@@ -860,7 +866,7 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation
List<InterfaceData> interfaceDataList = allInterfaceLifecycleTypes.left().value();
List<InterfaceDefinition> interfaceDefinitions = interfaceDataList.stream().map(this::convertInterfaceDataToInterfaceDefinition)
.filter(interfaceDefinition -> interfaceDefinition.getUniqueId()
- .equalsIgnoreCase(UniqueIdBuilder.buildInterfaceTypeUid(interfaceDefinition.getModel(), interfaceDefinition.getType()))
+ .equalsIgnoreCase(UniqueIdBuilder.buildInterfaceTypeUid(interfaceDefinition.getModel(), interfaceDefinition.getType()))
).collect(Collectors.toList());
for (InterfaceDefinition interfaceDefinition : interfaceDefinitions) {
Either<List<ImmutablePair<OperationData, GraphEdge>>, JanusGraphOperationStatus> childrenNodes = janusGraphGenericDao
@@ -881,11 +887,36 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation
private String getModelAssociatedToInterface(String uid) {
final Either<ImmutablePair<ModelData, GraphEdge>, JanusGraphOperationStatus> model = janusGraphGenericDao.getParentNode(
- UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Interface), uid, GraphEdgeLabels.MODEL_ELEMENT,
- NodeTypeEnum.Model, ModelData.class);
+ UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.Interface), uid, GraphEdgeLabels.MODEL_ELEMENT,
+ NodeTypeEnum.Model, ModelData.class);
if (model.isLeft()) {
return model.left().value().getLeft().getName();
}
return null;
}
+
+ public void deleteInterfaceTypeById(String interfaceTypeId) {
+ try (final GraphTraversalSource traversal = janusGraphGenericDao.getJanusGraph().traversal()) {
+ traversal.V()
+ .has(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), interfaceTypeId)
+ .out(GraphEdgeLabels.INTERFACE_OPERATION.getProperty())
+ .toList()
+ .forEach(interfaceOperationVertex -> {
+ traversal.V(interfaceOperationVertex).out(GraphEdgeLabels.PROPERTY.getProperty()).drop().iterate();
+ interfaceOperationVertex.remove();
+ });
+ traversal.V().has(GraphPropertiesDictionary.UNIQUE_ID.getProperty(), interfaceTypeId).toList()
+ .forEach(interfaceTypeVertex -> {
+ traversal.V(interfaceTypeVertex).out(GraphEdgeLabels.PROPERTY.getProperty()).drop().iterate();
+ interfaceTypeVertex.remove();
+ });
+ } catch (Exception e) {
+ log.error("Failed to delete interface type {} and interface operations in graph. {}", interfaceTypeId, e);
+ }
+ }
+
+ public void removeInterfaceTypeFromAdditionalType(InterfaceDefinition interfaceDefinition) {
+ modelOperation.removeTypeFromAdditionalType(ElementTypeEnum.INTERFACE_LIFECYCLE_TYPE, interfaceDefinition.getModel(),
+ interfaceDefinition.getType());
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
index b57c57a9cc..785ca41033 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ModelOperation.java
@@ -457,7 +457,7 @@ public class ModelOperation {
toscaModelImportCassandraDao.saveAll(modelName, rebuiltModelImportList);
}
- public void removeDataTypeFromAdditionalType(final ElementTypeEnum elementTypeEnum, final String modelName, final String name) {
+ public void removeTypeFromAdditionalType(final ElementTypeEnum elementTypeEnum, final String modelName, final String name) {
final List<ToscaImportByModel> modelImportList = toscaModelImportCassandraDao.findAllByModel(modelName);
final Optional<ToscaImportByModel> additionalTypeDefinitionsImportOptional = modelImportList.stream()
.filter(t -> ADDITIONAL_TYPE_DEFINITIONS_PATH.equals(Path.of(t.getFullPath()))).findAny();