Database Reference
In-Depth Information
Listing 11-55.
The returnLocationsWithinDistanceAndHasProduct Method
public GraphStory
returnLocationsWithinDistanceAndHasProduct
(GraphStory graphStory, Double lat,
Double lon, Double distance, Long productNodeId) {
List<MappedLocation> locations =
mappedLocationRepository.locationsWithinDistanceWithProduct
(distanceQueryAsString(lat, lon, distance), productNodeId);
// add the distance in miles to locations
addDistanceTo(locations, lat, lon);
graphStory.setMappedLocations(locations);
graphStory.setProduct(productRepository.findOne(productNodeId));
return graphStory;
}
Intent Graph Model
The last part of the graph model exploration considers all the other graphs in order to suggest products based on the
Purchase
entity, shown in Listing 11-56. The intent graph also considers the products, users, locations, and tags that
are connected based on the Purchase entity.
In addition, each one of the following examples makes use of the
MappedProductUserPurchase
interface found in
the
MappedProductUserPurchaseRepository
, as shown in Listing 11-57.
Listing 11-56.
The
Purchase
entity
@NodeEntity
@TypeAlias("Purchase")
public class
Purchase
{
@GraphId
private Long nodeId;
@Indexed
private String purchaseId;
@RelatedTo(type = GraphStoryConstants.CONTAINS, direction =
Direction.OUTGOING, elementClass = Product.class)
private Set<Product> products;
private Date timestamp;
// getters and setters
}