Class DefautlInventoryAvailabilityService
java.lang.Object
com.broadleafcommerce.search.index.catalog.service.DefautlInventoryAvailabilityService
- All Implemented Interfaces:
InventoryAvailabilityService
public class DefautlInventoryAvailabilityService
extends Object
implements InventoryAvailabilityService
This component makes a web services callout to Broadleaf's InventoryServices to determine
inventory availability for indexing, allowing us to filter products that are unavailable for a
given application or tenant.
- Author:
- Kelly Tisdell (ktisdell)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefautlInventoryAvailabilityService
(org.springframework.web.reactive.function.client.WebClient webClient, String inventoryEndpoint, String readAvailabilityPath, com.fasterxml.jackson.databind.ObjectMapper mapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.web.util.UriComponentsBuilder
buildBasicUri
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected String
buildReadInventoryAvailabilityUri
(com.broadleafcommerce.search.catalog.core.domain.Product product, com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected String
determineSkuReferences
(com.broadleafcommerce.search.catalog.core.domain.Product product, com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns a comma-separated list of SKU references.List<com.broadleafcommerce.search.catalog.core.domain.ConsolidatedInventoryAvailability>
findConsolidatedInventoryAvailability
(com.broadleafcommerce.search.catalog.core.domain.Product product, com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads a consolidated list of Inventory Availabilities.getForPickup
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether this is for pickup.getForShipping
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether this is for shipping.protected org.springframework.http.HttpHeaders
getHeaders
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sets the CONTENT_TYPE and ACCEPT headers.getInStore
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether this is for in store shopping.protected String
protected com.fasterxml.jackson.databind.ObjectMapper
getMinQuantity
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns the minimum number for all the SKUs.protected String
The service client to use when calling inventory services.protected org.springframework.web.reactive.function.client.WebClient
void
setServiceClient
(String serviceClient) The service client to use when calling inventory services.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.search.index.catalog.service.InventoryAvailabilityService
updateInventoryAvailability
-
Field Details
-
PRIMARY_SKU_JSON_PATH
- See Also:
-
ADDITIONAL_SKUS_JSON_PATH
- See Also:
-
CLIENT_REGISTRATION_ID
- See Also:
-
FOR_SHIPPING_PARAM
- See Also:
-
FOR_PICKUP_PARAM
- See Also:
-
FOR_IN_STORE_PARAM
- See Also:
-
MIN_QUANTITY_PARAM
- See Also:
-
SKU_CODES_PARAM
- See Also:
-
-
Constructor Details
-
DefautlInventoryAvailabilityService
-
-
Method Details
-
findConsolidatedInventoryAvailability
@NonNull public List<com.broadleafcommerce.search.catalog.core.domain.ConsolidatedInventoryAvailability> findConsolidatedInventoryAvailability(@NonNull com.broadleafcommerce.search.catalog.core.domain.Product product, @NonNull com.jayway.jsonpath.DocumentContext jsonContext, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:InventoryAvailabilityService
Reads a consolidated list of Inventory Availabilities. These are typically aggregated so that they don't include quantities, nor specific warehouses or inventory locations. This is meant to indicate if inventory is available so that it should not be removed from search results.- Specified by:
findConsolidatedInventoryAvailability
in interfaceInventoryAvailabilityService
- Parameters:
product
- for which to check availabilityjsonContext
- the parsed JSONDocumentContext
of the productcontextInfo
- required context info for this request, specifying the tenantId, which is required- Returns:
- list of consolidated inventory availability across a tenant
-
buildBasicUri
protected org.springframework.web.util.UriComponentsBuilder buildBasicUri(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
buildReadInventoryAvailabilityUri
protected String buildReadInventoryAvailabilityUri(com.broadleafcommerce.search.catalog.core.domain.Product product, com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
determineSkuReferences
protected String determineSkuReferences(com.broadleafcommerce.search.catalog.core.domain.Product product, com.jayway.jsonpath.DocumentContext jsonContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns a comma-separated list of SKU references. By default, these are SKU codes.- Parameters:
product
- the product containing the metadatajsonContext
- the JSON Document ContextcontextInfo
-- Returns:
-
getForShipping
protected Optional<Boolean> getForShipping(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether this is for shipping. The default is true, so we don't bother setting the value.- Parameters:
contextInfo
-- Returns:
-
getForPickup
protected Optional<Boolean> getForPickup(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether this is for pickup. The default is true, so we don't bother setting the value.- Parameters:
contextInfo
-- Returns:
-
getInStore
protected Optional<Boolean> getInStore(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns whether this is for in store shopping. The default is null, so we don't bother setting the value.- Parameters:
contextInfo
-- Returns:
-
getMinQuantity
protected Optional<Integer> getMinQuantity(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Returns the minimum number for all the SKUs. The default is 1, so we don't bother setting the value.- Parameters:
contextInfo
-- Returns:
-
getHeaders
protected org.springframework.http.HttpHeaders getHeaders(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sets the CONTENT_TYPE and ACCEPT headers. Also, serializes theContextInfo
, if available, into HTTP a header.- Parameters:
contextInfo
-- Returns:
- headers
-
getWebClient
protected org.springframework.web.reactive.function.client.WebClient getWebClient() -
getInventoryEndpoint
-
getReadAvailabilityPath
-
getMapper
protected com.fasterxml.jackson.databind.ObjectMapper getMapper() -
getServiceClient
The service client to use when calling inventory services. Default is "indexerclient" -
setServiceClient
The service client to use when calling inventory services. Default is "indexerclient"
-