org.broadleafcommerce.core.catalog.dao
Interface CategoryDao

All Known Implementing Classes:
CategoryDaoImpl

public interface CategoryDao

CategoryDao provides persistence access to Category instances.

Author:
Jeff Fischer
See Also:
Category, Product

Method Summary
 Category create()
          Create a new Category instance.
 void delete(Category category)
          Removed the passed in Category instance from the datastore
 java.lang.Long getCurrentDateResolution()
          Retrieve the value in milliseconds for how long the current data/time is cached when performing an active category query.
 java.util.List<Category> readActiveSubCategoriesByCategory(Category category)
          Retrieve a list of all active child categories of the passed in Category instance.
 java.util.List<Category> readAllCategories()
          Retrieve all categories in the datastore
 java.util.List<Product> readAllProducts()
          Retrieve all products in the datastore
 java.util.List<Category> readAllSubCategories(Category category)
          Retrieve a list of all child categories of the passed in Category instance
 java.util.List<Category> readCategoriesByName(java.lang.String categoryName)
          Retrieve a list of Category instances by name.
 Category readCategoryById(java.lang.Long categoryId)
          Retrieve a Category instance by its primary key
 Category readCategoryByName(java.lang.String categoryName)
          Deprecated. 
 Category save(Category category)
          Persist a Category instance to the datastore
 void setCurrentDateResolution(java.lang.Long currentDateResolution)
          Set the value in milliseconds for how long the current date/time is cached when performing an active category query.
 

Method Detail

readCategoryById

@Nonnull
Category readCategoryById(@Nonnull
                                  java.lang.Long categoryId)
Retrieve a Category instance by its primary key

Parameters:
categoryId - the primary key of the Category
Returns:
the Category at the specified primary key

readCategoryByName

@Nonnull
@Deprecated
Category readCategoryByName(@Nonnull
                                               java.lang.String categoryName)
Deprecated. 

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 readCategoriesByName(String) instead.

Parameters:
categoryName - the name of the category
Returns:
the Category having the specified name

readCategoriesByName

@Nonnull
java.util.List<Category> readCategoriesByName(@Nonnull
                                                      java.lang.String categoryName)
Retrieve a list of Category instances by name.

Parameters:
categoryName - the name to search by
Returns:
the Category instances having the specified name

save

@Nonnull
Category save(@Nonnull
                      Category category)
Persist a Category instance to the datastore

Parameters:
category - the Category instance
Returns:
the updated state of the passed in Category after being persisted

readAllCategories

@Nonnull
java.util.List<Category> readAllCategories()
Retrieve all categories in the datastore

Returns:
a list of all the Category instances in the datastore

readAllProducts

@Nonnull
java.util.List<Product> readAllProducts()
Retrieve all products in the datastore

Returns:
a list of all Category instances in the datastore, regardless of their category association

readAllSubCategories

@Nonnull
java.util.List<Category> readAllSubCategories(@Nonnull
                                                      Category category)
Retrieve a list of all child categories of the passed in Category instance

Parameters:
category - the parent category
Returns:
a list of all child categories

delete

void delete(@Nonnull
            Category category)
Removed the passed in Category instance from the datastore

Parameters:
category - the Category instance to remove

create

@Nonnull
Category create()
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.

Returns:
a Category instance based on the Broadleaf entity configuration.

readActiveSubCategoriesByCategory

@Nonnull
java.util.List<Category> readActiveSubCategoriesByCategory(Category category)
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 getCurrentDateResolution()

Parameters:
category - the parent category
Returns:
a list of all active child categories

getCurrentDateResolution

@Nonnull
java.lang.Long getCurrentDateResolution()
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.

Returns:
the value in milliseconds for how long the current date/time is cached

setCurrentDateResolution

void setCurrentDateResolution(@Nonnull
                              java.lang.Long currentDateResolution)
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.

Parameters:
currentDateResolution - the value in milliseconds for how long the current date/time is cached


Copyright © 2012. All Rights Reserved.