Package de.hybris.platform.category.impl
Class DefaultCategoryService
- java.lang.Object
-
- de.hybris.platform.servicelayer.internal.service.AbstractService
-
- de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
-
- de.hybris.platform.category.impl.DefaultCategoryService
-
- All Implemented Interfaces:
CategoryService
,java.io.Serializable
,org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanNameAware
,org.springframework.beans.factory.InitializingBean
public class DefaultCategoryService extends AbstractBusinessService implements CategoryService
Default implementation forCategoryService
.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
AbstractService.SerializableDTO
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
modelService, sessionService, txManager
-
Fields inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
tenant
-
-
Constructor Summary
Constructors Constructor Description DefaultCategoryService()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
disableSubcategoryRemovalCheck()
Disable subcategory removal check.void
enableSubcategoryRemovalCheck()
Enable subcategory removal check.java.util.Collection<CategoryModel>
getAllSubcategoriesForCategory(CategoryModel category)
Gets all subcategories for category and all subcategories recursively.java.util.Collection<CategoryModel>
getAllSupercategoriesForCategory(CategoryModel category)
Gets the all supercategories for categories.java.util.Collection<CategoryModel>
getCategoriesForCode(java.lang.String code)
Retrieves for the givencode
all foundCategoryModel
s.CategoryModel
getCategory(CatalogVersionModel catalogVersion, java.lang.String code)
Deprecated.since agesCategoryModel
getCategory(java.lang.String code)
Deprecated.since agesCategoryModel
getCategoryForCode(CatalogVersionModel catalogVersion, java.lang.String code)
Retrieves theCategoryModel
with the specifiedcode
which belonging to the specifiedcatalogVersion
.CategoryModel
getCategoryForCode(java.lang.String code)
Retrieves theCategoryModel
with the specificcode
.java.util.List<CategoryModel>
getCategoryPathForProduct(ProductModel product, java.lang.Class... includeOnlyCategories)
Gets the category path for product.java.util.List<CategoryModel>
getPath(CategoryModel category)
Deprecated.since agesjava.util.List<CategoryModel>
getPathForCategory(CategoryModel category)
Returns the path from root category to the givenCategoryModel
.java.util.Collection<java.util.List<CategoryModel>>
getPathsForCategory(CategoryModel category)
Returns all paths for thisCategoryModel
.java.util.Collection<CategoryModel>
getRootCategories(CatalogVersionModel catalogVersion)
Deprecated.since agesjava.util.Collection<CategoryModel>
getRootCategoriesForCatalogVersion(CatalogVersionModel catalogVersion)
Retrieves the rootCategoryModel
s of the specifiedCatalogVersionModel
.boolean
isEmpty(CategoryModel category)
Checks if theCategoryModel
has product or sub-category.boolean
isRoot(CategoryModel category)
Checks if the theCategoryModel
is a root category (has no super category).boolean
isSetAllowedPrincipalsRecursivelyDisabled()
Checks if the attributeCategoryConstants.DISABLE_SETALLOWEDPRINCIPAL_RECURSIVELY
exists in the session and evaluates its value.boolean
isSubcategoryRemovalCheckDisabled()
Checks if the attributeCategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECK
exists in the session and evaluates its value.void
setAllowedPrincipalsForAllRelatedCategories(CategoryModel category, java.util.List<PrincipalModel> newPrincipals)
Sets the principals for the category and all supercategories and subcategories of passed as parameter category.void
setAllowedPrincipalsForCategory(CategoryModel category, java.util.List<PrincipalModel> newPrincipals)
Sets the principals for the category.void
setCatalogVersionService(CatalogVersionService catalogVersionService)
void
setCategoryDao(CategoryDao categoryDao)
void
setCategoryPrincipalStrategy(CategoryPrincipalStrategy categoryPrincipalStrategy)
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractBusinessService
getModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManager
-
Methods inherited from class de.hybris.platform.servicelayer.internal.service.AbstractService
afterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplace
-
-
-
-
Method Detail
-
disableSubcategoryRemovalCheck
public void disableSubcategoryRemovalCheck()
Description copied from interface:CategoryService
Disable subcategory removal check. This method puts into the session flagCategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECK
with valueBoolean.TRUE
. This flag is next checked byCategoryRemovalValidator
to ensure that category should be checked against possible subcategories during remove.- Specified by:
disableSubcategoryRemovalCheck
in interfaceCategoryService
-
enableSubcategoryRemovalCheck
public void enableSubcategoryRemovalCheck()
Description copied from interface:CategoryService
Enable subcategory removal check. This method removes flagCategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECK
from the session and each possible remove action on category will always perform check against possible subcategories. Category which has subcategories will be not removed.- Specified by:
enableSubcategoryRemovalCheck
in interfaceCategoryService
-
isSubcategoryRemovalCheckDisabled
public boolean isSubcategoryRemovalCheckDisabled()
Description copied from interface:CategoryService
Checks if the attributeCategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECK
exists in the session and evaluates its value.- Specified by:
isSubcategoryRemovalCheckDisabled
in interfaceCategoryService
- Returns:
- true if
CategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECK
exists in the session AND the value is true
-
isSetAllowedPrincipalsRecursivelyDisabled
public boolean isSetAllowedPrincipalsRecursivelyDisabled()
Description copied from interface:CategoryService
Checks if the attributeCategoryConstants.DISABLE_SETALLOWEDPRINCIPAL_RECURSIVELY
exists in the session and evaluates its value. If the flag is set to false (default) then while setting the principals for a given category, the subcategories and supercategories are updated as well. Copying the prinicpals down to subcategories means mostly replacing them. Pulling the principals up however allows only adding new principals in supercategories, never remove.- Specified by:
isSetAllowedPrincipalsRecursivelyDisabled
in interfaceCategoryService
- Returns:
- true if
CategoryConstants.DISABLE_SETALLOWEDPRINCIPAL_RECURSIVELY
exists in the session AND the value is true
-
getCategoriesForCode
public java.util.Collection<CategoryModel> getCategoriesForCode(java.lang.String code)
Description copied from interface:CategoryService
Retrieves for the givencode
all foundCategoryModel
s.- Specified by:
getCategoriesForCode
in interfaceCategoryService
- Parameters:
code
- the code of the category.- Returns:
- all found
CategoryModel
s or an empty collection if no such category exists - See Also:
CatalogVersionService.setSessionCatalogVersions(Collection)
,CatalogVersionService.getSessionCatalogVersions()
,CatalogVersionService.addSessionCatalogVersion(CatalogVersionModel)
-
getCategoryPathForProduct
public java.util.List<CategoryModel> getCategoryPathForProduct(ProductModel product, java.lang.Class... includeOnlyCategories)
Description copied from interface:CategoryService
Gets the category path for product.- Specified by:
getCategoryPathForProduct
in interfaceCategoryService
- Parameters:
product
- the productincludeOnlyCategories
- classes which limits resulting path- Returns:
- the category path for product
-
getCategory
@Deprecated public CategoryModel getCategory(CatalogVersionModel catalogVersion, java.lang.String code)
Deprecated.since ages- Specified by:
getCategory
in interfaceCategoryService
- Returns:
- the found
CategoryModel
with the specifiedcode
.
-
getCategory
@Deprecated public CategoryModel getCategory(java.lang.String code)
Deprecated.since ages- Specified by:
getCategory
in interfaceCategoryService
- Parameters:
code
- the code of the to be foundCategoryModel
- Returns:
- the found
CategoryModel
ornull
if no category with this code exists
-
getCategoryForCode
public CategoryModel getCategoryForCode(CatalogVersionModel catalogVersion, java.lang.String code)
Description copied from interface:CategoryService
Retrieves theCategoryModel
with the specifiedcode
which belonging to the specifiedcatalogVersion
.- Specified by:
getCategoryForCode
in interfaceCategoryService
- Parameters:
catalogVersion
- theCatalogVersionModel
where the returned category should be foundcode
- the code of theCategoryModel
- Returns:
- the
CategoryModel
with the specifiedcode
and belonging to theCatalogVersionModel
-
getCategoryForCode
public CategoryModel getCategoryForCode(java.lang.String code)
Description copied from interface:CategoryService
Retrieves theCategoryModel
with the specificcode
.- Specified by:
getCategoryForCode
in interfaceCategoryService
- Parameters:
code
- the code of the to be foundCategoryModel
- Returns:
- found
CategoryModel
-
getPath
@Deprecated public java.util.List<CategoryModel> getPath(CategoryModel category)
Deprecated.since ages- Specified by:
getPath
in interfaceCategoryService
- Parameters:
category
- theCategoryModel
- Returns:
- the first found path for this category
-
getPathForCategory
public java.util.List<CategoryModel> getPathForCategory(CategoryModel category)
Description copied from interface:CategoryService
Returns the path from root category to the givenCategoryModel
. To get all super-categories useCategoryModel.getSupercategories()
.- Specified by:
getPathForCategory
in interfaceCategoryService
- Parameters:
category
- theCategoryModel
- Returns:
- the found path for this category
-
getPathsForCategory
public java.util.Collection<java.util.List<CategoryModel>> getPathsForCategory(CategoryModel category)
Description copied from interface:CategoryService
Returns all paths for thisCategoryModel
. Each path is a list of all categories in the path from root to this category.- Specified by:
getPathsForCategory
in interfaceCategoryService
- Parameters:
category
- the (sub)CategoryModel
- Returns:
- all paths for this
CategoryModel
, or empty collection if this category has no super-categories.
-
getRootCategories
@Deprecated public java.util.Collection<CategoryModel> getRootCategories(CatalogVersionModel catalogVersion)
Deprecated.since ages- Specified by:
getRootCategories
in interfaceCategoryService
- Returns:
- the found
CategoryModel
s with the specifiedcode
.
-
getRootCategoriesForCatalogVersion
public java.util.Collection<CategoryModel> getRootCategoriesForCatalogVersion(CatalogVersionModel catalogVersion)
Description copied from interface:CategoryService
Retrieves the rootCategoryModel
s of the specifiedCatalogVersionModel
.- Specified by:
getRootCategoriesForCatalogVersion
in interfaceCategoryService
- Returns:
- all found
CategoryModel
s or an empty collection if no root categories can be found
-
isEmpty
public boolean isEmpty(CategoryModel category)
Description copied from interface:CategoryService
Checks if theCategoryModel
has product or sub-category.- Specified by:
isEmpty
in interfaceCategoryService
- Parameters:
category
- the category to be checked- Returns:
- true if the
CategoryModel
has neither product nor sub-category
-
isRoot
public boolean isRoot(CategoryModel category)
Description copied from interface:CategoryService
Checks if the theCategoryModel
is a root category (has no super category).- Specified by:
isRoot
in interfaceCategoryService
- Parameters:
category
- the category to be checked- Returns:
- true if the
CategoryModel
is a root category, false otherwise.
-
setAllowedPrincipalsForCategory
public void setAllowedPrincipalsForCategory(CategoryModel category, java.util.List<PrincipalModel> newPrincipals)
Description copied from interface:CategoryService
Sets the principals for the category. The new principals will be set to theCategoryModel
so that the user rights can be defined specifically.- Specified by:
setAllowedPrincipalsForCategory
in interfaceCategoryService
- Parameters:
category
- the category where the principals will be applied tonewPrincipals
- the list with the new allowed principals of the category- See Also:
CategoryPrincipalStrategy.replacePrincipalsForCategory(CategoryModel, List)
-
setAllowedPrincipalsForAllRelatedCategories
public void setAllowedPrincipalsForAllRelatedCategories(CategoryModel category, java.util.List<PrincipalModel> newPrincipals)
Description copied from interface:CategoryService
Sets the principals for the category and all supercategories and subcategories of passed as parameter category. The new principals will be set to theCategoryModel
so that the user rights can be defined specifically.- Specified by:
setAllowedPrincipalsForAllRelatedCategories
in interfaceCategoryService
- Parameters:
category
- the category where the principals will be applied tonewPrincipals
- the list with the new allowed principals of the category- See Also:
CategoryPrincipalStrategy.replacePrincipalsForCategory(CategoryModel, List)
-
getAllSubcategoriesForCategory
public java.util.Collection<CategoryModel> getAllSubcategoriesForCategory(CategoryModel category)
Description copied from interface:CategoryService
Gets all subcategories for category and all subcategories recursively.- Specified by:
getAllSubcategoriesForCategory
in interfaceCategoryService
- Parameters:
category
- the category for which subcategories should be obtained- Returns:
- the collection of subcategories
-
getAllSupercategoriesForCategory
public java.util.Collection<CategoryModel> getAllSupercategoriesForCategory(CategoryModel category)
Description copied from interface:CategoryService
Gets the all supercategories for categories.- Specified by:
getAllSupercategoriesForCategory
in interfaceCategoryService
- Parameters:
category
- the category for which supercategories should be obtained- Returns:
- the collection of supercategories
-
setCatalogVersionService
public void setCatalogVersionService(CatalogVersionService catalogVersionService)
-
setCategoryDao
public void setCategoryDao(CategoryDao categoryDao)
-
setCategoryPrincipalStrategy
public void setCategoryPrincipalStrategy(CategoryPrincipalStrategy categoryPrincipalStrategy)
-
-