aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/main
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2021-02-05 16:18:52 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-02-21 07:55:36 +0000
commit8cc03e2c78639be5500ab50f3ebaaf7d64404775 (patch)
tree1c4d82ba477c4de058f8817b717deaa2f3f4e877 /catalog-dao/src/main
parent751ac4b93e575c56e29cdbbcf95e0aa899d914a2 (diff)
Update node and data types for SOL001 3.3.1 + CNF enhancements
Types in 2.7.1 folder are types valid for v3.3.1 that have not changed from v2.7.1 Types in 4.1.1 folder are the CNF enhancements which it is assumed will be in v4.1.1 Includes some changes in functionality to support: 1. Deployment of both existing (2.5.1) versions of types and new versions of types through sdc-BE-init 2. Selection of the correct node type definition version at onboarding of an ETSI SOL004 VNF/CNF csar, based on the declared version supported in the csar (i.e. when a 3.3.1 csar is imported, the node type definitions valid for 3.3.1 are used (rather than current logic which always selects the latest version) Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3470 Change-Id: Iff835d230b173b9d44349caa6b0b11d783e8f8d3
Diffstat (limited to 'catalog-dao/src/main')
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java41
1 files changed, 22 insertions, 19 deletions
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
index 729d3c57da..be1dc454f8 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
@@ -21,6 +21,7 @@
package org.openecomp.sdc.be.dao.jsongraph;
import org.janusgraph.core.*;
+import org.janusgraph.graphdb.query.JanusGraphPredicate;
import fj.data.Either;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -461,6 +462,12 @@ public class JanusGraphDao {
}
public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props, Map<GraphPropertyEnum, Object> hasNotProps, JsonParseFlagEnum parseFlag) {
+ return getByCriteria(type, props, hasNotProps, null, parseFlag);
+ }
+
+ public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(final VertexTypeEnum type,
+ final Map<GraphPropertyEnum, Object> hasProps, final Map<GraphPropertyEnum, Object> hasNotProps,
+ final Map<String, Entry<JanusGraphPredicate, Object>> predicates, final JsonParseFlagEnum parseFlag) {
Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
if (graph.isLeft()) {
try {
@@ -471,8 +478,8 @@ public class JanusGraphDao {
query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
}
- if (props != null && !props.isEmpty()) {
- for (Map.Entry<GraphPropertyEnum, Object> entry : props.entrySet()) {
+ if (hasProps != null && !hasProps.isEmpty()) {
+ for (Map.Entry<GraphPropertyEnum, Object> entry : hasProps.entrySet()) {
query = query.has(entry.getKey().getProperty(), entry.getValue());
}
}
@@ -485,40 +492,36 @@ public class JanusGraphDao {
}
}
}
+ if (predicates != null && !predicates.isEmpty()) {
+ for (Map.Entry<String, Entry<JanusGraphPredicate, Object>> entry : predicates.entrySet()) {
+ JanusGraphPredicate predicate = entry.getValue().getKey();
+ Object object = entry.getValue().getValue();
+ query = query.has(entry.getKey(), predicate, object);
+ }
+ }
Iterable<JanusGraphVertex> vertices = query.vertices();
- if (vertices == null) {
+ if (vertices == null || !vertices.iterator().hasNext()) {
return Either.right(JanusGraphOperationStatus.NOT_FOUND);
}
- Iterator<JanusGraphVertex> iterator = vertices.iterator();
List<GraphVertex> result = new ArrayList<>();
-
- while (iterator.hasNext()) {
- JanusGraphVertex vertex = iterator.next();
-
- Map<GraphPropertyEnum, Object> newProp = getVertexProperties(vertex);
- GraphVertex graphVertex = createAndFill(vertex, parseFlag);
-
- result.add(graphVertex);
- }
+ vertices.forEach(vertex -> result.add(createAndFill(vertex, parseFlag)));
+
if (logger.isDebugEnabled()) {
- logger.debug("Number of fetced nodes in graph for criteria : from type = {} and properties = {} is {}", type, props, result.size());
- }
- if (result.size() == 0) {
- return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+ logger.debug("Number of fetched nodes in graph for criteria : from type '{}' and properties '{}' is '{}'", type, hasProps, result.size());
}
return Either.left(result);
} catch (Exception e) {
if (logger.isDebugEnabled()) {
- logger.debug("Failed get by criteria for type = {} and properties = {}", type, props, e);
+ logger.debug("Failed to get by criteria for type '{}' and properties '{}'", type, hasProps, e);
}
return Either.right(JanusGraphClient.handleJanusGraphException(e));
}
} else {
if (logger.isDebugEnabled()) {
- logger.debug("Failed get by criteria for type ={} and properties = {} error : {}", type, props, graph.right().value());
+ logger.debug("Failed to get by criteria for type '{}' and properties '{}'. Error : '{}'", type, hasProps, graph.right().value());
}
return Either.right(graph.right().value());
}