Database Reference
In-Depth Information
Listing 12-35. Get the Content Owned by the Current User 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) {
ResultSet rs = cypher.resultSetQuery(
"MATCH (u:User {username: {1} })" +
" MATCH u-[:CURRENTPOST]-lp-[:NEXTPOST*0..]-p " +
" WITH DISTINCT u,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, " +
" u.username as username, true as owner" +
" ORDER BY p.timestamp DESC",
map("1", username, "2", tag));
contents = mappedContentResultSetMapper
.mapResultSetToListMappedClass(rs, MappedContent.class);
} else {
// this block is shown in Listing 12-34
}
}
catch (Exception e) {
log.error(e);
}
return contents;
}
Filtering Connected Content
If a tag is clicked on inside of the “Interests in my Network” section, the getContentByTag method is called with the
isCurrentUser value set to false, as shown in Listing (Listing 12-36)
The second query is nearly identical to the first query found in getContentByTag , except that it will factor in
the users being followed and exclude the current user. The method also returns a collection of items and matches
resulting content to a provided tag, placing no limit on the number of status updates to be returned (Figure 12-13 ). In
addition, it marks the owner property as false.
 
Search WWH ::




Custom Search