diff options
Diffstat (limited to 'catalog-dao')
-rw-r--r-- | catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java | 8 | ||||
-rw-r--r-- | catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java index 19f78ced24..c6ad5f2c26 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphGenericDao.java @@ -851,7 +851,7 @@ public class JanusGraphGenericDao { public <T extends GraphNode> Either<List<T>, JanusGraphOperationStatus> getByCriteriaWithPredicate(NodeTypeEnum type, Map<String, Entry<JanusGraphPredicate, Object>> props, - Class<T> clazz) { + Class<T> clazz, String modelName) { Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph(); if (graph.isLeft()) { try { @@ -871,7 +871,11 @@ public class JanusGraphGenericDao { if (vertices == null) { return Either.right(JanusGraphOperationStatus.NOT_FOUND); } - Iterator<JanusGraphVertex> iterator = vertices.iterator(); + final Predicate<? super JanusGraphVertex> filterPredicate = + StringUtils.isEmpty(modelName) ? this::vertexNotConnectedToAnyModel : vertex -> vertexValidForModel(vertex, modelName); + final List<JanusGraphVertex> verticesForModel = StreamSupport.stream(vertices.spliterator(), false).filter(filterPredicate) + .collect(Collectors.toList()); + Iterator<JanusGraphVertex> iterator = verticesForModel.iterator(); List<T> result = new ArrayList<>(); while (iterator.hasNext()) { Vertex vertex = iterator.next(); diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java index 1e62a952cf..941e13af6b 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/janusgraph/JanusGraphUtils.java @@ -19,7 +19,6 @@ */ package org.openecomp.sdc.be.dao.janusgraph; -import static java.util.Collections.emptyMap; import static org.apache.commons.collections.CollectionUtils.isEmpty; import static org.janusgraph.core.attribute.Contain.NOT_IN; @@ -36,7 +35,7 @@ public class JanusGraphUtils { public static <T> Map<String, Entry<JanusGraphPredicate, Object>> buildNotInPredicate(String propKey, Collection<T> notInCollection) { if (isEmpty(notInCollection)) { - return emptyMap(); + return new HashMap<>(); } Map<String, Entry<JanusGraphPredicate, Object>> predicateCriteria = new HashMap<>(); predicateCriteria.put(propKey, new HashMap.SimpleEntry<>(NOT_IN, notInCollection)); |