Class DefaultInventoryLocationService<L extends InventoryLocation>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<L>
com.broadleafcommerce.inventory.service.DefaultInventoryLocationService<L>
- Type Parameters:
L-
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<L>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<L>,InventoryLocationService<L>
public class DefaultInventoryLocationService<L extends InventoryLocation>
extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<L>
implements InventoryLocationService<L>
Service to store and retrieve
InventoryLocation data.- Author:
- Kelly Tisdell (ktisdell)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultInventoryLocationService(InventoryLocationRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager mapper) Creates a new instance ofDefaultInventoryLocationService. -
Method Summary
Modifier and TypeMethodDescriptionprotected Double[]calculateBoundedBox(Double latitude, Double longitude, Double distance) Returns anDoublearray with 4 values representing a bounding box: Min Latitude, Max Latitude, Min Longitude, Max Longitudeprotected DoubleconvertDistanceToKilometers(Double distance, DistanceType type) We always convert to KM prior to finding the area.voidDeletes theInventoryLocationwith the specified contextId.booleanexistsByContextId(String contextId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Indicates if anInventoryLocationexists with the specified contextId in the provided context.protected com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManagerData Mapper to assist in data conversion.protected InventoryLocationRepository<com.broadleafcommerce.data.tracking.core.Trackable>Inventory Repository (or DAO).protected SkuInventoryService<SkuInventory>org.springframework.data.domain.Page<L>readAllByNameOrNumber(String nameOrNumberQuery, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Read all Inventory Locations, optionally filtered by name or number.org.springframework.data.domain.Page<L>readAllLocationsByCountryCode(String countryCode, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Pageable query forInventoryLocationreferences with a particular country code.org.springframework.data.domain.Page<L>readAllLocationsByCountryCodeAndPostalCode(String countryCode, String postalCode, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Pageable query forInventoryLocationreferences with particular country code and postal code.org.springframework.data.domain.Page<L>readAllLocationsByCountryCodeAndStateProvinceRegionCode(String countryCode, String stateProvinceRegionCode, String city, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Pageable query forInventoryLocationreferences with a particular country code and state / province / region code.org.springframework.data.domain.Page<L>readAllLocationsByDistanceFromCoordinates(Double latitude, Double longitude, Double distance, DistanceType distanceType, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Query for allInventoryLocationreferences that are marked as shipping locations and have a latitude and longitude within a given distance of a provided coordinate.readByContextIdOptional(String contextId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) An alternative toCrudEntityService.readByContextId(String, ContextInfo)that returns anOptionalrather than throwing an exception if not found.readByLocationNumber(String locationNumber, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Query forInventoryLocationreferences with a given location number, which is an arbitrary reference number (e.g.readByPickupLocationTrue(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns allInventoryLocationreferences that are pickup locations.readByShippingLocationTrue(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns allInventoryLocationreferences that are shipping locations.org.springframework.data.domain.Page<L>readLocationsByLocationNumbers(Set<String> locationNumbers, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Query forInventoryLocationreferences with a given location number, which is an arbitrary reference number (e.g.org.springframework.data.domain.Page<L>readPickupLocationsByCountryCodeAndPostalCode(String countryCode, String postalCode, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Pageable query forInventoryLocationreferences that support pickup with a particular country code and postal code.org.springframework.data.domain.Page<L>readPickupLocationsByCountryCodeAndStateProvinceRegionCode(String countryCode, String stateProvinceRegionCode, String city, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Pageable query forInventoryLocationreferences that allow pickup with a particular country code and state / province / region code.org.springframework.data.domain.Page<L>readPickupLocationsByDistanceFromCoordinates(Double latitude, Double longitude, Double distance, DistanceType distanceType, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Query for allInventoryLocationreferences that are marked as pickup locations and have a latitude and longitude within a given distance of a provided coordinate.org.springframework.data.domain.Page<L>readShippingLocationsByCountryCodeAndPostalCode(String countryCode, String postalCode, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Pageable query forInventoryLocationreferences that support shipping with a particular country code and postal code.org.springframework.data.domain.Page<L>readShippingLocationsByCountryCodeAndStateProvinceRegionCode(String countryCode, String stateProvinceRegionCode, String city, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Pageable query forInventoryLocationreferences that allow shipping with a particular country code and state / province / region code.org.springframework.data.domain.Page<L>readShippingLocationsByDistanceFromCoordinates(Double latitude, Double longitude, Double distance, DistanceType distanceType, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Query for allInventoryLocationreferences that are marked as shipping locations and have a latitude and longitude within a given distance of a provided coordinate.org.springframework.data.domain.Page<L>readStoreLocationsByCountryCodeAndPostalCode(String countryCode, String postalCode, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Pageable query forInventoryLocationreferences that are "Stores" with a particular country code and postal code.org.springframework.data.domain.Page<L>readStoreLocationsByCountryCodeAndStateProvinceRegionCode(String countryCode, String stateProvinceRegionCode, String city, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Pageable query forInventoryLocationreferences that are "Stores" with a particular country code and state / province / region code.org.springframework.data.domain.Page<L>readStoreLocationsByDistanceFromCoordinates(Double latitude, Double longitude, Double distance, DistanceType distanceType, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Query for allInventoryLocationreferences that are marked as "Store" locations and have a latitude and longitude within a given distance of a provided coordinate.voidsetSkuInventoryService(SkuInventoryService<SkuInventory> skuInventoryService) Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAllMethods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, createAllAllowingPartialSuccess, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort
-
Field Details
-
MILES_TO_KM_CONVERSION_MULTIPLIER
This is the constant number of KM in a Mile. -
EARTH_MEAN_RADIUS_KM
Constant for the mean radius of the Earth in Kilometers.
-
-
Constructor Details
-
DefaultInventoryLocationService
public DefaultInventoryLocationService(InventoryLocationRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager mapper) Creates a new instance ofDefaultInventoryLocationService.- Parameters:
repository-helper-mapper-
-
-
Method Details
-
readAllByNameOrNumber
public org.springframework.data.domain.Page<L> readAllByNameOrNumber(@Nullable String nameOrNumberQuery, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:InventoryLocationServiceRead all Inventory Locations, optionally filtered by name or number.- Specified by:
readAllByNameOrNumberin interfaceInventoryLocationService<L extends InventoryLocation>- Parameters:
nameOrNumberQuery- (optional) the name or location number to filter byfilters- additional filters to apply in the query, can be nullpage- the requested page of results from the databasecontext- context information surrounding sandboxing and multitenant state- Returns:
-
readByContextIdOptional
public Optional<L> readByContextIdOptional(String contextId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServiceAn alternative toCrudEntityService.readByContextId(String, ContextInfo)that returns anOptionalrather than throwing an exception if not found.- Specified by:
readByContextIdOptionalin interfaceInventoryLocationService<L extends InventoryLocation>- Parameters:
contextId- the context ID of the location to findcontextInfo- context information surrounding multitenant state- Returns:
- an optional containing the requested
InventoryLocationif found,Optional.empty()otherwise
-
readByShippingLocationTrue
public List<L> readByShippingLocationTrue(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns allInventoryLocationreferences that are shipping locations.- Specified by:
readByShippingLocationTruein interfaceInventoryLocationService<L extends InventoryLocation>- Parameters:
contextInfo-- Returns:
-
readByPickupLocationTrue
public List<L> readByPickupLocationTrue(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns allInventoryLocationreferences that are pickup locations.- Specified by:
readByPickupLocationTruein interfaceInventoryLocationService<L extends InventoryLocation>- Parameters:
contextInfo-- Returns:
-
readAllLocationsByCountryCodeAndPostalCode
public org.springframework.data.domain.Page<L> readAllLocationsByCountryCodeAndPostalCode(String countryCode, String postalCode, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServicePageable query forInventoryLocationreferences with particular country code and postal code.- Specified by:
readAllLocationsByCountryCodeAndPostalCodein interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readShippingLocationsByCountryCodeAndPostalCode
public org.springframework.data.domain.Page<L> readShippingLocationsByCountryCodeAndPostalCode(String countryCode, String postalCode, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServicePageable query forInventoryLocationreferences that support shipping with a particular country code and postal code.- Specified by:
readShippingLocationsByCountryCodeAndPostalCodein interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readPickupLocationsByCountryCodeAndPostalCode
public org.springframework.data.domain.Page<L> readPickupLocationsByCountryCodeAndPostalCode(String countryCode, String postalCode, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServicePageable query forInventoryLocationreferences that support pickup with a particular country code and postal code.- Specified by:
readPickupLocationsByCountryCodeAndPostalCodein interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readAllLocationsByCountryCodeAndStateProvinceRegionCode
public org.springframework.data.domain.Page<L> readAllLocationsByCountryCodeAndStateProvinceRegionCode(String countryCode, String stateProvinceRegionCode, @Nullable String city, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServicePageable query forInventoryLocationreferences with a particular country code and state / province / region code. The city parameter is optional and will only be used if not null.- Specified by:
readAllLocationsByCountryCodeAndStateProvinceRegionCodein interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readShippingLocationsByCountryCodeAndStateProvinceRegionCode
public org.springframework.data.domain.Page<L> readShippingLocationsByCountryCodeAndStateProvinceRegionCode(String countryCode, String stateProvinceRegionCode, @Nullable String city, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServicePageable query forInventoryLocationreferences that allow shipping with a particular country code and state / province / region code.- Specified by:
readShippingLocationsByCountryCodeAndStateProvinceRegionCodein interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readPickupLocationsByCountryCodeAndStateProvinceRegionCode
public org.springframework.data.domain.Page<L> readPickupLocationsByCountryCodeAndStateProvinceRegionCode(String countryCode, String stateProvinceRegionCode, @Nullable String city, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServicePageable query forInventoryLocationreferences that allow pickup with a particular country code and state / province / region code.- Specified by:
readPickupLocationsByCountryCodeAndStateProvinceRegionCodein interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readAllLocationsByCountryCode
public org.springframework.data.domain.Page<L> readAllLocationsByCountryCode(String countryCode, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServicePageable query forInventoryLocationreferences with a particular country code.- Specified by:
readAllLocationsByCountryCodein interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readByLocationNumber
public Optional<L> readByLocationNumber(String locationNumber, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServiceQuery forInventoryLocationreferences with a given location number, which is an arbitrary reference number (e.g. store number, store ID, warehouse ID, etc.)- Specified by:
readByLocationNumberin interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readLocationsByLocationNumbers
public org.springframework.data.domain.Page<L> readLocationsByLocationNumbers(Set<String> locationNumbers, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServiceQuery forInventoryLocationreferences with a given location number, which is an arbitrary reference number (e.g. store number, store ID, warehouse ID, etc.)- Specified by:
readLocationsByLocationNumbersin interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readAllLocationsByDistanceFromCoordinates
public org.springframework.data.domain.Page<L> readAllLocationsByDistanceFromCoordinates(Double latitude, Double longitude, Double distance, DistanceType distanceType, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServiceQuery for allInventoryLocationreferences that are marked as shipping locations and have a latitude and longitude within a given distance of a provided coordinate.- Specified by:
readAllLocationsByDistanceFromCoordinatesin interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readPickupLocationsByDistanceFromCoordinates
public org.springframework.data.domain.Page<L> readPickupLocationsByDistanceFromCoordinates(Double latitude, Double longitude, Double distance, DistanceType distanceType, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServiceQuery for allInventoryLocationreferences that are marked as pickup locations and have a latitude and longitude within a given distance of a provided coordinate.- Specified by:
readPickupLocationsByDistanceFromCoordinatesin interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readShippingLocationsByDistanceFromCoordinates
public org.springframework.data.domain.Page<L> readShippingLocationsByDistanceFromCoordinates(Double latitude, Double longitude, Double distance, DistanceType distanceType, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServiceQuery for allInventoryLocationreferences that are marked as shipping locations and have a latitude and longitude within a given distance of a provided coordinate.- Specified by:
readShippingLocationsByDistanceFromCoordinatesin interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
existsByContextId
public boolean existsByContextId(String contextId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServiceIndicates if anInventoryLocationexists with the specified contextId in the provided context.- Specified by:
existsByContextIdin interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
delete
@Transactional("inventoryTransactionManager") public void delete(String contextId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServiceDeletes theInventoryLocationwith the specified contextId. Also deletes all theSkuInventorypresent at the specified inventory location.- Specified by:
deletein interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<L extends InventoryLocation>- Specified by:
deletein interfaceInventoryLocationService<L extends InventoryLocation>- Overrides:
deletein classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<L extends InventoryLocation>
-
getRepositoryDomain
- Specified by:
getRepositoryDomainin interfaceInventoryLocationService<L extends InventoryLocation>
-
readStoreLocationsByCountryCodeAndPostalCode
public org.springframework.data.domain.Page<L> readStoreLocationsByCountryCodeAndPostalCode(String countryCode, String postalCode, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServicePageable query forInventoryLocationreferences that are "Stores" with a particular country code and postal code.- Specified by:
readStoreLocationsByCountryCodeAndPostalCodein interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readStoreLocationsByCountryCodeAndStateProvinceRegionCode
public org.springframework.data.domain.Page<L> readStoreLocationsByCountryCodeAndStateProvinceRegionCode(String countryCode, String stateProvinceRegionCode, String city, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServicePageable query forInventoryLocationreferences that are "Stores" with a particular country code and state / province / region code.- Specified by:
readStoreLocationsByCountryCodeAndStateProvinceRegionCodein interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
readStoreLocationsByDistanceFromCoordinates
public org.springframework.data.domain.Page<L> readStoreLocationsByDistanceFromCoordinates(Double latitude, Double longitude, Double distance, DistanceType distanceType, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryLocationServiceQuery for allInventoryLocationreferences that are marked as "Store" locations and have a latitude and longitude within a given distance of a provided coordinate.- Specified by:
readStoreLocationsByDistanceFromCoordinatesin interfaceInventoryLocationService<L extends InventoryLocation>- Returns:
-
calculateBoundedBox
Returns anDoublearray with 4 values representing a bounding box: Min Latitude, Max Latitude, Min Longitude, Max Longitude- Parameters:
latitude-longitude-distance-- Returns:
-
convertDistanceToKilometers
We always convert to KM prior to finding the area. If Kilometers are passed in, then they are not converted, but rather returned as aDoublevalue.- Parameters:
distance-type-- Returns:
-
getRepository
@NonNull protected InventoryLocationRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()Inventory Repository (or DAO).- Overrides:
getRepositoryin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<L extends InventoryLocation>
-
getMapper
@NonNull protected com.broadleafcommerce.data.tracking.core.mapping.DomainMapperManager getMapper()Data Mapper to assist in data conversion. -
setSkuInventoryService
@Autowired @Lazy public void setSkuInventoryService(SkuInventoryService<SkuInventory> skuInventoryService) -
getSkuInventoryService
-