Database Reference
In-Depth Information
Capturing Consumption
You are creating code that directly captures consumption for a user, but the process could also be done by creating a
graph-backed service to consume the webserver logs in real time or another data store to create the relationships. The
result would be the same in either event: a process that connects nodes to reveal a pattern of consumption
(Listing 12-37).
Listing 12-37. Show List of Products and Product Trail of Current User OR Return Snippet of Products
//show products and products VIEWED by user
@Action(value = "consumption/{pagenum}", results = {
@Result(name = "success", type = "mustache", location =
"/mustache/html/graphs/consumption/index.html"),
@Result(name = "page", type = "mustache", location =
"/mustache/html/graphs/consumption/product-list.html")
})
public String consumption() {
// returns a product list HTML snippet
if (pagenum != null) {
// set current page
Integer curpage = pagenum;
// get the list of products for this page
graphStory = graphStoryDAO.getProductDAO().getProducts(graphStory, curpage);
// increase the page count
curpage = curpage + 10;
// set the next page to call
graphStory.setNextPageUrl("/consumption/" + curpage.toString());
return "page";
} else {
setTitle("Consumption");
// retrieve the first page of products
graphStory = graphStoryDAO.getProductDAO().getProducts(graphStory, pageNumStart);
// set the product trail
graphStory.setProductTrail(graphStoryDAO.getProductDAO()
.getProductTrail(cookiesMap.get(GraphStoryConstants.graphstoryUserAuthKey)));
// set the next page to call
graphStory.setNextPageUrl("/consumption/10");
return SUCCESS;
}
}
 
Search WWH ::




Custom Search