org.broadleafcommerce.core.catalog.dao
Class ProductDaoImpl

java.lang.Object
  extended by org.broadleafcommerce.core.catalog.dao.ProductDaoImpl
All Implemented Interfaces:
ProductDao

@Repository(value="blProductDao")
public class ProductDaoImpl
extends java.lang.Object
implements ProductDao

Author:
Jeff Fischer

Field Summary
protected  java.lang.Long currentDateResolution
           
protected  javax.persistence.EntityManager em
           
protected  EntityConfiguration entityConfiguration
           
 
Constructor Summary
ProductDaoImpl()
           
 
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.lang.Long getCurrentDateResolution()
           
 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
 void setCurrentDateResolution(java.lang.Long currentDateResolution)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

em

protected javax.persistence.EntityManager em

entityConfiguration

protected EntityConfiguration entityConfiguration

currentDateResolution

protected java.lang.Long currentDateResolution
Constructor Detail

ProductDaoImpl

public ProductDaoImpl()
Method Detail

save

public Product save(Product product)
Description copied from interface: ProductDao
Persist a Product instance to the datastore

Specified by:
save in interface ProductDao
Parameters:
product - the product instance
Returns:
the updated state of the product instance after being persisted

readProductById

public Product readProductById(java.lang.Long productId)
Description copied from interface: ProductDao
Retrieve a Product instance by its primary key

Specified by:
readProductById in interface ProductDao
Parameters:
productId - the primary key of the product
Returns:
the product instance at the specified primary key

readProductsByName

public java.util.List<Product> readProductsByName(java.lang.String searchName)
Description copied from interface: ProductDao
Find all Product instances whose name starts with or is equal to the passed in search parameter

Specified by:
readProductsByName in interface ProductDao
Parameters:
searchName - the partial or whole name to match
Returns:
the list of product instances that were search hits

readActiveProductsByCategory

public java.util.List<Product> readActiveProductsByCategory(java.lang.Long categoryId,
                                                            java.util.Date currentDate)
Description copied from interface: ProductDao
Find all products whose start and end dates are before and after the passed in date and who are related to the given category

Specified by:
readActiveProductsByCategory in interface ProductDao
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

public java.util.List<Product> readProductsByCategory(java.lang.Long categoryId)
Description copied from interface: ProductDao
Find all products related to the passed in category

Specified by:
readProductsByCategory in interface ProductDao
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

public java.util.List<Product> readProductsBySku(java.lang.Long skuId)
Description copied from interface: ProductDao
Find all the products related to the passed in sku

Specified by:
readProductsBySku in interface ProductDao
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.

readProductsBySkuOneToOne

public java.util.List<ProductSku> readProductsBySkuOneToOne(java.lang.Long skuId)
Description copied from interface: ProductDao
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.

Specified by:
readProductsBySkuOneToOne in interface ProductDao
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

readActiveProductsBySku

public java.util.List<Product> readActiveProductsBySku(java.lang.Long skuId,
                                                       java.util.Date currentDate)
Description copied from interface: ProductDao
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.

Specified by:
readActiveProductsBySku in interface ProductDao
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

readActiveProductsBySkuOneToOne

public java.util.List<ProductSku> readActiveProductsBySkuOneToOne(java.lang.Long skuId,
                                                                  java.util.Date currentDate)
Description copied from interface: ProductDao
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.

Specified by:
readActiveProductsBySkuOneToOne in interface ProductDao
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

public void delete(Product product)
Description copied from interface: ProductDao
Remove the passed in product instance from the datastore

Specified by:
delete in interface ProductDao
Parameters:
product - the product instance to remove

create

public Product create(ProductType productType)
Description copied from interface: ProductDao
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.

Specified by:
create in interface ProductDao
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.

getCurrentDateResolution

public java.lang.Long getCurrentDateResolution()

setCurrentDateResolution

public void setCurrentDateResolution(java.lang.Long currentDateResolution)


Copyright © 2012. All Rights Reserved.