Search in sources :

Example 1 with Neo4jGraphAPIImpl

use of org.neo4j.tinkerpop.api.impl.Neo4jGraphAPIImpl in project timbuctoo by HuygensING.

the class TinkerPopGraphManager method start.

@Override
public void start() throws Exception {
    synchronized (graphWaitList) {
        initGraphDatabaseService();
        this.graph = Neo4jGraph.open(new Neo4jGraphAPIImpl(graphDatabase));
        new DatabaseMigrator(this, migrations).execute();
        callWaiters();
    }
}
Also used : Neo4jGraphAPIImpl(org.neo4j.tinkerpop.api.impl.Neo4jGraphAPIImpl) DatabaseMigrator(nl.knaw.huygens.timbuctoo.server.databasemigration.DatabaseMigrator)

Example 2 with Neo4jGraphAPIImpl

use of org.neo4j.tinkerpop.api.impl.Neo4jGraphAPIImpl in project timbuctoo by HuygensING.

the class TestGraphBuilder method build.

public Neo4jGraph build() {
    // one is called.
    if (neo4jDb == reusableNeo4jDb) {
        if (trans != null) {
            trans.close();
        }
        cleanDb(neo4jDb);
    }
    Neo4jGraphAPIImpl neo4jGraphApi = new Neo4jGraphAPIImpl(neo4jDb);
    Neo4jGraph neo4jGraph = Neo4jGraph.open(neo4jGraphApi);
    try (org.apache.tinkerpop.gremlin.structure.Transaction tx = neo4jGraph.tx()) {
        final List<RelationData> requestedRelations = new LinkedList<>();
        final Map<String, Vertex> identifiableVertices = new HashMap<>();
        // Create all identifiable vertices
        graphFragmentBuilders.forEach(builder -> {
            Tuple<Vertex, String> result = builder.build(neo4jGraph, requestedRelations::add);
            identifiableVertices.put(result.getRight(), result.getLeft());
        });
        // then we can create the relations between them
        requestedRelations.forEach(relationData -> relationData.makeRelation(identifiableVertices));
        tx.commit();
    }
    if (neo4jDb == reusableNeo4jDb) {
        // we're re-using the database
        // make sure we own the toplevel transaction so are guaranteed to close it
        trans = neo4jDb.beginTx();
    }
    return neo4jGraph;
}
Also used : Neo4jGraphAPIImpl(org.neo4j.tinkerpop.api.impl.Neo4jGraphAPIImpl) Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) HashMap(java.util.HashMap) Neo4jGraph(org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph) LinkedList(java.util.LinkedList)

Aggregations

Neo4jGraphAPIImpl (org.neo4j.tinkerpop.api.impl.Neo4jGraphAPIImpl)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 DatabaseMigrator (nl.knaw.huygens.timbuctoo.server.databasemigration.DatabaseMigrator)1 Neo4jGraph (org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph)1 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)1