From 9034ac68d20e1cb9f9aeda9ed8445023fca92527 Mon Sep 17 00:00:00 2001 From: Fiete Ostkamp Date: Wed, 6 Mar 2024 07:56:05 +0100 Subject: Update janusgraph to 0.3.3 - update tinkerpop version from 3.2.11 to 3.3.0 - update janusgraph from 0.2.3 to 0.3.3 - the default GraphSON version would change with this update but was held back [1] - add jackson-dataformat-xml dependency to aai-core as the XmlMapper is used in the ErrorLogHelper [1] a separate story AAI-3796 - Use GraphSON v2 or v3 in AAI has been created for this Issue-ID: AAI-3795 Change-Id: I4539e83aa74c260d5238ebe869e9884d4396e9f4 Signed-off-by: Fiete Ostkamp --- .../src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java | 10 ---------- aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java | 1 + .../org/onap/aai/query/builder/GraphTraversalBuilder.java | 11 ++++++++++- .../java/org/onap/aai/query/builder/GremlinQueryBuilder.java | 9 +++++++++ .../main/java/org/onap/aai/query/builder/QueryBuilder.java | 3 +++ .../org/onap/aai/restcore/search/AAIAbstractGroovyShell.java | 2 +- .../org/onap/aai/serialization/queryformats/GraphSON.java | 8 +++++++- 7 files changed, 31 insertions(+), 13 deletions(-) (limited to 'aai-core/src/main/java') diff --git a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java index 6c2eee15..c097a5bf 100644 --- a/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java +++ b/aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java @@ -129,16 +129,6 @@ public final class GraphSONPartialIO this.version = version; } - /** - * @deprecated As of release 3.2.2, replaced by {@link #onMapper(Consumer)}. - */ - @Deprecated - @Override - public Io.Builder registry(final IoRegistry registry) { - this.registry = registry; - return this; - } - @Override public Io.Builder onMapper(final Consumer onMapper) { this.onMapper = onMapper; diff --git a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java index d9994f52..15f57c13 100644 --- a/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java +++ b/aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java @@ -70,6 +70,7 @@ public class AAIGraph { } this.loadGraph(rtConfig, serviceName); } catch (Exception e) { + logger.error("Failed to instantiate graph", e); throw new RuntimeException("Failed to instantiate graphs", e); } } diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java index c5c4512e..24e5ec8b 100644 --- a/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java +++ b/aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java @@ -34,7 +34,7 @@ import java.util.Set; import org.apache.tinkerpop.gremlin.process.traversal.P; import org.apache.tinkerpop.gremlin.process.traversal.Path; -import org.apache.tinkerpop.gremlin.process.traversal.Step; +import org.apache.tinkerpop.gremlin.process.traversal.Pop; 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.GraphTraversal; @@ -688,6 +688,15 @@ public abstract class GraphTraversalBuilder extends QueryBuilder { return this; } + @Override + public QueryBuilder select(Pop pop, String name) { + this.traversal.select(pop, name); + + stepIndex++; + + return this; + } + @Override public QueryBuilder select(String... names) { if (names.length == 1) { diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java index 4500a47e..db1c78ae 100644 --- a/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java +++ b/aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java @@ -29,6 +29,7 @@ import com.google.common.collect.Multimap; import java.util.*; import org.apache.tinkerpop.gremlin.process.traversal.Path; +import org.apache.tinkerpop.gremlin.process.traversal.Pop; 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.step.util.Tree; @@ -827,6 +828,14 @@ public abstract class GremlinQueryBuilder extends QueryBuilder { return this; } + @Override + public QueryBuilder select(Pop pop, String name) { + this.list.add(".select(Pop." + pop.toString() + ",'" + name + "')"); + stepIndex++; + + return this; + } + @Override public QueryBuilder select(String... names) { String stepString = ".select('"; diff --git a/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java b/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java index 66532529..309ffa16 100644 --- a/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java +++ b/aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java @@ -31,6 +31,7 @@ import java.util.Map; import javax.ws.rs.core.MultivaluedMap; import org.apache.tinkerpop.gremlin.process.traversal.Path; +import org.apache.tinkerpop.gremlin.process.traversal.Pop; import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree; import org.apache.tinkerpop.gremlin.structure.Edge; @@ -704,6 +705,8 @@ public abstract class QueryBuilder implements Iterator { public abstract QueryBuilder select(String name); + public abstract QueryBuilder select(Pop pop, String name); + public abstract QueryBuilder select(String... names); public abstract QueryBuilder until(QueryBuilder builder); diff --git a/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java b/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java index 4a8760ec..f63df4b2 100644 --- a/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java +++ b/aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java @@ -59,7 +59,7 @@ public abstract class AAIAbstractGroovyShell { "org.apache.tinkerpop.gremlin.process.traversal.Order"); imports.addImports("org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__", "org.apache.tinkerpop.gremlin.structure.T", "org.apache.tinkerpop.gremlin.process.traversal.P", - "org.onap.aai.edges.enums.EdgeType", "java.util.Map.Entry"); + "org.onap.aai.edges.enums.EdgeType", "java.util.Map.Entry","org.apache.tinkerpop.gremlin.process.traversal.Pop"); imports.addStarImports("java.util"); CompilerConfiguration config = new CompilerConfiguration(); config.addCompilationCustomizers(custom, imports); diff --git a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java index c0ba860f..89970e24 100644 --- a/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java +++ b/aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java @@ -36,6 +36,7 @@ import java.util.Optional; import org.apache.tinkerpop.gremlin.structure.Direction; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONMapper; +import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion; import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONWriter; import org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry; import org.onap.aai.serialization.queryformats.exceptions.AAIFormatQueryResultFormatNotSupported; @@ -47,8 +48,13 @@ public class GraphSON implements FormatMapper { private static final Logger logger = LoggerFactory.getLogger(GraphSON.class); + // TODO: Use v2 or v3 here + // v2 is the default starting from Janusgraph 0.3.0 + // Further reference: https://tinkerpop.apache.org/docs/3.3.0/dev/io/#graphson + private static final GraphSONVersion version = GraphSONVersion.V1_0; + private final GraphSONMapper mapper = - GraphSONMapper.build().addRegistry(JanusGraphIoRegistry.getInstance()).create(); + GraphSONMapper.build().version(version).addRegistry(JanusGraphIoRegistry.getInstance()).create(); private final GraphSONWriter writer = GraphSONWriter.build().mapper(mapper).create(); @Override -- cgit 1.2.3-korg