Database Reference
In-Depth Information
Once the product and distance have been set, the search can be executed and the location method tests to see if
a productNodeId property has been set. If so, the returnLocationsWithinDistanceAndHasProduct method is called
from LocationDAO service, as shown in Listing 12-43.
Listing 12-43. The returnLocationsWithinDistanceAndHasProduct Method
public List<MappedLocation> returnLocationsWithinDistanceAndHasProduct(
Double lat, Double lon, Double distance, Long productNodeId) {
try {
ResultSet rs = cypher.resultSetQuery(
" START n = node:geom({1}), p=node({2}) " +
" MATCH n-[:HAS]->p " +
" RETURN n.locationId as locationId, n.address as address, " +
" n.city as city, n.state as state, n.zip as zip, " +
" n.name as name, n.lat as lat, n.lon as lon",
map("1", distanceQueryAsString(lat, lon, distance), "2", productNodeId));
ResultSetMapper<MappedLocation> resultSetMapper =
new ResultSetMapper<MappedLocation>();
List<MappedLocation> locations = resultSetMapper
.mapResultSetToListMappedClass(rs, MappedLocation.class);
// add the distance in miles to locations
addDistanceTo(locations, lat, lon);
return locations;
}
catch (Exception e) {
log.error(e);
return null;
}
}
Search WWH ::




Custom Search