aboutsummaryrefslogtreecommitdiffstats
path: root/aai-core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'aai-core/src/main')
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/query/builder/GraphTraversalBuilder.java32
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinQueryBuilder.java18
-rw-r--r--aai-core/src/main/java/org/openecomp/aai/query/builder/QueryBuilder.java9
3 files changed, 52 insertions, 7 deletions
diff --git a/aai-core/src/main/java/org/openecomp/aai/query/builder/GraphTraversalBuilder.java b/aai-core/src/main/java/org/openecomp/aai/query/builder/GraphTraversalBuilder.java
index 73b57d06..72c2efb0 100644
--- a/aai-core/src/main/java/org/openecomp/aai/query/builder/GraphTraversalBuilder.java
+++ b/aai-core/src/main/java/org/openecomp/aai/query/builder/GraphTraversalBuilder.java
@@ -30,7 +30,6 @@ import java.util.Set;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal.Admin;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
@@ -70,7 +69,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
public GraphTraversalBuilder(Loader loader, GraphTraversalSource source) {
super(loader, source);
- traversal = new DefaultGraphTraversal<>();
+ traversal = (GraphTraversal<Vertex, E>) __.<E>start();
}
@@ -83,7 +82,7 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
public GraphTraversalBuilder(Loader loader, GraphTraversalSource source, Vertex start) {
super(loader, source, start);
- traversal = new DefaultGraphTraversal<>();
+ traversal = (GraphTraversal<Vertex, E>) __.__(start);
}
@@ -404,6 +403,24 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
}
@Override
+ public QueryBuilder<E> until(QueryBuilder<E> builder) {
+ this.traversal.until((GraphTraversal<Vertex,E>)builder.getQuery());
+ stepIndex++;
+
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public QueryBuilder<E> simplePath(){
+ this.traversal.simplePath();
+ stepIndex++;
+ return this;
+ }
+
+ @Override
public QueryBuilder<Edge> outE() {
this.traversal.outE();
stepIndex++;
@@ -594,17 +611,18 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
private void executeQuery() {
- Admin<Vertex, Vertex> admin;
+ Admin admin;
if (start != null) {
- admin = source.V(start).asAdmin();
+ this.completeTraversal = traversal.asAdmin();
} else {
admin = source.V().asAdmin();
+ TraversalHelper.insertTraversal(admin.getEndStep(), traversal.asAdmin(), admin);
+
+ this.completeTraversal = (Admin<Vertex, E>) admin;
}
- TraversalHelper.insertTraversal(admin.getEndStep(), traversal.asAdmin(), admin);
- this.completeTraversal = (Admin<Vertex, E>) admin;
}
@Override
diff --git a/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinQueryBuilder.java b/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinQueryBuilder.java
index f93bc484..b151d9d8 100644
--- a/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinQueryBuilder.java
+++ b/aai-core/src/main/java/org/openecomp/aai/query/builder/GremlinQueryBuilder.java
@@ -394,6 +394,24 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
}
@Override
+ public QueryBuilder<E> until(QueryBuilder<E> builder) {
+ this.list.add(".until(__" + builder.getQuery() + ")");
+ stepIndex++;
+
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public QueryBuilder<E> simplePath(){
+ this.list.add(".simplePath()");
+ stepIndex++;
+ return this;
+ }
+
+ @Override
public QueryBuilder<Edge> outE() {
this.list.add(".outE()");
stepIndex++;
diff --git a/aai-core/src/main/java/org/openecomp/aai/query/builder/QueryBuilder.java b/aai-core/src/main/java/org/openecomp/aai/query/builder/QueryBuilder.java
index 009f4fdf..717033fa 100644
--- a/aai-core/src/main/java/org/openecomp/aai/query/builder/QueryBuilder.java
+++ b/aai-core/src/main/java/org/openecomp/aai/query/builder/QueryBuilder.java
@@ -298,6 +298,15 @@ public abstract class QueryBuilder<E> implements Iterator<E> {
public abstract QueryBuilder<E> not(QueryBuilder<E> builder);
public abstract QueryBuilder<E> as(String name);
public abstract QueryBuilder<E> select(String name);
+ public abstract QueryBuilder<E> until(QueryBuilder<E> builder);
+
+ /**
+ * Used to prevent the traversal from repeating its path through the graph.
+ * See http://tinkerpop.apache.org/docs/3.0.1-incubating/#simplepath-step for more info.
+ *
+ * @return a QueryBuilder with the simplePath step appended to its traversal
+ */
+ public abstract QueryBuilder<E> simplePath();
public abstract void markContainer();