Database Reference
In-Depth Information
Consumption Graph Model
This section examines a few techniques to capture and use patterns of consumption generated implicitly by a user
or users. For the purposes of your application, you will use the prepopulated set of products provided in the sample
graph. The code required for the console will reinforce the standard persistence operations, this section focuses on
the operations that take advantage of this model type, including:
Capturing consumption
Filtering consumption for users
Filtering consumption for messaging
Product Entity
The Product entity will be used to demonstrate the consumption graph— specifically how a user's product trail can be
provided. As shown in Listing 7-40, this entity is similar to the other entities that have been outlined for this chapter.
Listing 7-40. The Product Object
public class Product
{
public long nodeId { get; set; }
public NodeReference noderef { get; set; }
public string productId { get; set; }
public string title { get; set; }
public string description { get; set; }
public string tagstr { get; set; }
public string content { get; set; }
public string price { get; set; }
}
Capturing Consumption
The process above for creating code that directly captures consumption for a user could also be done by creating
a graph-backed service to consume the webserver logs in real time, or by creating another data store to create
the relationships. The result would be the same in any event: a process that connects nodes to reveal a pattern of
consumption.
The sample application used the createUserViewAndReturnViews method in ProductService first to find the
Product entity being viewed and then to create an explicit relationship type called VIEWED . As you may have noticed,
this is the first relationship type in the application that also 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 7-41, checks to see if a
VIEWED relationship already exists between the user and the product using MERGE .
In the MERGE section of the query, if the result of the MERGE is zero matches, then a relationship is created with key
value pairs on the new relationship—specifically, dateAsStr and timestamp . Finally, the query uses MATCH to return
the existing product views.
 
Search WWH ::




Custom Search