Search in sources :

Example 1 with FulgoraElementTraversal

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();
}
Also used : Graph(org.apache.tinkerpop.gremlin.structure.Graph) TitanBlueprintsGraph(com.thinkaurelius.titan.graphdb.tinkerpop.TitanBlueprintsGraph) FulgoraElementTraversal(com.thinkaurelius.titan.graphdb.olap.computer.FulgoraElementTraversal) TitanTransaction(com.thinkaurelius.titan.core.TitanTransaction) TitanBlueprintsGraph(com.thinkaurelius.titan.graphdb.tinkerpop.TitanBlueprintsGraph)

Aggregations

TitanTransaction (com.thinkaurelius.titan.core.TitanTransaction)1 FulgoraElementTraversal (com.thinkaurelius.titan.graphdb.olap.computer.FulgoraElementTraversal)1 TitanBlueprintsGraph (com.thinkaurelius.titan.graphdb.tinkerpop.TitanBlueprintsGraph)1 Graph (org.apache.tinkerpop.gremlin.structure.Graph)1