From cee79dd87db512691b7f3fde339635a1ca8632e7 Mon Sep 17 00:00:00 2001 From: franciscovila Date: Tue, 26 Apr 2022 18:06:03 +0100 Subject: Support deletion of archived VFs in SDC BE Support deletion of archived VFs in SDC BE Issue-ID: SDC-3973 Signed-off-by: franciscovila Change-Id: I0bb18e627c026b794609c2a57806c7a4f925741b --- .../sdc/be/dao/janusgraph/JanusGraphDao.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'catalog-dao/src') diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphDao.java index 449a4968e8..ed69992715 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphDao.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphDao.java @@ -24,6 +24,8 @@ import static org.apache.commons.collections.CollectionUtils.isEmpty; import fj.data.Either; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; +import java.util.EnumMap; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -49,6 +51,7 @@ import org.janusgraph.core.JanusGraphVertex; import org.janusgraph.core.JanusGraphVertexQuery; import org.janusgraph.core.PropertyKey; import org.janusgraph.graphdb.query.JanusGraphPredicate; +import org.openecomp.sdc.be.dao.api.exception.JanusGraphException; import org.openecomp.sdc.be.dao.jsongraph.GraphVertex; import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum; import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum; @@ -604,6 +607,39 @@ public class JanusGraphDao { } } + + /** + * Finds the vertices that have the given invariant id and any additional property provided. + * + * @param invariantUuid the invariant uuid + * @param additionalPropertiesToMatch any additional property to match along with the {@link GraphPropertyEnum#INVARIANT_UUID} + * @return the list of vertex that has the given invariant uuid + * @throws JanusGraphException if the find operation was returned an error status + */ + public List findAllVertexByInvariantUuid(final String invariantUuid, + final Map additionalPropertiesToMatch) { + final Map propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class); + if (MapUtils.isNotEmpty(additionalPropertiesToMatch)) { + propertiesToMatch.putAll(additionalPropertiesToMatch); + } + propertiesToMatch.put(GraphPropertyEnum.INVARIANT_UUID, invariantUuid); + final Either, JanusGraphOperationStatus> vertexEither = + getByCriteria(null, propertiesToMatch, JsonParseFlagEnum.ParseMetadata); + if (vertexEither.isRight()) { + final JanusGraphOperationStatus status = vertexEither.right().value(); + if (status == JanusGraphOperationStatus.NOT_FOUND) { + return Collections.emptyList(); + } + final String errorMsg = String.format("Couldn't fetch vertex with invariantUUId '%s'. Status was '%s'", invariantUuid, status); + throw new JanusGraphException(status, errorMsg); + } + final List vertices = vertexEither.left().value(); + if (vertices == null || vertices.isEmpty()) { + return Collections.emptyList(); + } + return vertices; + } + private boolean vertexValidForModel(final JanusGraphVertex vertex, final String model, final boolean includeNormativeExtensions) { final String vertexLabel = (String)vertex.property(GraphPropertyEnum.LABEL.getProperty()).value(); final VertexTypeEnum vertexType = VertexTypeEnum.getByName(vertexLabel); -- cgit 1.2.3-korg