Database Reference
In-Depth Information
Listing 11-43. getContentByTag in ContentImpl
public List<MappedContent> getContentByTag (String username, String tag, Boolean getuserscontent) {
if (getuserscontent) {
return mappedContentRepository.getUserContentWithTag (username, tag);
} else {
return mappedContentRepository.getFollowingContentWithTag (username, tag);
}
}
In turn, this will call the getUserContentWithTag , shown in listing 11-44. Similarly to the query for the
getContent method in MappedContentRepository , the query for getUserContentWithTag returns a collection of
MappedContent items, but matches resulting content to a provide tag, via @Param("wp") , and places no limit on the
number of status updates to be returned. In addition, it marks the owner property as true, because we've determined
ahead of time we are only returning the current user's content.
Listing 11-44. getUserContentWithTag in the MappedContentRepository
@Query("MATCH (u:User {username: {u} })" +
" MATCH u-[:CURRENTPOST]-lp-[:NEXTPOST*0..]-p " +
" WITH DISTINCT u,p " +
" MATCH p-[:HAS]-(t:Tag {wordPhrase : {wp} } ) " +
" 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")
List<MappedContent> getUserContentWithTag (@Param("u") String username, @Param("wp") String
wordPhrase);
Filtering Connected Content
If a tag is clicked on inside of the “Interests in my Network” section, then the getContentByTag method will be called
be with the userscontent value set to false. In turn, this will call the getFollowingContentWithTag method, shown
in Listing 11-45.
The query for the getFollowingContentWithTag method is nearly identical to the query found in
getUserContentWithTag , except it factors in the users being followed and exclude the current user. The method also
returns a collection of MappedContent items and matches resulting content to a provide tag, via @Param("wp") , placing
no limit on the number of status updates to be returned. In addition, it marks the owner property as false. The results
of calling this method are shown in Figure 11-13 .
 
Search WWH ::




Custom Search