Skip to content

Instantly share code, notes, and snippets.

@amorgner
Created March 21, 2013 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amorgner/5217550 to your computer and use it in GitHub Desktop.
Save amorgner/5217550 to your computer and use it in GitHub Desktop.
Services.command(SecurityContext.getSuperUserInstance(), TransactionCommand.class).execute(new StructrTransaction() {
@Override
public Object execute() throws FrameworkException {
for (Node node : IteratorUtil.asIterable(nodes)) {
final List<Relationship> references = ImmutableList.copyOf(node.getRelationships(Direction.INCOMING, new RelationshipType() {
@Override
public String name() {
return RELATIONSHIP_TYPE;
}
}));
for (int i = 1; i < references.size(); i++) {
final Relationship reference = references.get(i);
logger.log(Level.INFO, "Deleting reference {0} between {1} and {2}", new Object[] { reference.getId(), reference.getStartNode().getId(),
reference.getEndNode().getId() });
reference.delete();
}
}
return null;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment