org.broadleafcommerce.core.catalog.domain
Interface Category

All Superinterfaces:
Serializable
All Known Implementing Classes:
CategoryImpl

public interface Category
extends Serializable

Implementations of this interface are used to hold data about a Category. A category is a group of products.

You should implement this class if you want to make significant changes to how the Category is persisted. If you just want to add additional fields then you should extend CategoryImpl.

Author:
btaylor, Jeff Fischer
See Also:
CategoryImpl}

Method Summary
 List<Category> buildCategoryHierarchy(List<Category> currentHierarchy)
          Build category hierarchy by walking the default category tree up to the root category.
 List<Category> buildFullCategoryHierarchy(List<Category> currentHierarchy)
          Build the full category hierarchy by walking up the default category tree and the all parent category tree.
 Date getActiveEndDate()
          Gets the active end date.
 List<Product> getActiveProducts()
          Convenience method to retrieve all of this Category's Products filtered by active.
 Date getActiveStartDate()
          Gets the active start date.
 List<Category> getAllChildCategories()
          Gets the child categories.
 List<Category> getAllParentCategories()
          Retrieve all parent categories
 List<Product> getAllProducts()
          Retrieve all the Product instances associated with this category.
 CategoryAttribute getCategoryAttributeByName(String name)
          Convenience method to get a CategoryAttribute by name
 List<CategoryAttribute> getCategoryAttributes()
          Gets the attributes for this Category.
 String getCategoryImage(String imageKey)
          Deprecated. replaced by getCategoryMedia()
 Map<String,String> getCategoryImages()
          Deprecated. replaced by getCategoryMedia()
 Map<String,Media> getCategoryMedia()
          Gets the category media map.
 List<Category> getChildCategories()
          Gets the child categories.
 Map<String,List<Long>> getChildCategoryURLMap()
          Gets the child category url map.
 List<RelatedProduct> getCrossSaleProducts()
          Returns a list of cross sale products that are related to this category.
 List<RelatedProduct> getCumulativeCrossSaleProducts()
          Returns a list of the cross sale products in this category as well as all cross sale products in all parent categories of this category.
 List<FeaturedProduct> getCumulativeFeaturedProducts()
          Returns a list of the featured products in this category as well as all featured products in all parent categories of this category.
 List<CategorySearchFacet> getCumulativeSearchFacets()
          Returns a list of CategorySearchFacets that takes into consideration the search facets for this Category, the search facets for all parent categories, and the search facets that should be excluded from this Category.
 List<RelatedProduct> getCumulativeUpSaleProducts()
          Returns a list of the upsale products in this category as well as all upsale products in all parent categories of this category.
 Category getDefaultParentCategory()
          Gets the default parent category.
 String getDescription()
          Gets the description.
 String getDisplayTemplate()
          Gets the display template.
 List<SearchFacet> getExcludedSearchFacets()
          Gets the excluded SearchFacets
 List<FeaturedProduct> getFeaturedProducts()
          Gets the featured products.
 String getGeneratedUrl()
          Creates the SEO url starting from this category and recursing up the hierarchy of default parent categories until the topmost category is reached.
 Long getId()
          Gets the primary key.
 String getLongDescription()
          Gets the long description.
 Map<String,CategoryAttribute> getMappedCategoryAttributes()
          Convenience method to return the CategoryAttributes for the Category in an easily-consumable form
 String getName()
          Gets the name.
 List<CategorySearchFacet> getSearchFacets()
          Returns all of the SearchFacets that are directly associated with this Category
 List<RelatedProduct> getUpSaleProducts()
          Returns a list of cross sale products that are related to this category.
 String getUrl()
          Gets the url.
 String getUrlKey()
          Gets the url key.
 boolean hasAllChildCategories()
          Checks for child categories.
 boolean hasChildCategories()
          Checks for child categories.
 boolean isActive()
          Checks if is active.
 void setActiveEndDate(Date activeEndDate)
          Sets the active end date.
 void setActiveStartDate(Date activeStartDate)
          Sets the active start date.
 void setAllChildCategories(List<Category> childCategories)
          Sets the list of child categories (active and inactive)
 void setAllParentCategories(List<Category> allParentCategories)
          Sets the list of parent categories
 void setAllProducts(List<Product> allProducts)
          Set all the Product instances associated with this category.
 void setCategoryAttributes(List<CategoryAttribute> categoryAttributes)
          Sets the attributes for this Category.
 void setCategoryImages(Map<String,String> categoryImages)
          Deprecated. replaced by setCategoryMedia(java.util.Map)
 void setCategoryMedia(Map<String,Media> categoryMedia)
          Sets the category media.
 void setChildCategories(List<Category> childCategories)
          Sets the all child categories.
 void setChildCategoryURLMap(Map<String,List<Long>> childCategoryURLMap)
          Included to support the HydratedCacheJPAListener
 void setCrossSaleProducts(List<RelatedProduct> crossSaleProducts)
          Sets the cross sale products that are related to this category.
 void setDefaultParentCategory(Category defaultParentCategory)
          Sets the default parent category.
 void setDescription(String description)
          Sets the description.
 void setDisplayTemplate(String displayTemplate)
          Sets the display template.
 void setExcludedSearchFacets(List<SearchFacet> excludedSearchFacets)
          Sets the SearchFacets that should not be rendered by this Category.
 void setFeaturedProducts(List<FeaturedProduct> featuredProducts)
          Sets the featured products.
 void setId(Long id)
          Sets the primary key.
 void setLongDescription(String longDescription)
          Sets the long description.
 void setName(String name)
          Sets the name.
 void setSearchFacets(List<CategorySearchFacet> searchFacets)
          Sets the SearchFacets that are directly associated with this Category
 void setUpSaleProducts(List<RelatedProduct> upSaleProducts)
          Sets the upsale products that are related to this category.
 void setUrl(String url)
          Sets the url.
 void setUrlKey(String urlKey)
          Sets the url key.
 

Method Detail

getId

@Nullable
Long getId()
Gets the primary key.

Returns:
the primary key

setId

void setId(@Nullable
           Long id)
Sets the primary key.

Parameters:
id - the new primary key

getName

@Nonnull
String getName()
Gets the name.

Returns:
the name

setName

void setName(@Nonnull
             String name)
Sets the name.

Parameters:
name - the new name

getDefaultParentCategory

@Nullable
Category getDefaultParentCategory()
Gets the default parent category.

Returns:
the default parent category

setDefaultParentCategory

void setDefaultParentCategory(@Nullable
                              Category defaultParentCategory)
Sets the default parent category.

Parameters:
defaultParentCategory - the new default parent category

getAllParentCategories

@Nonnull
List<Category> getAllParentCategories()
Retrieve all parent categories

Returns:
the list of parent categories

setAllParentCategories

void setAllParentCategories(@Nonnull
                            List<Category> allParentCategories)
Sets the list of parent categories

Parameters:
allParentCategories - the list of parent categories

getUrl

@Nullable
String getUrl()
Gets the url. The url represents the presentation layer destination for this category. For example, if using Spring MVC, you could send the user to this destination by returning "redirect:"+currentCategory.getUrl(); from a controller.

Returns:
the url for the presentation layer component for this category

setUrl

void setUrl(@Nullable
            String url)
Sets the url. The url represents the presentation layer destination for this category. For example, if using Spring MVC, you could send the user to this destination by returning "redirect:"+currentCategory.getUrl(); from a controller.

Parameters:
url - the new url for the presentation layer component for this category

getUrlKey

@Nullable
String getUrlKey()
Gets the url key. The url key is used as part of SEO url generation for this category. Each segment of the url leading to a category is comprised of the url keys of the various associated categories in a hierarchy leading to this one. If the url key is null, the the name for the category formatted with dashes for spaces.

Returns:
the url key for this category to appear in the SEO url

getGeneratedUrl

@Nullable
String getGeneratedUrl()
Creates the SEO url starting from this category and recursing up the hierarchy of default parent categories until the topmost category is reached. The url key for each category is used for each segment of the SEO url.

Returns:
the generated SEO url for this category

setUrlKey

void setUrlKey(@Nullable
               String urlKey)
Sets the url key. The url key is used as part of SEO url generation for this category. Each segment of the url leading to a category is comprised of the url keys of the various associated categories in a hierarchy leading to this one.

Parameters:
urlKey - the new url key for this category to appear in the SEO url

getDescription

@Nullable
String getDescription()
Gets the description.

Returns:
the description

setDescription

void setDescription(@Nullable
                    String description)
Sets the description.

Parameters:
description - the new description

getActiveStartDate

@Nullable
Date getActiveStartDate()
Gets the active start date. If the current date is before activeStartDate, then this category will not be visible on the site.

Returns:
the active start date

setActiveStartDate

void setActiveStartDate(@Nullable
                        Date activeStartDate)
Sets the active start date. If the current date is before activeStartDate, then this category will not be visible on the site.

Parameters:
activeStartDate - the new active start date

getActiveEndDate

@Nullable
Date getActiveEndDate()
Gets the active end date. If the current date is after activeEndDate, the this category will not be visible on the site.

Returns:
the active end date

setActiveEndDate

void setActiveEndDate(@Nullable
                      Date activeEndDate)
Sets the active end date. If the current date is after activeEndDate, the this category will not be visible on the site.

Parameters:
activeEndDate - the new active end date

isActive

boolean isActive()
Checks if is active. Returns true if the startDate is null or if the current date is after the start date, or if the endDate is null or if the current date is before the endDate.

Returns:
true, if is active

getDisplayTemplate

@Nullable
String getDisplayTemplate()
Gets the display template. The display template can be used to help create a unique key that drives the presentation layer destination for this category. For example, if using Spring MVC, you might derive the view destination in this way: view = categoryTemplatePrefix + currentCategory.getDisplayTemplate();

Returns:
the display template

setDisplayTemplate

void setDisplayTemplate(@Nullable
                        String displayTemplate)
Sets the display template. The display template can be used to help create a unique key that drives the presentation layer destination for this category. For example, if using Spring MVC, you might derive the view destination in this way: view = categoryTemplatePrefix + currentCategory.getDisplayTemplate();

Parameters:
displayTemplate - the new display template

getChildCategoryURLMap

@Nonnull
Map<String,List<Long>> getChildCategoryURLMap()
Gets the child category url map. This map is keyed off of the getGeneratedUrl() values for this category and all of its child categories. By calling get on this map using the generated url for a given category, you will receive the list of immediate child categories. This lifecycle for this map is maintained via the HydratedCacheJPAListener. This listener keeps this map in a separate cache from the normal Hibernate level 2 cache, but will honor cache region settings for this entity, resulting in this map being evicted from its cache when this entity is removed from the Hibernate level 2 cache.

Returns:
the child category url map
See Also:
HydratedSetup

setChildCategoryURLMap

void setChildCategoryURLMap(@Nonnull
                            Map<String,List<Long>> childCategoryURLMap)
Included to support the HydratedCacheJPAListener

Parameters:
childCategoryURLMap -
See Also:
HydratedSetup

getAllChildCategories

@Nonnull
List<Category> getAllChildCategories()
Gets the child categories. This list includes all categories, regardless of whether or not they are active.

Returns:
the list of active and inactive child categories.

hasAllChildCategories

boolean hasAllChildCategories()
Checks for child categories.

Returns:
true, if this category has any children (active or not)

setAllChildCategories

void setAllChildCategories(@Nonnull
                           List<Category> childCategories)
Sets the list of child categories (active and inactive)

Parameters:
childCategories - the list of child categories

getChildCategories

@Nonnull
List<Category> getChildCategories()
Gets the child categories. If child categories has not been previously set, then the list of active only categories will be returned.

Returns:
the list of active child categories

hasChildCategories

boolean hasChildCategories()
Checks for child categories.

Returns:
true, if this category contains any active child categories.

setChildCategories

void setChildCategories(@Nonnull
                        List<Category> childCategories)
Sets the all child categories. This should be a list of active only child categories.

Parameters:
childCategories - the list of active child categories.

getCategoryImages

@Deprecated
@Nonnull
Map<String,String> getCategoryImages()
Deprecated. replaced by getCategoryMedia()

Gets the category images.

Returns:
the category images

getCategoryImage

@Deprecated
@Nullable
String getCategoryImage(@Nonnull
                                            String imageKey)
Deprecated. replaced by getCategoryMedia()

Gets the category image.

Parameters:
imageKey - the image key
Returns:
the category image

setCategoryImages

@Deprecated
void setCategoryImages(@Nonnull
                                  Map<String,String> categoryImages)
Deprecated. replaced by setCategoryMedia(java.util.Map)

Sets the category images.

Parameters:
categoryImages - the category images

getCategoryMedia

@Nonnull
Map<String,Media> getCategoryMedia()
Gets the category media map. The key is of arbitrary meaning and the Media instance stores information about the media itself (image url, etc...)

Returns:
the category Media

setCategoryMedia

void setCategoryMedia(@Nonnull
                      Map<String,Media> categoryMedia)
Sets the category media. The key is of arbitrary meaning and the Media instance stores information about the media itself (image url, etc...)

Parameters:
categoryMedia - the category media

getLongDescription

@Nullable
String getLongDescription()
Gets the long description.

Returns:
the long description

setLongDescription

void setLongDescription(@Nullable
                        String longDescription)
Sets the long description.

Parameters:
longDescription - the new long description

getFeaturedProducts

@Nonnull
List<FeaturedProduct> getFeaturedProducts()
Gets the featured products. Featured products are a special list of products you would like to showcase for this category.

Returns:
the featured products

setFeaturedProducts

void setFeaturedProducts(@Nonnull
                         List<FeaturedProduct> featuredProducts)
Sets the featured products. Featured products are a special list of products you would like to showcase for this category.

Parameters:
featuredProducts - the featured products

getActiveProducts

List<Product> getActiveProducts()
Convenience method to retrieve all of this Category's Products filtered by active. If you want all of the Products (whether inactive or not) consider using getAllProducts().

Returns:
the list of active Products for this Category
See Also:
Product#isActive()}

getAllProducts

@Nonnull
List<Product> getAllProducts()
Retrieve all the Product instances associated with this category.
Note: this method does not take into account whether or not the Products are active or not. If you need this functionality, use getActiveProducts()

Returns:
the list of products associated with this category.

setAllProducts

void setAllProducts(@Nonnull
                    List<Product> allProducts)
Set all the Product instances associated with this category.

Parameters:
allProducts - the list of products to associate with this category

getCrossSaleProducts

List<RelatedProduct> getCrossSaleProducts()
Returns a list of cross sale products that are related to this category.

Returns:
a list of cross sale products

setCrossSaleProducts

void setCrossSaleProducts(List<RelatedProduct> crossSaleProducts)
Sets the cross sale products that are related to this category.

Parameters:
crossSaleProducts -
See Also:
getCrossSaleProducts()

getUpSaleProducts

List<RelatedProduct> getUpSaleProducts()
Returns a list of cross sale products that are related to this category.

Returns:
a list of cross sale products

setUpSaleProducts

void setUpSaleProducts(List<RelatedProduct> upSaleProducts)
Sets the upsale products that are related to this category.

Parameters:
upSaleProducts -
See Also:
getUpSaleProducts()

getCumulativeCrossSaleProducts

List<RelatedProduct> getCumulativeCrossSaleProducts()
Returns a list of the cross sale products in this category as well as all cross sale products in all parent categories of this category.

Returns:
the cumulative cross sale products

getCumulativeUpSaleProducts

List<RelatedProduct> getCumulativeUpSaleProducts()
Returns a list of the upsale products in this category as well as all upsale products in all parent categories of this category.

Returns:
the cumulative upsale products

getCumulativeFeaturedProducts

List<FeaturedProduct> getCumulativeFeaturedProducts()
Returns a list of the featured products in this category as well as all featured products in all parent categories of this category.

Returns:
the cumulative featured products

getSearchFacets

List<CategorySearchFacet> getSearchFacets()
Returns all of the SearchFacets that are directly associated with this Category

Returns:
related SearchFacets

setSearchFacets

void setSearchFacets(List<CategorySearchFacet> searchFacets)
Sets the SearchFacets that are directly associated with this Category

Parameters:
searchFacets -

setExcludedSearchFacets

void setExcludedSearchFacets(List<SearchFacet> excludedSearchFacets)
Sets the SearchFacets that should not be rendered by this Category. Typically, this will include facets from parent categories that do not apply to this category.

Parameters:
excludedSearchFacets -

getExcludedSearchFacets

List<SearchFacet> getExcludedSearchFacets()
Gets the excluded SearchFacets

Returns:
the excluded SearchFacets

getCumulativeSearchFacets

List<CategorySearchFacet> getCumulativeSearchFacets()
Returns a list of CategorySearchFacets that takes into consideration the search facets for this Category, the search facets for all parent categories, and the search facets that should be excluded from this Category. This method will order the resulting list based on the CategorySearchFacet#getPosition() method for each category level. That is, the facets on this Category will be ordered by their position relative to each other with the ordered parent facets after that, etc.

Returns:
the current active search facets for this category and all parent categories

buildCategoryHierarchy

List<Category> buildCategoryHierarchy(List<Category> currentHierarchy)
Build category hierarchy by walking the default category tree up to the root category. If the passed in tree is null then create the initial list.

Parameters:
currentHierarchy -
Returns:

buildFullCategoryHierarchy

List<Category> buildFullCategoryHierarchy(List<Category> currentHierarchy)
Build the full category hierarchy by walking up the default category tree and the all parent category tree.

Parameters:
currentHierarchy -
Returns:
the full hierarchy

getCategoryAttributes

List<CategoryAttribute> getCategoryAttributes()
Gets the attributes for this Category. In smaller sites, using these attributes might be preferred to extending the domain object itself.

Returns:
See Also:
#getMappedCategoryAttributes()}

setCategoryAttributes

void setCategoryAttributes(List<CategoryAttribute> categoryAttributes)
Sets the attributes for this Category. In smaller sites, using these attributes might be preferred to extending the domain object and creating a new table to store custom properties.


getCategoryAttributeByName

CategoryAttribute getCategoryAttributeByName(String name)
Convenience method to get a CategoryAttribute by name

Parameters:
name -
Returns:
See Also:
#getCategoryAttributes()}, {@link #getMappedCategoryAttributes()}

getMappedCategoryAttributes

Map<String,CategoryAttribute> getMappedCategoryAttributes()
Convenience method to return the CategoryAttributes for the Category in an easily-consumable form

Returns:


Copyright © 2012. All Rights Reserved.