Search in sources :

Example 1 with UnitOfWork

use of org.neo4j.server.helpers.UnitOfWork in project neo4j by neo4j.

the class NeoServerJAXRSIT method createSimpleDatabase.

private int createSimpleDatabase(final GraphDatabaseAPI graph) {
    final int numberOfNodes = 10;
    new Transactor(graph, new UnitOfWork() {

        @Override
        public void doWork() {
            for (int i = 0; i < numberOfNodes; i++) {
                graph.createNode();
            }
            for (Node n1 : graph.getAllNodes()) {
                for (Node n2 : graph.getAllNodes()) {
                    if (n1.equals(n2)) {
                        continue;
                    }
                    n1.createRelationshipTo(n2, RelationshipType.withName("REL"));
                }
            }
        }
    }).execute();
    return numberOfNodes;
}
Also used : UnitOfWork(org.neo4j.server.helpers.UnitOfWork) Node(org.neo4j.graphdb.Node) Transactor(org.neo4j.server.helpers.Transactor)

Aggregations

Node (org.neo4j.graphdb.Node)1 Transactor (org.neo4j.server.helpers.Transactor)1 UnitOfWork (org.neo4j.server.helpers.UnitOfWork)1