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, ProductSku

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> 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> readActiveProductsBySku(Long skuId, 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 sku.
 List<ProductSku> readActiveProductsBySkuOneToOne(Long skuId, Date currentDate)
          Find all the ProductSku instances whose start and end dates are before and after the passed in date and who are related to the given sku.
 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> readProductsByName(String searchName)
          Find all Product instances whose name starts with or is equal to the passed in search parameter
 List<Product> readProductsBySku(Long skuId)
          Find all the products related to the passed in sku
 List<ProductSku> readProductsBySkuOneToOne(Long skuId)
          Find all the ProductSku instances related to the passed in sku.
 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

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

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

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

readProductsBySku

@Nonnull
List<Product> readProductsBySku(@Nonnull
                                        Long skuId)
Find all the products related to the passed in sku

Parameters:
skuId - the primary key of the sku to whom the resulting product list should be related
Returns:
the list of products qualified for the sku. Use this method if your product domain is modelled with a ManyToMany relationship between Product and Sku.

readActiveProductsBySku

@Nonnull
List<Product> readActiveProductsBySku(@Nonnull
                                              Long skuId,
                                              @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 sku. Use this method if your product domain is modelled with a ManyToMany relationship between Product and Sku.

Parameters:
skuId - the primary key of the sku 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 sku and date

readProductsBySkuOneToOne

@Nonnull
List<ProductSku> readProductsBySkuOneToOne(@Nonnull
                                                   Long skuId)
Find all the ProductSku instances related to the passed in sku. Use this method if your product domain is modelled with a OneToOne relationship between Product and Sku.

Parameters:
skuId - the primary key of the sku to whom the resulting ProductSku list should be related
Returns:
the list of ProductSku instances qualified for the sku

readActiveProductsBySkuOneToOne

@Nonnull
List<ProductSku> readActiveProductsBySkuOneToOne(@Nonnull
                                                         Long skuId,
                                                         @Nonnull
                                                         Date currentDate)
Find all the ProductSku instances whose start and end dates are before and after the passed in date and who are related to the given sku. Use this method if your product domain is modelled with a OneToOne relationship between Product and Sku.

Parameters:
skuId - the primary key of the sku to whom the resulting ProductSku list should be related
currentDate - the date for which the ProductSku instances should be checked against to determine their active state
Returns:
the list of ProductSku instances qualifed for the sku and date

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.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.


Copyright © 2012. All Rights Reserved.