diff options
author | franciscovila <javier.paradela.vila@est.tech> | 2022-04-26 18:06:03 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-04-28 12:26:09 +0000 |
commit | cee79dd87db512691b7f3fde339635a1ca8632e7 (patch) | |
tree | a4c8f4f79d1f3b162aa4168465fe228c58e97dca /catalog-dao/src | |
parent | 4b7564241a1d9bf322764a905c3e80215a026b15 (diff) |
Support deletion of archived VFs in SDC BE
Support deletion of archived VFs in SDC BE
Issue-ID: SDC-3973
Signed-off-by: franciscovila <javier.paradela.vila@est.tech>
Change-Id: I0bb18e627c026b794609c2a57806c7a4f925741b
Diffstat (limited to 'catalog-dao/src')
-rw-r--r-- | catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphDao.java | 36 |
1 files changed, 36 insertions, 0 deletions
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<GraphVertex> findAllVertexByInvariantUuid(final String invariantUuid, + final Map<GraphPropertyEnum, Object> additionalPropertiesToMatch) { + final Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class); + if (MapUtils.isNotEmpty(additionalPropertiesToMatch)) { + propertiesToMatch.putAll(additionalPropertiesToMatch); + } + propertiesToMatch.put(GraphPropertyEnum.INVARIANT_UUID, invariantUuid); + final Either<List<GraphVertex>, 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<GraphVertex> 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); |