Class 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)
    • Constructor Detail

      • DefautlInventoryAvailabilityService

        public DefautlInventoryAvailabilityService​(org.springframework.web.reactive.function.client.WebClient webClient,
                                                   String inventoryEndpoint,
                                                   String readAvailabilityPath,
                                                   com.fasterxml.jackson.databind.ObjectMapper mapper)
    • 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 interface InventoryAvailabilityService
        Parameters:
        product - for which to check availability
        jsonContext - the parsed JSON DocumentContext of the product
        contextInfo - 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 metadata
        jsonContext - the JSON Document Context
        contextInfo -
        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 the ContextInfo, 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"