* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2024 DEUTSCHE TELEKOM AG.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
package org.onap.aai.serialization.engines;
-import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
+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.__;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.InlineFilterStrategy;
-import org.apache.tinkerpop.gremlin.process.traversal.strategy.optimization.LazyBarrierStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
public QueryBuilder<Vertex> getQueryBuilder(QueryStyle style, Loader loader) {
GraphTraversalSource source = this.asAdmin().getTraversalSource();
- if (style.equals(QueryStyle.GREMLIN_TRAVERSAL)) {
- return new GremlinTraversal<>(loader, source);
- } else if (style.equals(QueryStyle.GREMLIN_UNIQUE)) {
- return new GremlinUnique<>(loader, source);
- } else if (style.equals(QueryStyle.GREMLINPIPELINE_TRAVERSAL)) {
- // return new GremlinPipelineTraversal(loader);
- } else if (style.equals(QueryStyle.TRAVERSAL)) {
- return new TraversalQuery<>(loader, source != null ? source.withoutStrategies(InlineFilterStrategy.class) : source);
- } else if (style.equals(QueryStyle.TRAVERSAL_URI)) {
- return new TraversalURIOptimizedQuery<>(loader, source != null ? source.withoutStrategies(InlineFilterStrategy.class) : source);
- } else if (style.equals(QueryStyle.HISTORY_TRAVERSAL)) {
- throw new IllegalArgumentException("History Traversal needs history traversal source");
- } else if (style.equals(QueryStyle.HISTORY_GREMLIN_TRAVERSAL)) {
- throw new IllegalArgumentException("History Gremlin Traversal needs history traversal source");
- } else {
- throw new IllegalArgumentException("Query Builder type not recognized");
- }
- return queryBuilder;
+ return this.getQueryBuilder(style, loader, source);
}
public QueryBuilder<Vertex> getQueryBuilder(QueryStyle style, Loader loader, GraphTraversalSource source) {
+ return this.getQueryBuilder(style, loader, source, (GraphTraversal<Vertex, Vertex>) __.<Vertex>start());
+ }
+
+ public QueryBuilder<Vertex> getQueryBuilder(QueryStyle style, Loader loader, GraphTraversalSource source, GraphTraversal<Vertex, Vertex> traversal) {
if (style.equals(QueryStyle.GREMLIN_TRAVERSAL)) {
return new GremlinTraversal<>(loader, source);
} else if (style.equals(QueryStyle.GREMLIN_UNIQUE)) {
} else if (style.equals(QueryStyle.GREMLINPIPELINE_TRAVERSAL)) {
// return new GremlinPipelineTraversal(loader);
} else if (style.equals(QueryStyle.TRAVERSAL)) {
- return new TraversalQuery<>(loader, source);
+ return new TraversalQuery<>(loader, source != null ? source.withoutStrategies(InlineFilterStrategy.class) : source, traversal);
} else if (style.equals(QueryStyle.TRAVERSAL_URI)) {
- return new TraversalURIOptimizedQuery<>(loader, source);
+ return new TraversalURIOptimizedQuery<>(loader, source != null ? source.withoutStrategies(InlineFilterStrategy.class) : source);
} else if (style.equals(QueryStyle.HISTORY_TRAVERSAL)) {
return new HistoryTraversalURIOptimizedQuery<>(loader, source);
} else if (style.equals(QueryStyle.HISTORY_GREMLIN_TRAVERSAL)) {