Search in sources :

Example 1 with IdGraph

use of com.tinkerpop.blueprints.util.wrappers.id.IdGraph in project pentaho-metaverse by pentaho.

the class SynchronizedGraphFactory method wrapGraph.

/**
 * Wraps the underlying graph with a synchronized one
 * @param graph The graph to wrap
 * @return The synchronized graph
 */
protected static Graph wrapGraph(Graph graph) {
    if (graph instanceof KeyIndexableGraph) {
        KeyIndexableGraph keyIndexableGraph = (KeyIndexableGraph) graph;
        IdGraph<KeyIndexableGraph> idGraph = new IdGraph<KeyIndexableGraph>(keyIndexableGraph);
        return new SynchronizedGraph(idGraph);
    } else {
        throw new IllegalArgumentException(Messages.getString("ERROR.BackingGraph.MustImplement.KeyIndexableGraph"));
    }
}
Also used : KeyIndexableGraph(com.tinkerpop.blueprints.KeyIndexableGraph) IdGraph(com.tinkerpop.blueprints.util.wrappers.id.IdGraph)

Example 2 with IdGraph

use of com.tinkerpop.blueprints.util.wrappers.id.IdGraph in project pentaho-metaverse by pentaho.

the class SynchronizedGraphFactoryTest method testWrapGraph.

@Test
public void testWrapGraph() throws Exception {
    Graph g = new TinkerGraph();
    SynchronizedGraph wrapped = (SynchronizedGraph) SynchronizedGraphFactory.wrapGraph(g);
    assertTrue(wrapped instanceof SynchronizedGraph);
    assertTrue(wrapped.graph instanceof IdGraph);
    assertTrue(wrapped.graph instanceof KeyIndexableGraph);
}
Also used : TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) Graph(com.tinkerpop.blueprints.Graph) KeyIndexableGraph(com.tinkerpop.blueprints.KeyIndexableGraph) IdGraph(com.tinkerpop.blueprints.util.wrappers.id.IdGraph) TinkerGraph(com.tinkerpop.blueprints.impls.tg.TinkerGraph) KeyIndexableGraph(com.tinkerpop.blueprints.KeyIndexableGraph) IdGraph(com.tinkerpop.blueprints.util.wrappers.id.IdGraph) Test(org.junit.Test)

Aggregations

KeyIndexableGraph (com.tinkerpop.blueprints.KeyIndexableGraph)2 IdGraph (com.tinkerpop.blueprints.util.wrappers.id.IdGraph)2 Graph (com.tinkerpop.blueprints.Graph)1 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)1 Test (org.junit.Test)1