Database Reference
In-Depth Information
// was this content also the last post?
if (content.getContentId().equals(currentPost.getContentId())) {
// get the next post
// remove the rel between currentpost and profile
neo4jTemplate.deleteRelationshipBetween
(user, content,
GraphStoryConstants.CURRENTPOST);
// remove the rel between currentpost and next post
if (content.getNext() != null) {
Content nextPost =
contentRepository.findOne
(content.getNext().getNodeId());
neo4jTemplate.deleteRelationshipBetween
(content, nextPost,
GraphStoryConstants.NEXTPOST);
// make nextpost the currentpost
neo4jTemplate.createRelationshipBetween
(
neo4jTemplate.getNode(user.getNodeId()), neo4jTemplate.getNode(nextPost.
getNodeId()), GraphStoryConstants.CURRENTPOST, null);
// set the profile
nextPost.setUser(user);
// save it
contentRepository.save
(nextPost);
}
}
// OK, then this is NEXT content
else
{
// is next to currentpost?
if (currentPost.getNext().getNodeId().equals(content.getNodeId())) {
// remove the rel between currentpost and the next to last content
neo4jTemplate.deleteRelationshipBetween
(currentPost, content,
GraphStoryConstants.NEXTPOST);
if (content.getNext().getNodeId() != null) {
// get the next content
Content newNextToLastPost =
contentRepository.findOne
(content.
getNext().getNodeId());
// remove the rel between the now former next to last content and
// new next to last content
neo4jTemplate.deleteRelationshipBetween
(content,
newNextToLastPost, GraphStoryConstants.NEXTPOST);