use of org.neo4j.tooling.GlobalGraphOperations 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.tooling.GlobalGraphOperations in project blueprints by tinkerpop.
the class Neo4j2BatchGraph 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, "true");
if (this.edgeIndexKeys.size() > 0)
builder.setConfig(GraphDatabaseSettings.relationship_keys_indexable, edgeIndexKeys.toString().replace("[", "").replace("]", "")).setConfig(GraphDatabaseSettings.relationship_auto_indexing, "true");
rawGraphDB = builder.newGraphDatabase();
Transaction tx = rawGraphDB.beginTx();
try {
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);
tx.success();
} finally {
tx.close();
}
} catch (Exception e) {
throw new RuntimeException(e.getMessage(), e);
} finally {
if (rawGraphDB != null)
rawGraphDB.shutdown();
}
}
Aggregations