Database Reference
In-Depth Information
The userTags method is similar but is concerned only with content and, subsequently, tags connected to the
current user. Both methods limit the results to 30 items. As mentioned earlier, the methods return an array of content and
tags , which supports the autosuggest plugin in the view and requires both a label and name to be provided in order to
execute. This autosuggest feature is also used in the status update form and search forms presented later in this chapter.
Listing 12-34. userTags and tagsInNetwork in the TagDAO Class
// returns just the current user's tags
public List<MappedContentTag> userTags(String username) throws Exception {
ResultSet rs = cypher.resultSetQuery(
" MATCH (u:User {username: {1} })-[:CURRENTPOST]-lp-[:NEXTPOST*0..]-c " +
" WITH distinct c " +
" MATCH c-[ct:HAS]->(t) " +
" WITH distinct ct,t " +
" RETURN t.wordPhrase as name, t.wordPhrase as label, count(ct) as id " +
" ORDER BY id desc " +
" SKIP 0 LIMIT 30",
map("1", username));
ResultSetMapper<MappedContentTag> resultSetMapper =
new ResultSetMapper<MappedContentTag>();
return resultSetMapper.mapResultSetToListMappedClass(rs, MappedContentTag.class);
}
// returns tags of the users being followed
public List<MappedContentTag> tagsInNetwork(String username) throws Exception {
ResultSet rs = cypher.resultSetQuery(
" MATCH (u:User {username: {1} })-[:FOLLOWS]->f " +
" WITH distinct f " +
" MATCH f-[:CURRENTPOST]-lp-[:NEXTPOST*0..]-c " +
" WITH distinct c " +
" MATCH c-[ct:HAS]->(t) " +
" WITH distinct ct,t " +
" RETURN t.wordPhrase as name, t.wordPhrase as label, count(ct) as id " +
" ORDER BY id desc " +
" SKIP 0 LIMIT 30",
map("1", username));
ResultSetMapper<MappedContentTag> resultSetMapper =
new ResultSetMapper<MappedContentTag>();
return resultSetMapper.mapResultSetToListMappedClass(rs, MappedContentTag.class);
}
Filtering Managed Content
Once the list of tags for the user and for the group she follows has been provided, the content can be filtered based
of the generated tag links, as shown in Figure 12-12 . If a tag is clicked on inside of the “My Interests” section, the
getContentByTag method, displayed in Listing 12-35, is called with the isCurrentUser value set to true.
 
Search WWH ::




Custom Search