Interface ProductDao

All Known Implementing Classes:
ProductDaoImpl

public interface ProductDao
ProductDao provides persistence access to Product instances
Author:
Jeff Fischer
See Also:
  • Method Details

    • readProductById

      @Nonnull Product readProductById(@Nonnull Long productId)
      Retrieve a Product instance by its primary key
      Parameters:
      productId - the primary key of the product
      Returns:
      the product instance at the specified primary key
    • readProductByExternalId

      Product readProductByExternalId(String externalId)
    • readProductsByIds

      List<Product> readProductsByIds(@Nonnull List<Long> productIds)
      Retrieves a list of Product instances by their primary keys
      Parameters:
      productIds - the list of primary keys for products
      Returns:
      the list of products specified by the primary keys
    • save

      @Nonnull Product save(@Nonnull Product product)
      Persist a Product instance to the datastore
      Parameters:
      product - the product instance
      Returns:
      the updated state of the product instance after being persisted
    • readProductsByName

      @Nonnull List<Product> readProductsByName(@Nonnull String searchName)
      Find all Product instances whose name starts with or is equal to the passed in search parameter
      Parameters:
      searchName - the partial or whole name to match
      Returns:
      the list of product instances that were search hits
    • readProductsByName

      @Nonnull List<Product> readProductsByName(@Nonnull String searchName, @Nonnull int limit, @Nonnull int offset)
      Find a subset of Product instances whose name starts with or is equal to the passed in search parameter. Res
      Parameters:
      searchName -
      limit - the maximum number of results
      offset - the starting point in the record set
      Returns:
      the list of product instances that fit the search criteria
    • readActiveProductsByCategory

      List<Product> readActiveProductsByCategory(@Nonnull Long categoryId)
      Find all products whose in the passed in category.
      Parameters:
      categoryId - the primary key of the category to whom the resulting product list should be related
      Returns:
      the list of products qualified for the category and date
    • readActiveProductsByCategory

      List<Product> readActiveProductsByCategory(@Nonnull Long categoryId, @Nonnull int limit, @Nonnull int offset)
      Read a page of products for a category.
      Parameters:
      categoryId -
      limit -
      offset -
      Returns:
    • readFilteredActiveProductsByCategory

      @Nonnull List<Product> readFilteredActiveProductsByCategory(Long categoryId, SearchCriteria searchCriteria)
      Find all active products that are related to the given category, match the given search criteria, and are not marked as archived.
      Parameters:
      categoryId -
      searchCriteria -
      Returns:
      the matching products
    • readFilteredActiveProductsByQuery

      @Nonnull List<Product> readFilteredActiveProductsByQuery(String query, SearchCriteria searchCriteria)
      Find all products whose start and end dates are before and after the passed in date, who match the search string, match the given search criteria, and are not marked as archived.
      Parameters:
      query -
      searchCriteria -
      Returns:
      the matching products
    • readFilteredActiveProductsByCategory

      @Deprecated(forRemoval=true) @Nonnull List<Product> readFilteredActiveProductsByCategory(Long categoryId, Date currentDate, SearchCriteria searchCriteria)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use readFilteredActiveProductsByCategory(Long, SearchCriteria)

      Find all products whose start and end dates are before and after the passed in date, who are related to the given category, match the given search criteria, and are not marked as archived.

      Parameters:
      categoryId -
      currentDate -
      searchCriteria -
      Returns:
      the matching products
    • readFilteredActiveProductsByQuery

      @Deprecated(forRemoval=true) @Nonnull List<Product> readFilteredActiveProductsByQuery(String query, Date currentDate, SearchCriteria searchCriteria)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use readFilteredActiveProductsByQuery(String, SearchCriteria) Find all products whose start and end dates are before and after the passed in date, who match the search string, match the given search criteria, and are not marked as archived.
      Parameters:
      query -
      currentDate -
      searchCriteria -
      Returns:
      the matching products
    • readActiveProductsByCategory

      @Deprecated(forRemoval=true) @Nonnull List<Product> readActiveProductsByCategory(@Nonnull Long categoryId, @Nonnull Date currentDate, @Nonnull int limit, @Nonnull int offset)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • readProductsByCategory

      @Nonnull List<Product> readProductsByCategory(@Nonnull Long categoryId)
      Find all products related to the passed in category
      Parameters:
      categoryId - the primary key of the category to whom the resulting product list should be related
      Returns:
      the list of products qualified for the category
    • readProductsByCategory

      @Nonnull List<Product> readProductsByCategory(@Nonnull Long categoryId, @Nonnull int limit, @Nonnull int offset)
      Find all products related to the passed in category
      Parameters:
      categoryId - the primary key of the category to whom the resulting product list should be related
      limit - the maximum number of results to return
      offset - the starting point in the record set
      Returns:
      the list of products qualified for the category
    • delete

      void delete(@Nonnull Product product)
      Remove the passed in product instance from the datastore
      Parameters:
      product - the product instance to remove
    • create

      Product create(ProductType productType)
      Create a new Product instance. The system will use the configuration in /BroadleafCommerce/core/BroadleafCommerceFramework/src/main/resources/bl-framework-applicationContext-entity.xml to determine which polymorphic version of Product to instantiate. To make Broadleaf instantiate your extension of Product by default, include an entity configuration bean in your application context xml similar to:

      <bean id="blEntityConfiguration" class="org.broadleafcommerce.common.persistence.EntityConfiguration"> <property name="entityContexts"> <list> <value>classpath:myCompany-applicationContext-entity.xml</value> </list> </property> </bean>

      Declare the same key for your desired entity in your entity xml that is used in the Broadleaf entity xml, but change the value to the fully qualified classname of your entity extension.
      Parameters:
      productType - the type of product you would like to create (presumably a Product or ProductSku instance). The getType method of ProductType provides the key for the entity configuration.
      Returns:
      a Product instance based on the Broadleaf entity configuration.
    • readAutomaticProductBundles

      List<ProductBundle> readAutomaticProductBundles()
      Returns all active ProductBundles whose automatic property is true.
      Returns:
    • findProductByURI

      List<Product> findProductByURI(String key)
      Look up a product that matches the given URI
      Parameters:
      key - - the relative URL to look up the Product by
      Returns:
      List of products that match the passed in URI.
    • readAllActiveProducts

      List<Product> readAllActiveProducts()
      Reads all products from the database that are currently active.
      Returns:
      a list of all active products
    • readAllActiveProducts

      @Deprecated(forRemoval=true) List<Product> readAllActiveProducts(@Nonnull Date currentDate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      currentDate -
      Returns:
      a list of all active products
    • readAllActiveProducts

      List<Product> readAllActiveProducts(int page, int pageSize)
      Reads all products from the database that are currently active. This method differs from readAllActiveProducts() in that this one will utilize database paging.

      It will fetch results in pages. For example, if page = 3 and pageSize = 25, this method would return rows 75-99 from the database.

      When possible, it is suggested to use readAllActiveProducts(Integer, Long) instead for performance.

      Parameters:
      page - - the number of the page to get (0 indexed)
      pageSize - - the number of results per page
      Returns:
      a list of active products for the given page
    • readAllActiveProducts

      List<Product> readAllActiveProducts(Integer pageSize, Long lastId)
      Reads all products from the database that are currently active. This method utilizes efficient paging to retrieve a subset of records. This approach does not use an offset technique (like readAllActiveProducts(int, int), but rather limits the retrieved records to those greater than the given id and returns a max results of pageSize. This is more efficient that using an offset, since the database will not have to retrieve all the records from the beginning of the table and trim the offset.
      Parameters:
      pageSize - the number of results per page
      lastId - the last id from the previous page - can be null if this is the first page request
      Returns:
      a list of active products for the given page
    • readAllActiveProducts

      @Deprecated List<Product> readAllActiveProducts(int page, int pageSize, Date currentDate)
      Parameters:
      page - - the number of the page to get (0 indexed)
      pageSize - - the number of results per page
      currentDate -
      Returns:
      a list of active products for the given page
    • readCountAllActiveProducts

      Long readCountAllActiveProducts()
      Returns the number of products that are currently active.
      Returns:
      the number of currently active products
    • readCountAllActiveProducts

      @Deprecated Long readCountAllActiveProducts(Date currentDate)
      Parameters:
      currentDate -
      Returns:
      the number of currently active products
    • getCurrentDateResolution

      Long getCurrentDateResolution()
      Returns the number of milliseconds that the current date/time will be cached for queries before refreshing. This aids in query caching, otherwise every query that utilized current date would be different and caching would be ineffective.
      Returns:
      the milliseconds to cache the current date/time
    • setCurrentDateResolution

      void setCurrentDateResolution(Long currentDateResolution)
      Sets the number of milliseconds that the current date/time will be cached for queries before refreshing. This aids in query caching, otherwise every query that utilized current date would be different and caching would be ineffective.
      Parameters:
      currentDateResolution - the milliseconds to cache the current date/time
    • readAllActiveProductIds

      List<Long> readAllActiveProductIds(Long lastId, int pageSize)
      Reads a paginated list of active product IDs, in ascending order, starting immediately after the lastId. If the lastId is null, then this returns the first page.
      Parameters:
      lastId -
      pageSize -
      Returns:
    • readAllActiveProductsForSiteMap

      List<Product> readAllActiveProductsForSiteMap(int page, int pageSize)