public interface CategoryService
CategoryModel. Please be aware that since CategoryModel is catalog version
aware, all methods of this service will work according to the active session catalog versions (see
CatalogVersionService.setSessionCatalogVersions(Collection) for more details). So in consequence, the methods
may return different results for different session users. If required, the following example shows how to temporarily
switch these active catalog versions without changing the enclosing callers session context:
SessionService sessionService = ...;
CatalogVersionService catalogVersionService = ...;
CatalogVersionModel myCatalogVersion = ...;
Collection<CategoryModel> rootCategories = (Collection<CategoryModel>) sessionService
.executeInLocalView(new SessionExecutionBody()
{
public Object execute()
{
catalogVersionService.setSessionCatalogVersions(Collections.singleton(myCatalogVersion));
return categoryService.getRootCategoriesForCatalogVersion(myCatalogVersion);
}
});
CatalogVersionService| Modifier and Type | Method and 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 given
code all found CategoryModels. |
CategoryModel |
getCategory(CatalogVersionModel catalogVersion,
java.lang.String code)
Deprecated.
since 4.3, please use
getCategoryForCode(CatalogVersionModel, String). |
CategoryModel |
getCategory(java.lang.String code)
Deprecated.
since 4.3, please use
getCategoryForCode(String) or getCategoriesForCode(String).
Retrieves the first found CategoryModel for the given code. |
CategoryModel |
getCategoryForCode(CatalogVersionModel catalogVersion,
java.lang.String code)
Retrieves the
CategoryModel with the specified code which belonging to the specified
catalogVersion. |
CategoryModel |
getCategoryForCode(java.lang.String code)
Retrieves the
CategoryModel with the specific code. |
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 4.3, please use
getPathForCategory(CategoryModel). Returns the path from the given
CategoryModel down to the root category. This method should be used only in cases without
multiple super-categories; otherwise it cannot be predicted which path is chosen! |
java.util.List<CategoryModel> |
getPathForCategory(CategoryModel category)
Returns the path from root category to the given
CategoryModel. |
java.util.Collection<java.util.List<CategoryModel>> |
getPathsForCategory(CategoryModel category)
Returns all paths for this
CategoryModel. |
java.util.Collection<CategoryModel> |
getRootCategories(CatalogVersionModel catalogVersion)
Deprecated.
since 4.3, please use
getRootCategoriesForCatalogVersion(CatalogVersionModel). |
java.util.Collection<CategoryModel> |
getRootCategoriesForCatalogVersion(CatalogVersionModel catalogVersion)
Retrieves the root
CategoryModels of the specified CatalogVersionModel. |
boolean |
isEmpty(CategoryModel category)
Checks if the
CategoryModel has product or sub-category. |
boolean |
isRoot(CategoryModel category)
Checks if the the
CategoryModel is a root category (has no super category). |
default boolean |
isSetAllowedPrincipalsRecursivelyDisabled()
Checks if the attribute
CategoryConstants.DISABLE_SETALLOWEDPRINCIPAL_RECURSIVELY exists in the session
and evaluates its value. |
boolean |
isSubcategoryRemovalCheckDisabled()
Checks if the attribute
CategoryConstants.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.
|
@Deprecated java.util.Collection<CategoryModel> getRootCategories(CatalogVersionModel catalogVersion)
getRootCategoriesForCatalogVersion(CatalogVersionModel).CategoryModels with the specified code.java.util.Collection<CategoryModel> getRootCategoriesForCatalogVersion(CatalogVersionModel catalogVersion)
CategoryModels of the specified CatalogVersionModel.CategoryModels or an empty collection if no root categories can be foundjava.lang.IllegalArgumentException - if the catalogVersion is null.@Deprecated CategoryModel getCategory(java.lang.String code)
getCategoryForCode(String) or getCategoriesForCode(String).
Retrieves the first found CategoryModel for the given code.code - the code of the to be found CategoryModelCategoryModel or null if no category with this code existsCategoryModel getCategoryForCode(java.lang.String code)
CategoryModel with the specific code.code - the code of the to be found CategoryModelCategoryModelUnknownIdentifierException - if no category with the specified code can be found.AmbiguousIdentifierException - if more than one category with the specified code and catalogVersion was
found.java.lang.IllegalArgumentException - if parameter code is null.java.util.Collection<CategoryModel> getCategoriesForCode(java.lang.String code)
code all found CategoryModels.code - the code of the category.CategoryModels or an empty collection if no such category existsCatalogVersionService.setSessionCatalogVersions(Collection),
CatalogVersionService.getSessionCatalogVersions(),
CatalogVersionService.addSessionCatalogVersion(CatalogVersionModel)@Deprecated CategoryModel getCategory(CatalogVersionModel catalogVersion, java.lang.String code)
getCategoryForCode(CatalogVersionModel, String).CategoryModel with the specified code.CategoryModel getCategoryForCode(CatalogVersionModel catalogVersion, java.lang.String code)
CategoryModel with the specified code which belonging to the specified
catalogVersion.catalogVersion - the CatalogVersionModel where the returned category should be foundcode - the code of the CategoryModelCategoryModel with the specified code and belonging to the
CatalogVersionModelUnknownIdentifierException - if no category with the specified code and catalogVersion can be found.AmbiguousIdentifierException - if more than one category with the specified code and catalogVersion was
found.java.lang.IllegalArgumentException - if parameter code or catalogVersion is null.@Deprecated java.util.List<CategoryModel> getPath(CategoryModel category)
getPathForCategory(CategoryModel). Returns the path from the given
CategoryModel down to the root category. This method should be used only in cases without
multiple super-categories; otherwise it cannot be predicted which path is chosen!category - the CategoryModeljava.lang.IllegalArgumentException - if parameter category is null.java.util.List<CategoryModel> getCategoryPathForProduct(ProductModel product, java.lang.Class... includeOnlyCategories)
product - the productincludeOnlyCategories - classes which limits resulting pathjava.util.List<CategoryModel> getPathForCategory(CategoryModel category)
CategoryModel. To get all super-categories use
CategoryModel.getSupercategories().category - the CategoryModeljava.lang.IllegalArgumentException - if parameter category is null.AmbiguousIdentifierException - if more than one path was found.java.util.Collection<java.util.List<CategoryModel>> getPathsForCategory(CategoryModel category)
CategoryModel. Each path is a list of all categories in the path from
root to this category.category - the (sub)CategoryModelCategoryModel, or empty collection if this category has no super-categories.java.lang.IllegalArgumentException - if parameter category is null.boolean isEmpty(CategoryModel category)
CategoryModel has product or sub-category.category - the category to be checkedCategoryModel has neither product nor sub-categoryjava.lang.IllegalArgumentException - if parameter category is null.boolean isRoot(CategoryModel category)
CategoryModel is a root category (has no super category).category - the category to be checkedCategoryModel is a root category, false otherwise.java.lang.IllegalArgumentException - if parameter category is null.void setAllowedPrincipalsForCategory(CategoryModel category, java.util.List<PrincipalModel> newPrincipals)
CategoryModel so that the user
rights can be defined specifically.category - the category where the principals will be applied tonewPrincipals - the list with the new allowed principals of the categoryjava.lang.IllegalArgumentException - if parameter category is null or newPrincipals is
null.CategoryPrincipalStrategy.replacePrincipalsForCategory(CategoryModel, List)void setAllowedPrincipalsForAllRelatedCategories(CategoryModel category, java.util.List<PrincipalModel> newPrincipals)
CategoryModel so that the user rights can be defined specifically.category - the category where the principals will be applied tonewPrincipals - the list with the new allowed principals of the categoryjava.lang.IllegalArgumentException - if parameter category is null or newPrincipals is
null.CategoryPrincipalStrategy.replacePrincipalsForCategory(CategoryModel, List)void disableSubcategoryRemovalCheck()
CategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECK with value
Boolean.TRUE. This flag is next checked by
CategoryRemovalValidator to ensure that category should be
checked against possible subcategories during remove.void enableSubcategoryRemovalCheck()
CategoryConstants.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.boolean isSubcategoryRemovalCheckDisabled()
CategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECK exists in the session and
evaluates its value.CategoryConstants.DISABLE_SUBCATEGORY_REMOVALCHECK exists in the session AND the
value is truedefault boolean isSetAllowedPrincipalsRecursivelyDisabled()
CategoryConstants.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.CategoryConstants.DISABLE_SETALLOWEDPRINCIPAL_RECURSIVELY exists in the session AND
the value is truejava.util.Collection<CategoryModel> getAllSubcategoriesForCategory(CategoryModel category)
category - the category for which subcategories should be obtainedjava.util.Collection<CategoryModel> getAllSupercategoriesForCategory(CategoryModel category)
category - the category for which supercategories should be obtainedCopyright © 2018 SAP SE. All Rights Reserved.