}
private static void removeNodes(GraphDatabaseService graphDatabaseService, boolean includeReferenceNode) {
GraphDatabaseAPI api = (GraphDatabaseAPI) graphDatabaseService;
NodeManager nodeManager = api.getDependencyResolver().resolveDependency(NodeManager.class);
final GlobalGraphOperations globalGraphOperations = GlobalGraphOperations.at(graphDatabaseService);
for (Node node : globalGraphOperations.getAllNodes()) {
for (Relationship rel : node.getRelationships(Direction.OUTGOING)) {
try {
if (nodeManager.isDeleted(rel)) continue;
rel.delete();
} catch(IllegalStateException ise) {
if (!ise.getMessage().contains("since it has already been deleted")) throw ise;
}
}
for (Label label: node.getLabels()) {
node.removeLabel(label);
}
}
for (Node node : globalGraphOperations.getAllNodes()) {
try {
if (nodeManager.isDeleted(node)) continue;
node.delete();
} catch(IllegalStateException ise) {
if (!ise.getMessage().contains("since it has already been deleted")) throw ise;