use of com.thinkaurelius.titan.graphdb.olap.computer.FulgoraElementTraversal in project titan by thinkaurelius.
the class TitanTraversalUtil method getTx.
public static TitanTransaction getTx(Traversal.Admin<?, ?> traversal) {
TitanTransaction tx = null;
Optional<Graph> optGraph = TraversalHelper.getRootTraversal(traversal.asAdmin()).getGraph();
if (traversal instanceof FulgoraElementTraversal) {
tx = (TitanTransaction) optGraph.get();
} else {
if (!optGraph.isPresent())
throw new IllegalArgumentException("Traversal is not bound to a graph: " + traversal);
Graph graph = optGraph.get();
if (graph instanceof TitanTransaction)
tx = (TitanTransaction) graph;
else if (graph instanceof TitanBlueprintsGraph)
tx = ((TitanBlueprintsGraph) graph).getCurrentThreadTx();
else
throw new IllegalArgumentException("Traversal is not bound to a Titan Graph, but: " + graph);
}
if (tx == null)
throw new IllegalArgumentException("Not a valid start step for a Titan traversal: " + traversal);
if (tx.isOpen())
return tx;
else
return ((StandardTitanTx) tx).getNextTx();
}
Aggregations