use of org.neo4j.graphdb.factory.GraphDatabaseFactory in project blueprints by tinkerpop.
the class Neo4jBatchGraph method removeReferenceNodeAndFinalizeKeyIndices.
private void removeReferenceNodeAndFinalizeKeyIndices() {
GraphDatabaseService rawGraphDB = null;
try {
GraphDatabaseBuilder builder = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(this.rawGraph.getStoreDir());
if (this.vertexIndexKeys.size() > 0)
builder.setConfig(GraphDatabaseSettings.node_keys_indexable, vertexIndexKeys.toString().replace("[", "").replace("]", "")).setConfig(GraphDatabaseSettings.node_auto_indexing, GraphDatabaseSetting.TRUE);
if (this.edgeIndexKeys.size() > 0)
builder.setConfig(GraphDatabaseSettings.relationship_keys_indexable, edgeIndexKeys.toString().replace("[", "").replace("]", "")).setConfig(GraphDatabaseSettings.relationship_auto_indexing, GraphDatabaseSetting.TRUE);
rawGraphDB = builder.newGraphDatabase();
Transaction tx = rawGraphDB.beginTx();
try {
rawGraphDB.getReferenceNode().delete();
tx.success();
} catch (Exception e) {
tx.failure();
} finally {
tx.finish();
}
GlobalGraphOperations graphOperations = GlobalGraphOperations.at(rawGraphDB);
if (this.vertexIndexKeys.size() > 0)
populateKeyIndices(rawGraphDB, rawGraphDB.index().getNodeAutoIndexer(), graphOperations.getAllNodes(), Vertex.class);
if (this.edgeIndexKeys.size() > 0)
populateKeyIndices(rawGraphDB, rawGraphDB.index().getRelationshipAutoIndexer(), graphOperations.getAllRelationships(), Edge.class);
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
} finally {
if (rawGraphDB != null)
rawGraphDB.shutdown();
}
}
use of org.neo4j.graphdb.factory.GraphDatabaseFactory in project javaee7-samples by javaee-samples.
the class PersonSessionBean method initDB.
@PostConstruct
private void initDB() {
try {
Path tempDir = Files.createTempDirectory("test-neo4j");
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(tempDir.toString());
try (Transaction tx = graphDb.beginTx()) {
firstNode = graphDb.createNode();
secondNode = graphDb.createNode();
tx.success();
}
} catch (IOException ex) {
Logger.getLogger(PersonSessionBean.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of org.neo4j.graphdb.factory.GraphDatabaseFactory in project neo4j by neo4j.
the class DatabaseRebuildTool method newDbBuilder.
private static GraphDatabaseBuilder newDbBuilder(File path, Args args) {
GraphDatabaseBuilder builder = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(path);
for (Map.Entry<String, String> entry : args.asMap().entrySet()) {
if (entry.getKey().startsWith("D")) {
String key = entry.getKey().substring(1);
String value = entry.getValue();
builder = builder.setConfig(key, value);
}
}
return builder;
}
use of org.neo4j.graphdb.factory.GraphDatabaseFactory in project neo4j by neo4j.
the class LegacyIndexesUpgradeTest method startDatabase.
private GraphDatabaseService startDatabase(boolean allowUpgread) {
GraphDatabaseFactory factory = new TestGraphDatabaseFactory();
GraphDatabaseBuilder builder = factory.newEmbeddedDatabaseBuilder(testDir.graphDbDir());
builder.setConfig(GraphDatabaseSettings.allow_store_upgrade, Boolean.toString(allowUpgread));
builder.setConfig(GraphDatabaseSettings.pagecache_memory, "8m");
return builder.newGraphDatabase();
}
use of org.neo4j.graphdb.factory.GraphDatabaseFactory in project neo4j by neo4j.
the class RestoreDatabaseCommandTest method createDbAt.
private void createDbAt(File fromPath, int nodesToCreate) {
GraphDatabaseFactory factory = new GraphDatabaseFactory();
GraphDatabaseService db = factory.newEmbeddedDatabase(fromPath);
try (Transaction tx = db.beginTx()) {
for (int i = 0; i < nodesToCreate; i++) {
db.createNode();
}
tx.success();
}
db.shutdown();
}
Aggregations