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
 Category findCategoryByURI(String uri)
           
 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> 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<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)
          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
                                  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
                                               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
List<Category> readCategoriesByName(@Nonnull
                                            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

readCategoriesByName

@Nonnull
List<Category> readCategoriesByName(@Nonnull
                                            String categoryName,
                                            int limit,
                                            int offset)

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
List<Category> readAllCategories()
Retrieve all categories in the datastore

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

readAllCategories

@Nonnull
List<Category> readAllCategories(@Nonnull
                                         int limit,
                                         @Nonnull
                                         int offset)
Retrieve a subset of all categories

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

readAllProducts

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

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

readAllProducts

@Nonnull
List<Product> readAllProducts(@Nonnull
                                      int limit,
                                      @Nonnull
                                      int offset)

readAllSubCategories

@Nonnull
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

readAllSubCategories

@Nonnull
List<Category> readAllSubCategories(@Nonnull
                                            Category category,
                                            @Nonnull
                                            int limit,
                                            @Nonnull
                                            int offset)
Retrieve a list of all child categories of the passed in Category instance

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

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

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

readActiveSubCategoriesByCategory

@Nonnull
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

readActiveSubCategoriesByCategory

@Nonnull
List<Category> readActiveSubCategoriesByCategory(@Nonnull
                                                         Category category,
                                                         @Nonnull
                                                         int limit,
                                                         @Nonnull
                                                         int offset)
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
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

@Nonnull
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
                              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

findCategoryByURI

@Nonnull
Category findCategoryByURI(String uri)


Copyright © 2012. All Rights Reserved.