Skip to content

Instantly share code, notes, and snippets.

@bshambaugh
Last active April 6, 2018 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bshambaugh/d62a07e468246509ab701de36e6927d1 to your computer and use it in GitHub Desktop.
Save bshambaugh/d62a07e468246509ab701de36e6927d1 to your computer and use it in GitHub Desktop.
How do I output John and Bob???
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.tinkerpop.gremlin.process.traversal.Order;
import org.apache.tinkerpop.gremlin.process.traversal.Path;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.umlg.sqlg.predicate.Text;
import org.umlg.sqlg.structure.SqlgGraph;
import java.util.Iterator;
import java.util.List;
public class GremlinJenaTest4 {
public static void main(String[] arg) {
BaseConfiguration conf = new BaseConfiguration();
conf.setProperty("jdbc.url", "jdbc:postgresql://localhost:5432/sqlgraphdb");
conf.setProperty("jdbc.username", "batman");
conf.setProperty("jdbc.password", "password");
Graph g = SqlgGraph.open(conf);
Vertex john = g.addVertex(T.label, "Manager", "name", "john");
Vertex bob = g.addVertex(T.label, "Manager", "name", "bob");
g.tx().commit();
List<Vertex> persons = g.traversal().V().hasLabel("Manager").toList();
// How do I grab john and bob???
for (Vertex path : persons) {
System.out.println(path);
}
try {
g.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment