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 Modifier and Type Field Description protected static String
ADDITIONAL_SKUS_JSON_PATH
protected static String
CLIENT_REGISTRATION_ID
protected static String
FOR_IN_STORE_PARAM
protected static String
FOR_PICKUP_PARAM
protected static String
FOR_SHIPPING_PARAM
protected static String
MIN_QUANTITY_PARAM
protected static String
PRIMARY_SKU_JSON_PATH
protected static String
SKU_CODES_PARAM
-
Constructor Summary
Constructors Constructor Description DefautlInventoryAvailabilityService(org.springframework.web.reactive.function.client.WebClient webClient, String inventoryEndpoint, String readAvailabilityPath, com.fasterxml.jackson.databind.ObjectMapper mapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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.protected Optional<Boolean>
getForPickup(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Returns whether this is for pickup.protected Optional<Boolean>
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.protected Optional<Boolean>
getInStore(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Returns whether this is for in store shopping.protected String
getInventoryEndpoint()
protected com.fasterxml.jackson.databind.ObjectMapper
getMapper()
protected Optional<Integer>
getMinQuantity(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Returns the minimum number for all the SKUs.protected String
getReadAvailabilityPath()
String
getServiceClient()
The service client to use when calling inventory services.protected org.springframework.web.reactive.function.client.WebClient
getWebClient()
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 Detail
-
PRIMARY_SKU_JSON_PATH
protected static final String PRIMARY_SKU_JSON_PATH
- See Also:
- Constant Field Values
-
ADDITIONAL_SKUS_JSON_PATH
protected static final String ADDITIONAL_SKUS_JSON_PATH
- See Also:
- Constant Field Values
-
CLIENT_REGISTRATION_ID
protected static final String CLIENT_REGISTRATION_ID
- See Also:
- Constant Field Values
-
FOR_SHIPPING_PARAM
protected static final String FOR_SHIPPING_PARAM
- See Also:
- Constant Field Values
-
FOR_PICKUP_PARAM
protected static final String FOR_PICKUP_PARAM
- See Also:
- Constant Field Values
-
FOR_IN_STORE_PARAM
protected static final String FOR_IN_STORE_PARAM
- See Also:
- Constant Field Values
-
MIN_QUANTITY_PARAM
protected static final String MIN_QUANTITY_PARAM
- See Also:
- Constant Field Values
-
SKU_CODES_PARAM
protected static final String SKU_CODES_PARAM
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
protected String getInventoryEndpoint()
-
getReadAvailabilityPath
protected String getReadAvailabilityPath()
-
getMapper
protected com.fasterxml.jackson.databind.ObjectMapper getMapper()
-
getServiceClient
public String getServiceClient()
The service client to use when calling inventory services. Default is "indexerclient"
-
setServiceClient
public void setServiceClient(String serviceClient)
The service client to use when calling inventory services. Default is "indexerclient"
-
-