Commit 8e40ab15 by Graham Wallis Committed by Sarath Subramanian

ATLAS-2242: Gremlin3 traversals for discovery service

parent 3b597fb5
...@@ -46,9 +46,9 @@ public class AtlasGremlin3QueryProvider extends AtlasGremlin2QueryProvider { ...@@ -46,9 +46,9 @@ public class AtlasGremlin3QueryProvider extends AtlasGremlin2QueryProvider {
"emit(has('__superTypeNames').and().properties('__superTypeNames').hasValue('DataSet'))." + "emit(has('__superTypeNames').and().properties('__superTypeNames').hasValue('DataSet'))." +
"path().toList()"; "path().toList()";
case GREMLIN_SEARCH_RETURNS_VERTEX_ID: case GREMLIN_SEARCH_RETURNS_VERTEX_ID:
return "g.V().range(0,1).valueMap(true).toList()"; return "g.V().range(0,1).toList()";
case GREMLIN_SEARCH_RETURNS_EDGE_ID: case GREMLIN_SEARCH_RETURNS_EDGE_ID:
return "g.E().range(0,1).valueMap(true).toList()"; return "g.E().range(0,1).toList()";
} }
return super.getQuery(gremlinQuery); return super.getQuery(gremlinQuery);
} }
......
...@@ -239,8 +239,7 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { ...@@ -239,8 +239,7 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
gremlinQueryProvider = AtlasGremlinQueryProvider.INSTANCE; gremlinQueryProvider = AtlasGremlinQueryProvider.INSTANCE;
// For tinkerpop2 this query was g.V.range(0,0).collect() // For tinkerpop2 this query was g.V.range(0,0).collect()
// For tinkerpop3 it should be g.V().range(0,1),valueMap(true).toList() // For tinkerpop3 it should be g.V().range(0,1).toList()
// List<Map<String,String>> gremlinResults = discoveryService.searchByGremlin("g.V().range(0,1).valueMap(true).toList()");
final String query = gremlinQueryProvider.getQuery(AtlasGremlinQuery.GREMLIN_SEARCH_RETURNS_VERTEX_ID); final String query = gremlinQueryProvider.getQuery(AtlasGremlinQuery.GREMLIN_SEARCH_RETURNS_VERTEX_ID);
List<Map<String,String>> gremlinResults = discoveryService.searchByGremlin(query); List<Map<String,String>> gremlinResults = discoveryService.searchByGremlin(query);
...@@ -259,8 +258,7 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { ...@@ -259,8 +258,7 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
gremlinQueryProvider = AtlasGremlinQueryProvider.INSTANCE; gremlinQueryProvider = AtlasGremlinQueryProvider.INSTANCE;
// For tinkerpop2 this query was g.E.range(0,0).collect() // For tinkerpop2 this query was g.E.range(0,0).collect()
// For tinkerpop3 it should be g.E().range(0,1),valueMap(true).toList() // For tinkerpop3 it should be g.E().range(0,1).toList()
// List<Map<String,String>> gremlinResults = discoveryService.searchByGremlin("g.E().range(0,1).valueMap(true).toList()");
final String query = gremlinQueryProvider.getQuery(AtlasGremlinQuery.GREMLIN_SEARCH_RETURNS_EDGE_ID); final String query = gremlinQueryProvider.getQuery(AtlasGremlinQuery.GREMLIN_SEARCH_RETURNS_EDGE_ID);
List<Map<String,String>> gremlinResults = discoveryService.searchByGremlin(query); List<Map<String,String>> gremlinResults = discoveryService.searchByGremlin(query);
...@@ -268,6 +266,8 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest { ...@@ -268,6 +266,8 @@ public class GraphBackedDiscoveryServiceTest extends BaseRepositoryTest {
Map<String, String> properties = gremlinResults.get(0); Map<String, String> properties = gremlinResults.get(0);
Assert.assertTrue(properties.containsKey(GraphBackedDiscoveryService.GREMLIN_ID_KEY)); Assert.assertTrue(properties.containsKey(GraphBackedDiscoveryService.GREMLIN_ID_KEY));
Assert.assertTrue(properties.containsKey(GraphBackedDiscoveryService.GREMLIN_LABEL_KEY)); Assert.assertTrue(properties.containsKey(GraphBackedDiscoveryService.GREMLIN_LABEL_KEY));
Assert.assertTrue(properties.containsKey(GraphBackedDiscoveryService.GREMLIN_INVERTEX_KEY));
Assert.assertTrue(properties.containsKey(GraphBackedDiscoveryService.GREMLIN_OUTVERTEX_KEY));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment