org.broadleafcommerce.core.catalog.dao
Class CategoryDaoImpl

java.lang.Object
  extended by org.broadleafcommerce.core.catalog.dao.CategoryDaoImpl
All Implemented Interfaces:
CategoryDao

@Repository(value="blCategoryDao")
public class CategoryDaoImpl
extends Object
implements CategoryDao

Author:
Jeff Fischer

Field Summary
protected  Date cachedDate
           
protected  Long currentDateResolution
           
protected  javax.persistence.EntityManager em
           
protected  EntityConfiguration entityConfiguration
           
 
Constructor Summary
CategoryDaoImpl()
           
 
Method Summary
 Category create()
          Create a new Category instance.
 void delete(Category category)
          Removed the passed in Category instance from the datastore
 Category findCategoryByURI(String uri)
           
protected  Date getCurrentDateAfterFactoringInDateResolution()
           
 Long getCurrentDateResolution()
          Returns the number of milliseconds that the current date/time will be cached for queries before refreshing.
 List<Category> readActiveSubCategoriesByCategory(Category category)
          Retrieve a list of all active child categories of the passed in Category instance.
 List<Category> readActiveSubCategoriesByCategory(Category category, int limit, int offset)
          Retrieve a list of all active child categories of the passed in Category instance.
 List<Category> readAllCategories()
          Retrieve all categories in the datastore
 List<Category> readAllCategories(int limit, int offset)
          Retrieve a subset of all categories
 List<Category> readAllParentCategories()
           
 List<Product> readAllProducts()
          Retrieve all products in the datastore
 List<Product> readAllProducts(int limit, int offset)
           
 List<Category> readAllSubCategories(Category category)
          Retrieve a list of all child categories of the passed in Category instance
 List<Category> readAllSubCategories(Category category, int limit, int offset)
          Retrieve a list of all child categories of the passed in Category instance
 List<Category> readCategoriesByName(String categoryName)
          Retrieve a list of Category instances by name.
 List<Category> readCategoriesByName(String categoryName, int limit, int offset)
           
 Category readCategoryById(Long categoryId)
          Retrieve a Category instance by its primary key
 Category readCategoryByName(String categoryName)
          Deprecated. 
 Category save(Category category)
          Persist a Category instance to the datastore
 void setCurrentDateResolution(Long currentDateResolution)
          Sets the number of milliseconds that the current date/time will be cached for queries before refreshing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentDateResolution

protected Long currentDateResolution

cachedDate

protected Date cachedDate

em

protected javax.persistence.EntityManager em

entityConfiguration

protected EntityConfiguration entityConfiguration
Constructor Detail

CategoryDaoImpl

public CategoryDaoImpl()
Method Detail

getCurrentDateAfterFactoringInDateResolution

protected Date getCurrentDateAfterFactoringInDateResolution()

save

public Category save(Category category)
Description copied from interface: CategoryDao
Persist a Category instance to the datastore

Specified by:
save in interface CategoryDao
Parameters:
category - the Category instance
Returns:
the updated state of the passed in Category after being persisted

readCategoryById

public Category readCategoryById(Long categoryId)
Description copied from interface: CategoryDao
Retrieve a Category instance by its primary key

Specified by:
readCategoryById in interface CategoryDao
Parameters:
categoryId - the primary key of the Category
Returns:
the Category at the specified primary key

readCategoryByName

@Deprecated
public Category readCategoryByName(String categoryName)
Deprecated. 

Description copied from interface: CategoryDao
Retrieve a Category instance by its name. Broadleaf allows more than one category to have the same name. Calling this method could produce an exception in such situations. Use CategoryDao.readCategoriesByName(String) instead.

Specified by:
readCategoryByName in interface CategoryDao
Parameters:
categoryName - the name of the category
Returns:
the Category having the specified name

readAllParentCategories

public List<Category> readAllParentCategories()
Specified by:
readAllParentCategories in interface CategoryDao
Returns:
a list of all categories that do not have a defaultParentCategory set

readCategoriesByName

public List<Category> readCategoriesByName(String categoryName)
Description copied from interface: CategoryDao
Retrieve a list of Category instances by name.

Specified by:
readCategoriesByName in interface CategoryDao
Parameters:
categoryName - the name to search by
Returns:
the Category instances having the specified name

readCategoriesByName

public List<Category> readCategoriesByName(String categoryName,
                                           int limit,
                                           int offset)
Specified by:
readCategoriesByName in interface CategoryDao

readAllCategories

public List<Category> readAllCategories()
Description copied from interface: CategoryDao
Retrieve all categories in the datastore

Specified by:
readAllCategories in interface CategoryDao
Returns:
a list of all the Category instances in the datastore

readAllCategories

public List<Category> readAllCategories(int limit,
                                        int offset)
Description copied from interface: CategoryDao
Retrieve a subset of all categories

Specified by:
readAllCategories in interface CategoryDao
Parameters:
limit - the maximum number of results, defaults to 20
offset - the starting point in the record set, defaults to 0
Returns:

readAllProducts

public List<Product> readAllProducts()
Description copied from interface: CategoryDao
Retrieve all products in the datastore

Specified by:
readAllProducts in interface CategoryDao
Returns:
a list of all Category instances in the datastore, regardless of their category association

readAllProducts

public List<Product> readAllProducts(int limit,
                                     int offset)
Specified by:
readAllProducts in interface CategoryDao

readAllSubCategories

public List<Category> readAllSubCategories(Category category)
Description copied from interface: CategoryDao
Retrieve a list of all child categories of the passed in Category instance

Specified by:
readAllSubCategories in interface CategoryDao
Parameters:
category - the parent category
Returns:
a list of all child categories

readAllSubCategories

public List<Category> readAllSubCategories(Category category,
                                           int limit,
                                           int offset)
Description copied from interface: CategoryDao
Retrieve a list of all child categories of the passed in Category instance

Specified by:
readAllSubCategories in interface CategoryDao
Parameters:
category - the parent category
limit - the maximum number of results to return
offset - the starting point in the record set
Returns:
a list of all child categories

readActiveSubCategoriesByCategory

public List<Category> readActiveSubCategoriesByCategory(Category category)
Description copied from interface: CategoryDao
Retrieve a list of all active child categories of the passed in Category instance. This method bases its search on a current time value. To make the retrieval of values more efficient, the current time is cached for a configurable amount of time. See CategoryDao.getCurrentDateResolution()

Specified by:
readActiveSubCategoriesByCategory in interface CategoryDao
Parameters:
category - the parent category
Returns:
a list of all active child categories

readActiveSubCategoriesByCategory

public List<Category> readActiveSubCategoriesByCategory(Category category,
                                                        int limit,
                                                        int offset)
Description copied from interface: CategoryDao
Retrieve a list of all active child categories of the passed in Category instance. This method bases its search on a current time value. To make the retrieval of values more efficient, the current time is cached for a configurable amount of time. See CategoryDao.getCurrentDateResolution()

Specified by:
readActiveSubCategoriesByCategory in interface CategoryDao
Parameters:
category - the parent category
limit - the maximum number of results to return
offset - the starting point in the record set
Returns:
a list of all active child categories

getCurrentDateResolution

public Long getCurrentDateResolution()
Description copied from interface: CategoryDao
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.

Specified by:
getCurrentDateResolution in interface CategoryDao
Returns:
the milliseconds to cache the current date/time

setCurrentDateResolution

public void setCurrentDateResolution(Long currentDateResolution)
Description copied from interface: CategoryDao
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.

Specified by:
setCurrentDateResolution in interface CategoryDao
Parameters:
currentDateResolution - the milliseconds to cache the current date/time

delete

public void delete(Category category)
Description copied from interface: CategoryDao
Removed the passed in Category instance from the datastore

Specified by:
delete in interface CategoryDao
Parameters:
category - the Category instance to remove

create

public Category create()
Description copied from interface: CategoryDao
Create a new Category 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 Category to instantiate. To make Broadleaf instantiate your extension of Category 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.

Specified by:
create in interface CategoryDao
Returns:
a Category instance based on the Broadleaf entity configuration.

findCategoryByURI

public Category findCategoryByURI(String uri)
Specified by:
findCategoryByURI in interface CategoryDao


Copyright © 2013. All Rights Reserved.