Database Reference
In-Depth Information
Listing 12-36. Get the Content of the User's Being Followed Based on a Tag
public List<MappedContent> getContentByTag(String username, String tag, Boolean isCurrentUser) {
List<MappedContent> contents = null;
ResultSetMapper<MappedContent> mappedContentResultSetMapper = new
ResultSetMapper<MappedContent>();
try {
if (isCurrentUser) {
// this block is shown in Listing 12-33
} else {
ResultSet rs = cypher.resultSetQuery(
" MATCH (u:User {username: {1} })" +
" WITH u " +
" MATCH (u)-[:FOLLOWS]->f" +
" WITH DISTINCT f" +
" MATCH f-[:CURRENTPOST]-lp-[:NEXTPOST*0..]-p" +
" WITH DISTINCT f,p" +
" MATCH p-[:HAS]-(t:Tag {wordPhrase : {2} } )" +
" RETURN p.contentId as contentId, p.title as title, p.tagstr as tagstr, " +
" p.timestamp as timestamp, p.url as url, " +
" f.username as username, false as owner " +
" ORDER BY p.timestamp DESC",
map("1", username, "2", tag));
contents = mappedContentResultSetMapper
.mapResultSetToListMappedClass(rs, MappedContent.class);
}
}
catch (Exception e) {
log.error(e);
}
return contents;
}
 
Search WWH ::




Custom Search