Class DefaultLocationService
- java.lang.Object
-
- de.hybris.platform.storelocator.location.impl.DefaultLocationService
-
- All Implemented Interfaces:
LocationService
public class DefaultLocationService extends java.lang.Object implements LocationService
Default implementation for LocationService.
-
-
Constructor Summary
Constructors Constructor Description DefaultLocationService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected doublecalculateDistance(GPS referenceGps, PointOfServiceModel posModel)booleandeleteLocation(Location location)Delete the given IAddress from the collection of stored addressesprotected CommonI18NServicegetCommonI18NService()protected GeoWebServiceWrappergetGeoServiceWrapper()LocationgetLocation(java.lang.String streetName, java.lang.String streetNumber, java.lang.String postalCode, java.lang.String town, java.lang.String countryCode, boolean geocode)Get temporary, non-persisted locationLocationgetLocationByName(java.lang.String name)Returns persisted Location by nameprotected LocationMapServicegetLocationMapService()java.util.List<Location>getLocationsForPoint(GPS gps, int limitLocationsCount, BaseStoreModel baseStore)Method returns the nearest locations (points of interest) to the given coordinates, in the number adequate to user definition.java.util.List<Location>getLocationsForPostcode(java.lang.String postalCode, java.lang.String countryCode, int limitLocationsCount, BaseStoreModel baseStore)Method looks for nearest locations (points of interest) to the place defined by postal code and country.java.util.List<Location>getLocationsForSearch(java.lang.String searchTerm, java.lang.String countryCode, int limitLocationsCount, BaseStoreModel baseStore)Method looks for nearby locations (points of interest) in the place defined by search term (that can be postal code or town name) and country.java.util.List<Location>getLocationsForTown(java.lang.String town, int limitLocationsCount, BaseStoreModel baseStore)Method looks for nearest locations (points of interest) to the place defined by city name.java.util.List<Location>getLocationsNearby(GPS gps, double distance)Get all known addresses which are located in the circle centered in the given gps location and a given radiusjava.util.List<Location>getLocationsNearby(GPS gps, double distance, BaseStoreModel baseStore)Get all known addresses which are located in the circle centered in the given gps location and a given radius, which belong to a given storeprotected MapServicegetMapService()protected ModelServicegetModelService()protected PointOfServiceDaogetPointOfServiceDao()java.util.List<DistanceAwareLocation>getSortedLocationsNearby(GPS gps, double distance, BaseStoreModel baseStore)Returns list of sortedDistanceAwareLocations.booleansaveOrUpdateLocation(Location location)Adds a new address or update existing onevoidsetCommonI18NService(CommonI18NService commonI18NService)voidsetGeoServiceWrapper(GeoWebServiceWrapper geoServiceWrapper)voidsetLocationMapService(LocationMapService locationMapService)voidsetMapService(MapService mapService)voidsetModelService(ModelService modelService)voidsetPointOfServiceDao(PointOfServiceDao pointOfServiceDao)protected voidvalidateInputData(java.lang.Object input, java.lang.String message)Validation for input parameters.
-
-
-
Method Detail
-
deleteLocation
public boolean deleteLocation(Location location)
Description copied from interface:LocationServiceDelete the given IAddress from the collection of stored addresses- Specified by:
deleteLocationin interfaceLocationService- Parameters:
location- GPS coordinates- Returns:
- true if address was deleted
-
getLocationsNearby
public java.util.List<Location> getLocationsNearby(GPS gps, double distance)
Description copied from interface:LocationServiceGet all known addresses which are located in the circle centered in the given gps location and a given radius- Specified by:
getLocationsNearbyin interfaceLocationService- Parameters:
gps- GPS coordinatesdistance- in kilometers- Returns:
- List of addresses
-
getLocationsNearby
public java.util.List<Location> getLocationsNearby(GPS gps, double distance, BaseStoreModel baseStore)
Description copied from interface:LocationServiceGet all known addresses which are located in the circle centered in the given gps location and a given radius, which belong to a given store- Specified by:
getLocationsNearbyin interfaceLocationService- Parameters:
gps- GPS coordinatesdistance- in kilometersbaseStore- base store- Returns:
- List of addresses
-
getSortedLocationsNearby
public java.util.List<DistanceAwareLocation> getSortedLocationsNearby(GPS gps, double distance, BaseStoreModel baseStore)
Description copied from interface:LocationServiceReturns list of sortedDistanceAwareLocations. Sorting order is ascending - the closest locations come first.- Specified by:
getSortedLocationsNearbyin interfaceLocationService- Parameters:
gps- - reference location. Center.distance- - radius in [km]. The returned locations are contained in the square that the circle describes.baseStore- - if set, method will return locations bound to the givenBaseStoreModel- Returns:
- a sorted list of nearby locations
-
calculateDistance
protected double calculateDistance(GPS referenceGps, PointOfServiceModel posModel)
-
saveOrUpdateLocation
public boolean saveOrUpdateLocation(Location location)
Description copied from interface:LocationServiceAdds a new address or update existing one- Specified by:
saveOrUpdateLocationin interfaceLocationService- Parameters:
location- GPS coordinates- Returns:
- true if operation was successful
-
getLocationByName
public Location getLocationByName(java.lang.String name)
Description copied from interface:LocationServiceReturns persisted Location by name- Specified by:
getLocationByNamein interfaceLocationService- Parameters:
name- name of location- Returns:
Locationmatched by unique name
-
getLocation
public Location getLocation(java.lang.String streetName, java.lang.String streetNumber, java.lang.String postalCode, java.lang.String town, java.lang.String countryCode, boolean geocode)
Description copied from interface:LocationServiceGet temporary, non-persisted location- Specified by:
getLocationin interfaceLocationService- Parameters:
streetName- street namestreetNumber- street numberpostalCode- postal codetown- name of towncountryCode- country codegeocode- - set to true if returnLocationshould haveGPSdata populated- Returns:
Location
-
getLocationsForPostcode
public java.util.List<Location> getLocationsForPostcode(java.lang.String postalCode, java.lang.String countryCode, int limitLocationsCount, BaseStoreModel baseStore)
Description copied from interface:LocationServiceMethod looks for nearest locations (points of interest) to the place defined by postal code and country. Number of returned locations is adequate to user definition. Use when you don't need any map, only list of sorted locations is enough.- Specified by:
getLocationsForPostcodein interfaceLocationService- Parameters:
postalCode- searching condition for locations - postal codecountryCode- searching condition for locations - country codelimitLocationsCount- number of locations to returnbaseStore- if set, method will return locations bound to the givenBaseStoreModel- Returns:
- list of found locations
-
getLocationsForTown
public java.util.List<Location> getLocationsForTown(java.lang.String town, int limitLocationsCount, BaseStoreModel baseStore)
Description copied from interface:LocationServiceMethod looks for nearest locations (points of interest) to the place defined by city name. Number of returned locations is adequate to user definition. Use when you don't need any map, only list of sorted locations is enough.- Specified by:
getLocationsForTownin interfaceLocationService- Parameters:
town- searching condition for locationslimitLocationsCount- number of locations to returnbaseStore- if set, method will return locations bound to the givenBaseStoreModel- Returns:
- list of found locations
-
getLocationsForSearch
public java.util.List<Location> getLocationsForSearch(java.lang.String searchTerm, java.lang.String countryCode, int limitLocationsCount, BaseStoreModel baseStore)
Description copied from interface:LocationServiceMethod looks for nearby locations (points of interest) in the place defined by search term (that can be postal code or town name) and country. Basically it combines two other methods that retrieves locations for town name and postal code.- Specified by:
getLocationsForSearchin interfaceLocationService- Parameters:
searchTerm- the search term - can be postal code or town namecountryCode- the country code - country code to look for (valid if given value is postal code)limitLocationsCount- number of locations to returnbaseStore- if set, method will return locations bound to the givenBaseStoreModel- Returns:
- list of found locations
-
getLocationsForPoint
public java.util.List<Location> getLocationsForPoint(GPS gps, int limitLocationsCount, BaseStoreModel baseStore)
Description copied from interface:LocationServiceMethod returns the nearest locations (points of interest) to the given coordinates, in the number adequate to user definition. Use when you have got defined coordinates and need only sorted locations nearby, without any map.- Specified by:
getLocationsForPointin interfaceLocationService- Parameters:
gps- coordinates of center pointlimitLocationsCount- number of POIs chosen by userbaseStore- if set, method will return locations bound to the givenBaseStoreModel- Returns:
- list of proper Locations
-
validateInputData
protected void validateInputData(java.lang.Object input, java.lang.String message)Validation for input parameters.- Parameters:
input- parameter to validatemessage- message to be thrown
-
getMapService
protected MapService getMapService()
-
setMapService
public void setMapService(MapService mapService)
-
getLocationMapService
protected LocationMapService getLocationMapService()
-
setLocationMapService
public void setLocationMapService(LocationMapService locationMapService)
-
getModelService
protected ModelService getModelService()
-
setModelService
public void setModelService(ModelService modelService)
-
getGeoServiceWrapper
protected GeoWebServiceWrapper getGeoServiceWrapper()
-
setGeoServiceWrapper
public void setGeoServiceWrapper(GeoWebServiceWrapper geoServiceWrapper)
-
getCommonI18NService
protected CommonI18NService getCommonI18NService()
-
setCommonI18NService
public void setCommonI18NService(CommonI18NService commonI18NService)
-
getPointOfServiceDao
protected PointOfServiceDao getPointOfServiceDao()
-
setPointOfServiceDao
public void setPointOfServiceDao(PointOfServiceDao pointOfServiceDao)
-
-