Database Reference
In-Depth Information
// create rel bewteen the last content and
// now new next to last content
neo4jTemplate.createRelationshipBetween
(
neo4jTemplate.getNode(currentPost.getNodeId()),
neo4jTemplate.getNode(newNextToLastPost.getNodeId()),
GraphStoryConstants.NEXTPOST, null
)
;
// set the next
currentPost.setNext(newNextToLastPost);
// save it
contentRepository.save
(currentPost);
}
} else {
Content previousPost =
contentRepository.prevpost
(content.getNodeId());
// remove the rel between prevpost and content
neo4jTemplate.deleteRelationshipBetween(
previousPost, content,
GraphStoryConstants.NEXTPOST
)
;
if (content.getNext().getNodeId() != null) {
Content newNextPost =
contentRepository.findOne
(content.getNext().getNodeId());
neo4jTemplate.deleteRelationshipBetween(
content, newNextPost,
GraphStoryConstants.NEXTPOST
);
neo4jTemplate.createRelationshipBetween(
neo4jTemplate.getNode(previousPost.getNodeId()),
neo4jTemplate.getNode(newNextPost.getNodeId()),
GraphStoryConstants.NEXTPOST, null
)
;
// set the next
previousPost.setNext(newNextPost);
// save it
contentRepository.save
(previousPost);
}
}
}
// delete the content
neo4jTemplate.delete
(content);
}