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 voiddisableSubcategoryRemovalCheck()Disable subcategory removal check.voidenableSubcategoryRemovalCheck()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 givencodeall foundCategoryModels.CategoryModelgetCategory(CatalogVersionModel catalogVersion, java.lang.String code)Deprecated.since agesCategoryModelgetCategory(java.lang.String code)Deprecated.since agesCategoryModelgetCategoryForCode(CatalogVersionModel catalogVersion, java.lang.String code)Retrieves theCategoryModelwith the specifiedcodewhich belonging to the specifiedcatalogVersion.CategoryModelgetCategoryForCode(java.lang.String code)Retrieves theCategoryModelwith 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 rootCategoryModels of the specifiedCatalogVersionModel.booleanisEmpty(CategoryModel category)Checks if theCategoryModelhas product or sub-category.booleanisRoot(CategoryModel category)Checks if the theCategoryModelis a root category (has no super category).booleanisSetAllowedPrincipalsRecursivelyDisabled()Checks if the attributeCategoryConstants.DISABLE_SETALLOWEDPRINCIPAL_RECURSIVELYexists in the session and evaluates its value.booleanisSubcategoryRemovalCheckDisabled()Checks if the attributeCategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECKexists in the session and evaluates its value.voidsetAllowedPrincipalsForAllRelatedCategories(CategoryModel category, java.util.List<PrincipalModel> newPrincipals)Sets the principals for the category and all supercategories and subcategories of passed as parameter category.voidsetAllowedPrincipalsForCategory(CategoryModel category, java.util.List<PrincipalModel> newPrincipals)Sets the principals for the category.voidsetCatalogVersionService(CatalogVersionService catalogVersionService)voidsetCategoryDao(CategoryDao categoryDao)voidsetCategoryPrincipalStrategy(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:CategoryServiceDisable subcategory removal check. This method puts into the session flagCategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECKwith valueBoolean.TRUE. This flag is next checked byCategoryRemovalValidatorto ensure that category should be checked against possible subcategories during remove.- Specified by:
disableSubcategoryRemovalCheckin interfaceCategoryService
-
enableSubcategoryRemovalCheck
public void enableSubcategoryRemovalCheck()
Description copied from interface:CategoryServiceEnable subcategory removal check. This method removes flagCategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECKfrom 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:
enableSubcategoryRemovalCheckin interfaceCategoryService
-
isSubcategoryRemovalCheckDisabled
public boolean isSubcategoryRemovalCheckDisabled()
Description copied from interface:CategoryServiceChecks if the attributeCategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECKexists in the session and evaluates its value.- Specified by:
isSubcategoryRemovalCheckDisabledin interfaceCategoryService- Returns:
- true if
CategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECKexists in the session AND the value is true
-
isSetAllowedPrincipalsRecursivelyDisabled
public boolean isSetAllowedPrincipalsRecursivelyDisabled()
Description copied from interface:CategoryServiceChecks if the attributeCategoryConstants.DISABLE_SETALLOWEDPRINCIPAL_RECURSIVELYexists 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:
isSetAllowedPrincipalsRecursivelyDisabledin interfaceCategoryService- Returns:
- true if
CategoryConstants.DISABLE_SETALLOWEDPRINCIPAL_RECURSIVELYexists in the session AND the value is true
-
getCategoriesForCode
public java.util.Collection<CategoryModel> getCategoriesForCode(java.lang.String code)
Description copied from interface:CategoryServiceRetrieves for the givencodeall foundCategoryModels.- Specified by:
getCategoriesForCodein interfaceCategoryService- Parameters:
code- the code of the category.- Returns:
- all found
CategoryModels 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:CategoryServiceGets the category path for product.- Specified by:
getCategoryPathForProductin 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:
getCategoryin interfaceCategoryService- Returns:
- the found
CategoryModelwith the specifiedcode.
-
getCategory
@Deprecated public CategoryModel getCategory(java.lang.String code)
Deprecated.since ages- Specified by:
getCategoryin interfaceCategoryService- Parameters:
code- the code of the to be foundCategoryModel- Returns:
- the found
CategoryModelornullif no category with this code exists
-
getCategoryForCode
public CategoryModel getCategoryForCode(CatalogVersionModel catalogVersion, java.lang.String code)
Description copied from interface:CategoryServiceRetrieves theCategoryModelwith the specifiedcodewhich belonging to the specifiedcatalogVersion.- Specified by:
getCategoryForCodein interfaceCategoryService- Parameters:
catalogVersion- theCatalogVersionModelwhere the returned category should be foundcode- the code of theCategoryModel- Returns:
- the
CategoryModelwith the specifiedcodeand belonging to theCatalogVersionModel
-
getCategoryForCode
public CategoryModel getCategoryForCode(java.lang.String code)
Description copied from interface:CategoryServiceRetrieves theCategoryModelwith the specificcode.- Specified by:
getCategoryForCodein 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:
getPathin 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:CategoryServiceReturns the path from root category to the givenCategoryModel. To get all super-categories useCategoryModel.getSupercategories().- Specified by:
getPathForCategoryin 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:CategoryServiceReturns all paths for thisCategoryModel. Each path is a list of all categories in the path from root to this category.- Specified by:
getPathsForCategoryin 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:
getRootCategoriesin interfaceCategoryService- Returns:
- the found
CategoryModels with the specifiedcode.
-
getRootCategoriesForCatalogVersion
public java.util.Collection<CategoryModel> getRootCategoriesForCatalogVersion(CatalogVersionModel catalogVersion)
Description copied from interface:CategoryServiceRetrieves the rootCategoryModels of the specifiedCatalogVersionModel.- Specified by:
getRootCategoriesForCatalogVersionin interfaceCategoryService- Returns:
- all found
CategoryModels or an empty collection if no root categories can be found
-
isEmpty
public boolean isEmpty(CategoryModel category)
Description copied from interface:CategoryServiceChecks if theCategoryModelhas product or sub-category.- Specified by:
isEmptyin interfaceCategoryService- Parameters:
category- the category to be checked- Returns:
- true if the
CategoryModelhas neither product nor sub-category
-
isRoot
public boolean isRoot(CategoryModel category)
Description copied from interface:CategoryServiceChecks if the theCategoryModelis a root category (has no super category).- Specified by:
isRootin interfaceCategoryService- Parameters:
category- the category to be checked- Returns:
- true if the
CategoryModelis a root category, false otherwise.
-
setAllowedPrincipalsForCategory
public void setAllowedPrincipalsForCategory(CategoryModel category, java.util.List<PrincipalModel> newPrincipals)
Description copied from interface:CategoryServiceSets the principals for the category. The new principals will be set to theCategoryModelso that the user rights can be defined specifically.- Specified by:
setAllowedPrincipalsForCategoryin 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:CategoryServiceSets the principals for the category and all supercategories and subcategories of passed as parameter category. The new principals will be set to theCategoryModelso that the user rights can be defined specifically.- Specified by:
setAllowedPrincipalsForAllRelatedCategoriesin 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:CategoryServiceGets all subcategories for category and all subcategories recursively.- Specified by:
getAllSubcategoriesForCategoryin 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:CategoryServiceGets the all supercategories for categories.- Specified by:
getAllSupercategoriesForCategoryin 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)
-
-