Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * BroadleafCommerce Framework
   * %%
   * Copyright (C) 2009 - 2013 Broadleaf Commerce
   * %%
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * 
  *       http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  * #L%
  */
 package org.broadleafcommerce.core.catalog.domain;
 
 
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
 import  javax.annotation.Nonnull;
 import  javax.annotation.Nullable;

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(s):
btaylor
Jeff Fischer
See also:
CategoryImpl
 
 public interface Category extends Serializable {

    
Gets the primary key.

Returns:
the primary key
 
     @Nullable
     public Long getId();

    
Sets the primary key.

Parameters:
id the new primary key
 
     public void setId(@Nullable Long id);

    
Gets the name.

Returns:
the name
 
     @Nonnull
     public String getName();

    
Sets the name.

Parameters:
name the new name
 
     public void setName(@Nonnull String name);

    
Gets the default parent category.

Returns:
the default parent category
 
     @Nullable
     public Category getDefaultParentCategory();

    
Sets the default parent category.

Parameters:
defaultParentCategory the new default parent category
 
     public void setDefaultParentCategory(@Nullable Category defaultParentCategory);

    
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
    @Nullable
    public String getUrl();

    
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
    public void setUrl(@Nullable String url);

    
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
    @Nullable
    public String getUrlKey();

    
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
    @Nullable
    public String getGeneratedUrl();

    
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
    public void setUrlKey(@Nullable String urlKey);

    
Gets the description.

Returns:
the description
    @Nullable
    public String getDescription();

    
Sets the description.

Parameters:
description the new description
    public void setDescription(@Nullable String description);

    
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
    @Nullable
    public Date getActiveStartDate();

    
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
    public void setActiveStartDate(@Nullable Date activeStartDate);

    
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
    @Nullable
    public Date getActiveEndDate();

    
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
    public void setActiveEndDate(@Nullable Date activeEndDate);

    
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
    public boolean isActive();

    
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
    @Nullable
    public String getDisplayTemplate();

    
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
    public void setDisplayTemplate(@Nullable String displayTemplate);

    
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 is inefficient, so its use is highly discouraged.

Deprecated:
This approach is inherently inefficient and should no longer be used
Returns:
the child category url map
    @Deprecated
    @Nonnull
    public Map<String,List<Long>> getChildCategoryURLMap();

    
Set the child category url map. This approach is inefficient, so its use is highly discouraged.

Deprecated:
This approach is inherently inefficient and should no longer be used
Parameters:
childCategoryURLMap
    @Deprecated
    public void setChildCategoryURLMap(@Nonnull Map<StringList<Long>> childCategoryURLMap);

    
Gets the category images.

Deprecated:
replaced by getCategoryMedia()
Returns:
the category images
    @Deprecated
    @Nonnull
    public Map<StringStringgetCategoryImages();

    
Gets the category image.

Deprecated:
replaced by getCategoryMedia()
Parameters:
imageKey the image key
Returns:
the category image
    @Deprecated
    @Nullable
    public String getCategoryImage(@Nonnull String imageKey);

    
Sets the category images.

Deprecated:
replaced by setCategoryMedia(java.util.Map)
Parameters:
categoryImages the category images
    @Deprecated
    public void setCategoryImages(@Nonnull Map<StringStringcategoryImages);

    
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
    @Nonnull
    public Map<StringMediagetCategoryMedia() ;

    
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
    public void setCategoryMedia(@Nonnull Map<StringMediacategoryMedia);

    
Gets the long description.

Returns:
the long description
    @Nullable
    public String getLongDescription();

    
Sets the long description.

Parameters:
longDescription the new long description
    public void setLongDescription(@Nullable String longDescription);

    
Gets the featured products. Featured products are a special list of products you would like to showcase for this category.

Returns:
the featured products
    @Nonnull
    public List<FeaturedProductgetFeaturedProducts();

    
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
    public void setFeaturedProducts(@Nonnull List<FeaturedProductfeaturedProducts);

    
Returns a list of cross sale products that are related to this category.

Returns:
a list of cross sale products
    public List<RelatedProductgetCrossSaleProducts();

    
Sets the cross sale products that are related to this category.

Parameters:
crossSaleProducts
See also:
getCrossSaleProducts()
    public void setCrossSaleProducts(List<RelatedProductcrossSaleProducts);

    
Returns a list of cross sale products that are related to this category.

Returns:
a list of cross sale products
    public List<RelatedProductgetUpSaleProducts();

    
Sets the upsale products that are related to this category.

Parameters:
upSaleProducts
See also:
getUpSaleProducts()
    public void setUpSaleProducts(List<RelatedProductupSaleProducts);

    
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
    public List<RelatedProductgetCumulativeCrossSaleProducts();
    
    
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
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
Returns all of the SearchFacets that are directly associated with this Category

Returns:
related SearchFacets
    public List<CategorySearchFacetgetSearchFacets();

    
Sets the SearchFacets that are directly associated with this Category

Parameters:
searchFacets
    public void setSearchFacets(List<CategorySearchFacetsearchFacets);

    
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
    public void setExcludedSearchFacets(List<SearchFacetexcludedSearchFacets);

    
Gets the excluded SearchFacets

Returns:
the excluded SearchFacets
    public List<SearchFacetgetExcludedSearchFacets();

    
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
    public List<CategorySearchFacetgetCumulativeSearchFacets();
    
    
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:
    
    public List<CategorybuildCategoryHierarchy(List<CategorycurrentHierarchy);
    
    
Build the full category hierarchy by walking up the default category tree and the all parent category tree.

Parameters:
currentHierarchy
Returns:
the full hierarchy
    public List<CategorybuildFullCategoryHierarchy(List<CategorycurrentHierarchy);

    
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()
    public void setCategoryAttributesMap(Map<StringCategoryAttributecategoryAttributes);
    
    
Gets the attributes for this Category. In smaller sites, using these attributes might be preferred to extending the domain object itself.

Deprecated:
This will be replaced with getCategoryAttributesMap() in 3.1.0.
Returns:
See also:
getMappedCategoryAttributes()
    public List<CategoryAttributegetCategoryAttributes();

    
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.

Deprecated:
This will be replaced with setCategoryAttributesMap() in 3.1.0.
Returns:
    public void setCategoryAttributes(List<CategoryAttributecategoryAttributes);

    
Convenience method to get a CategoryAttribute by name

Deprecated:
This will be removed in 3.1.0
Parameters:
name
Returns:
See also:
getCategoryAttributes(), getMappedCategoryAttributes()
    public CategoryAttribute getCategoryAttributeByName(String name);

    
Convenience method to return the CategoryAttributes for the Category in an easily-consumable form

Deprecated:
This will be removed in 3.1.0
Returns:
Returns the type of inventory for this category

Returns:
the InventoryType for this category
    public InventoryType getInventoryType();

    
Sets the type of inventory for this category

Parameters:
inventoryType the InventoryType for this category
    public void setInventoryType(InventoryType inventoryType);
    
    
Returns the default fulfillment type for skus in this category. May be null.

Returns:
    public FulfillmentType getFulfillmentType();
    
    
Sets the default fulfillment type for skus in this category. May return null.

Parameters:
fulfillmentType
    public void setFulfillmentType(FulfillmentType fulfillmentType);

    
Gets the child categories. This list includes all categories, regardless of whether or not they are active.

Deprecated:
use getAllChildCategoryXrefs() instead.
Returns:
the list of active and inactive child categories.
    @Nonnull
    @Deprecated
    public List<CategorygetAllChildCategories();

    
Checks for child categories.

Returns:
true, if this category has any children (active or not)
    public boolean hasAllChildCategories();

    
Sets the list of child categories (active and inactive)

Deprecated:
Use setAllChildCategoryXrefs() instead.
Parameters:
childCategories the list of child categories
    @Deprecated
    public void setAllChildCategories(@Nonnull List<CategorychildCategories);

    
Gets the child categories. If child categories has not been previously set, then the list of active only categories will be returned.

Deprecated:
Use getChildCategoryXrefs() instead.
Returns:
the list of active child categories
    @Deprecated
    @Nonnull
    public List<CategorygetChildCategories();

    
Gets the child category ids. If child categories has not been previously set, then the list of active only categories will be returned. This method is optimized with Hydrated cache, which means that the algorithm required to harvest active child categories will not need to be rebuilt as long as the parent category (this category) is not evicted from second level cache.

Returns:
the list of active child category ids
    @Nonnull
    public List<LonggetChildCategoryIds();

    
Sets the all child category ids. This should be a list of active only child categories.

Parameters:
childCategoryIds the list of active child category ids.
    public void setChildCategoryIds(@Nonnull List<LongchildCategoryIds);

    
Checks for child categories.

Returns:
true, if this category contains any active child categories.
    public boolean hasChildCategories();

    
Sets the all child categories. This should be a list of active only child categories.

Deprecated:
Use setChildCategoryXrefs() instead.
Parameters:
childCategories the list of active child categories.
    @Deprecated
    public void setChildCategories(@Nonnull List<CategorychildCategories);
    public void setChildCategoryXrefs(List<CategoryXrefchildCategories);
    public void setAllChildCategoryXrefs(List<CategoryXrefchildCategories);
    public void setAllParentCategoryXrefs(List<CategoryXrefallParentCategories);

    
Retrieve all parent categories

Deprecated:
Use getAllParentCategoryXrefs() instead.
Returns:
the list of parent categories
    @Deprecated
    @Nonnull
    public List<CategorygetAllParentCategories();

    
Sets the list of parent categories

Deprecated:
Use setAllParentCategoryXrefs() instead.
Parameters:
allParentCategories the list of parent categories
    @Deprecated
    public void setAllParentCategories(@Nonnull List<CategoryallParentCategories);
    public void setAllProductXrefs(List<CategoryProductXrefallProducts);

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

Deprecated:
Use getActiveProductXrefs() instead.
Returns:
the list of active Products for this Category
See also:
Product.isActive()
    @Deprecated
    public List<ProductgetActiveProducts();

    
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()

Deprecated:
Use getAllProductXrefs() instead.
Returns:
the list of products associated with this category.
    @Deprecated
    @Nonnull
    public List<ProductgetAllProducts();

    
Set all the Product instances associated with this category.

Deprecated:
Use setAllProductXrefs() instead.
Parameters:
allProducts the list of products to associate with this category
    @Deprecated
    public void setAllProducts(@Nonnull List<ProductallProducts);

    
Returns the tax code of this category.

Returns:
taxCode
    public String getTaxCode();

    
Sets the tax code of this category.

Parameters:
taxCode
    public void setTaxCode(String taxCode);
New to GrepCode? Check out our FAQ X