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
 java.util.List<Product> readActiveProductsByCategory(java.lang.Long categoryId, java.util.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
 java.util.List<Product> readActiveProductsBySku(java.lang.Long skuId, java.util.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.
 java.util.List<ProductSku> readActiveProductsBySkuOneToOne(java.lang.Long skuId, java.util.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(java.lang.Long productId)
          Retrieve a Product instance by its primary key
 java.util.List<Product> readProductsByCategory(java.lang.Long categoryId)
          Find all products related to the passed in category
 java.util.List<Product> readProductsByName(java.lang.String searchName)
          Find all Product instances whose name starts with or is equal to the passed in search parameter
 java.util.List<Product> readProductsBySku(java.lang.Long skuId)
          Find all the products related to the passed in sku
 java.util.List<ProductSku> readProductsBySkuOneToOne(java.lang.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
                                java.lang.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
java.util.List<Product> readProductsByName(@Nonnull
                                                   java.lang.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
java.util.List<Product> readActiveProductsByCategory(@Nonnull
                                                             java.lang.Long categoryId,
                                                             @Nonnull
                                                             java.util.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
java.util.List<Product> readProductsByCategory(@Nonnull
                                                       java.lang.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
java.util.List<Product> readProductsBySku(@Nonnull
                                                  java.lang.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
java.util.List<Product> readActiveProductsBySku(@Nonnull
                                                        java.lang.Long skuId,
                                                        @Nonnull
                                                        java.util.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
java.util.List<ProductSku> readProductsBySkuOneToOne(@Nonnull
                                                             java.lang.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
java.util.List<ProductSku> readActiveProductsBySkuOneToOne(@Nonnull
                                                                   java.lang.Long skuId,
                                                                   @Nonnull
                                                                   java.util.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.