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  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
 Long getCurrentDateResolution()
          Retrieve the value in milliseconds for how long the current data/time is cached when performing an active category query.
 List<Category> readActiveSubCategoriesByCategory(Category category)
          Retrieve a list of all active child categories of the passed in Category instance.
 List<Category> readAllCategories()
          Retrieve all categories in the datastore
 List<Product> readAllProducts()
          Retrieve all products in the datastore
 List<Category> readAllSubCategories(Category category)
          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.
 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)
          Set the value in milliseconds for how long the current date/time is cached when performing an active category query.
 
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 Long currentDateResolution
Constructor Detail

CategoryDaoImpl

public CategoryDaoImpl()
Method Detail

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

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

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

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

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

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

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

getCurrentDateResolution

public Long getCurrentDateResolution()
Description copied from interface: CategoryDao
Retrieve the value in milliseconds for how long the current data/time is cached when performing an active category query. By caching the current date/time, the same query can be generated repeatedly, which allows the query cache to be utilized. The default value is 10000 milliseconds.

Specified by:
getCurrentDateResolution in interface CategoryDao
Returns:
the value in milliseconds for how long the current date/time is cached

setCurrentDateResolution

public void setCurrentDateResolution(Long currentDateResolution)
Description copied from interface: CategoryDao
Set the value in milliseconds for how long the current date/time is cached when performing an active category query. The default value is 10000 milliseconds.

Specified by:
setCurrentDateResolution in interface CategoryDao
Parameters:
currentDateResolution - the value in milliseconds for how long the current date/time is cached


Copyright © 2012. All Rights Reserved.