org.broadleafcommerce.core.catalog.dao
Interface ProductDao

All Known Implementing Classes:
ProductDaoImpl

public interface ProductDao

ProductDao provides persistence access to Product instances

Author:
Jeff Fischer
See Also:
Product

Method Summary
 Product create(ProductType productType)
          Create a new Product instance.
 void delete(Product product)
          Remove the passed in product instance from the datastore
 List<Product> findProductByURI(String key)
          Look up a product that matches the given URI
 List<Product> readActiveProductsByCategory(Long categoryId, Date currentDate)
          Find all products whose start and end dates are before and after the passed in date and who are related to the given category
 List<Product> readActiveProductsByCategory(Long categoryId, Date currentDate, int limit, int offset)
           
 List<Product> readAllActiveProducts(Date currentDate)
          Reads all products from the database that are currently active.
 List<Product> readAllActiveProducts(int page, int pageSize, Date currentDate)
          Reads all products from the database that are currently active.
 List<ProductBundle> readAutomaticProductBundles()
          Returns all active ProductBundles whose automatic property is true.
 Long readCountAllActiveProducts(Date currentDate)
          Returns the number of products that are currently active.
 List<Product> readFilteredActiveProductsByCategory(Long categoryId, Date currentDate, ProductSearchCriteria 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.
 List<Product> readFilteredActiveProductsByQuery(String query, Date currentDate, ProductSearchCriteria 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.
 Product readProductById(Long productId)
          Retrieve a Product instance by its primary key
 List<Product> readProductsByCategory(Long categoryId)
          Find all products related to the passed in category
 List<Product> readProductsByCategory(Long categoryId, int limit, int offset)
          Find all products related to the passed in category
 List<Product> readProductsByIds(List<Long> productIds)
          Retrieves a list of Product instances by their primary keys
 List<Product> readProductsByName(String searchName)
          Find all Product instances whose name starts with or is equal to the passed in search parameter
 List<Product> readProductsByName(String searchName, int limit, int offset)
          Find a subset of Product instances whose name starts with or is equal to the passed in search parameter.
 Product save(Product product)
          Persist a Product instance to the datastore
 

Method Detail

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

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

@Nonnull
List<Product> readActiveProductsByCategory(@Nonnull
                                                   Long categoryId,
                                                   @Nonnull
                                                   Date currentDate)
Find all products whose start and end dates are before and after the passed in date and who are related to the given category

Parameters:
categoryId - the primary key of the category to whom the resulting product list should be related
currentDate - the date for which the products should be checked against to determine their active state
Returns:
the list of products qualified for the category and date

readFilteredActiveProductsByCategory

@Nonnull
List<Product> readFilteredActiveProductsByCategory(Long categoryId,
                                                           Date currentDate,
                                                           ProductSearchCriteria 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

@Nonnull
List<Product> readFilteredActiveProductsByQuery(String query,
                                                        Date currentDate,
                                                        ProductSearchCriteria 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

@Nonnull
List<Product> readActiveProductsByCategory(@Nonnull
                                                   Long categoryId,
                                                   @Nonnull
                                                   Date currentDate,
                                                   @Nonnull
                                                   int limit,
                                                   @Nonnull
                                                   int offset)

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:
uri - - the relative URL to look up the Product by
Returns:
List of products that match the passed in URI.

readAllActiveProducts

List<Product> readAllActiveProducts(@Nonnull
                                    Date currentDate)
Reads all products from the database that are currently active. That is, reads all products that are not archived and whose start and end dates surround the currentDate

Parameters:
currentDate -
Returns:
a list of all active products

readAllActiveProducts

List<Product> readAllActiveProducts(int page,
                                    int pageSize,
                                    Date currentDate)
Reads all products from the database that are currently active. That is, reads all products that are not archived and whose start and end dates surround the currentDate. This method differs from readAllActiveProducts(Date) 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.

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(Date currentDate)
Returns the number of products that are currently active.

Parameters:
currentDate -
Returns:
the number of currently active products


Copyright © 2013. All Rights Reserved.