Database Reference
In-Depth Information
Filtering Consumption for Users
One practical use of the consumption model is to create a content trail for users, as shown in Figure 12-14 . As a user
clicks on items in the scrolling product stream, the interaction is captured using createUserView , which ultimately
returns a list of relationship objects of the VIEWED type.
In the Consumption section, take a look at the c reateUserProductViewRel method to see how the process begins
inside the controller. The controller method first saves the view and then returns the complete history of views using
the getProductTrail method, which can be found in the Product service class. The process is started when the
createUserProductViewRel function is called, which is located in graphstory.js.
Figure 12-14. The Scrolling Product and Product Trail page
For the sample application, you will use the addUserViewAndReturnProductTrail method in the ProductDAO
class to find the Product entity being viewed and then create an explicit relationship type called VIEWED . As you may
have noticed, this is the first instance of a relationship type in the application that contains properties. In this case,
you are creating a timestamp with a Date object and String value of the timestamp. The query, provided in
Listing 12-38, checks to see if a VIEWED relationship already exists between the user and the product.
If the result of the MERGE clause within query is returns zero matches, then a map is created with key value pairs to
create properties on the new relationship, specifically timestamp and dateAsStr . Otherwise, the query will update the
existing relationship properties to their new, respective values.
 
Search WWH ::




Custom Search