summaryrefslogtreecommitdiffstats
path: root/aai-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'aai-core/src')
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbgen/GraphSONPartialIO.java10
-rw-r--r--aai-core/src/main/java/org/onap/aai/dbmap/AAIGraph.java1
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/GraphTraversalBuilder.java11
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/GremlinQueryBuilder.java9
-rw-r--r--aai-core/src/main/java/org/onap/aai/query/builder/QueryBuilder.java3
-rw-r--r--aai-core/src/main/java/org/onap/aai/restcore/search/AAIAbstractGroovyShell.java2
-rw-r--r--aai-core/src/main/java/org/onap/aai/serialization/queryformats/GraphSON.java8
-rw-r--r--aai-core/src/test/java/org/onap/aai/TinkerpopUpgradeTests.java4
-rw-r--r--aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java14
9 files changed, 42 insertions, 20 deletions
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<GraphSONPartialIO> registry(final IoRegistry registry) {
- this.registry = registry;
- return this;
- }
-
@Override
public Io.Builder<? extends Io> onMapper(final Consumer<Mapper.Builder> 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;
@@ -689,6 +689,15 @@ public abstract class GraphTraversalBuilder<E> extends QueryBuilder<E> {
}
@Override
+ public QueryBuilder<E> select(Pop pop, String name) {
+ this.traversal.select(pop, name);
+
+ stepIndex++;
+
+ return this;
+ }
+
+ @Override
public QueryBuilder<E> select(String... names) {
if (names.length == 1) {
this.traversal.select(names[0]);
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;
@@ -828,6 +829,14 @@ public abstract class GremlinQueryBuilder<E> extends QueryBuilder<E> {
}
@Override
+ public QueryBuilder<E> select(Pop pop, String name) {
+ this.list.add(".select(Pop." + pop.toString() + ",'" + name + "')");
+ stepIndex++;
+
+ return this;
+ }
+
+ @Override
public QueryBuilder<E> select(String... names) {
String stepString = ".select('";
for (int i = 0; i < names.length; i++) {
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<E> implements Iterator<E> {
public abstract QueryBuilder<E> select(String name);
+ public abstract QueryBuilder<E> select(Pop pop, String name);
+
public abstract QueryBuilder<E> select(String... names);
public abstract QueryBuilder<E> until(QueryBuilder<E> 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
diff --git a/aai-core/src/test/java/org/onap/aai/TinkerpopUpgradeTests.java b/aai-core/src/test/java/org/onap/aai/TinkerpopUpgradeTests.java
index 799f6060..f443b308 100644
--- a/aai-core/src/test/java/org/onap/aai/TinkerpopUpgradeTests.java
+++ b/aai-core/src/test/java/org/onap/aai/TinkerpopUpgradeTests.java
@@ -24,6 +24,7 @@ import org.junit.experimental.categories.Categories;
import org.junit.experimental.categories.Categories.IncludeCategory;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
+import org.onap.aai.db.DbMethHelperTest;
import org.onap.aai.introspection.sideeffect.DataLinkTest;
import org.onap.aai.parsers.query.GraphTraversalTest;
import org.onap.aai.query.builder.TraversalQueryTest;
@@ -45,7 +46,8 @@ import org.onap.aai.query.builder.TraversalURIOptimizedQueryTest;
DataLinkTest.class,
GraphTraversalTest.class,
TraversalQueryTest.class,
- TraversalURIOptimizedQueryTest.class
+ TraversalURIOptimizedQueryTest.class,
+ DbMethHelperTest.class
})
public class TinkerpopUpgradeTests {
}
diff --git a/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java b/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java
index 16faa5f1..c79b9148 100644
--- a/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java
+++ b/aai-core/src/test/java/org/onap/aai/db/DbMethHelperTest.java
@@ -36,6 +36,7 @@ import org.apache.commons.io.IOUtils;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
import org.janusgraph.core.JanusGraphFactory;
import org.junit.After;
import org.junit.AfterClass;
@@ -44,10 +45,12 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.onap.aai.AAISetup;
+import org.onap.aai.TinkerpopUpgrade;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.Loader;
@@ -62,6 +65,7 @@ import org.onap.aai.setup.SchemaVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.DirtiesContext;
+@Category(TinkerpopUpgrade.class)
@RunWith(value = Parameterized.class)
@DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS)
public class DbMethHelperTest extends AAISetup {
@@ -127,12 +131,10 @@ public class DbMethHelperTest extends AAISetup {
map.put("pserver.hostname", "testSearchVertexByIdentityMap-pserver-hostname-01");
Optional<Vertex> optionalVertex;
- try {
- optionalVertex = dbMethHelper.searchVertexByIdentityMap(type, map);
- } catch (Exception e) {
- throw new Exception(e);
- }
- Assert.assertEquals("vp[hostname->testSearchVertexById]", optionalVertex.get().property("hostname").toString());
+ optionalVertex = dbMethHelper.searchVertexByIdentityMap(type, map);
+
+ String hostname = (String) optionalVertex.get().property("hostname").value();
+ Assert.assertEquals("testSearchVertexByIdentityMap-pserver-hostname-01", hostname);
}
@Test(expected = AmbiguousMapAAIException.class)