Class DefaultFlexibleCMSItemSearchService
- java.lang.Object
-
- de.hybris.platform.cms2.cmsitems.service.impl.DefaultFlexibleCMSItemSearchService
-
- All Implemented Interfaces:
CMSItemSearchService
public class DefaultFlexibleCMSItemSearchService extends java.lang.Object implements CMSItemSearchService
The DefaultFlexibleCMSItemSearchService is aCMSItemSearchServiceimplementation that performs partial matching of the mask param on both UID and NAME fields, and exact matching on typeCode(s) and additional parameter fields
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCATALOG_VERSION_QUERY_PARAMstatic java.lang.StringEXCLUDED_TYPES_QUERY_PARAMstatic java.lang.StringITEM_SEARCH_PARAM_CHECKstatic java.lang.StringITEM_SEARCH_PARAM_CHECK_NULLstatic java.lang.StringMASK_CHECKstatic java.lang.StringMASK_CHECK_ABSTRACTPAGEstatic java.lang.StringMASK_QUERY_PARAMstatic java.lang.StringORDER_BYstatic java.lang.StringQUERYstatic java.lang.StringTYPE_PKS_QUERY_PARAMstatic java.lang.StringTYPECODES_ABSTRACT_PAGEstatic java.lang.StringTYPECODES_QUERY_PARAMDeprecated, for removal: This API element is subject to removal in a future version.since 2105, no longer needed.
-
Constructor Summary
Constructors Constructor Description DefaultFlexibleCMSItemSearchService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappendSearchParams(java.util.Map<java.lang.String,java.lang.String> itemSearchParams, java.lang.StringBuilder queryBuilder, java.util.Map<java.lang.String,java.lang.Object> queryParameters, java.lang.String typeCode)Append the item search data to the query builderprotected voidappendSort(java.lang.String sortNameAndDirection, java.lang.StringBuilder queryBuilder, java.lang.String typeCode)Append theORDER BYclause to the query builderprotected voidappendTypeExclusions(java.util.List<ComposedTypeModel> composedTypes, java.lang.StringBuilder queryBuilder, java.util.Map<java.lang.String,java.lang.Object> queryParameters)Append the type primary keys to be excluded from the query to the query builder.protected java.util.function.Predicate<Sort>attributeExistsForType(java.lang.String typeCode)protected java.lang.StringbuildSortStatement(java.lang.String typeCode, Sort sort)Create theStringrepresentation of the sort parameter and direction by formatting the sort parameter by applying the syntax required by the Flexible Search query.SearchResult<CMSItemModel>findCMSItems(CMSItemSearchData cmsItemSearchData, PageableData pageableData)Paged Search for CMSItemsprotected java.util.List<ComposedTypeModel>getAllSubTypes(ComposedTypeModel composedType)Get the list of all the sub types given a composedType.protected java.util.List<java.lang.String>getAllSuperTypeCodes(ComposedTypeModel composedType)Get the list of all the super typeCodes given a composedType, including the composedType typeCode.protected CatalogVersionServicegetCatalogVersionService()protected java.util.Map<java.lang.String,java.util.List<java.lang.String>>getCmsItemSearchTypeBlacklistMap()protected SortStatementFormattergetDefaultSortStatementFormatter()protected java.lang.StringgetFirstCommonAncestorTypeCode(java.util.List<ComposedTypeModel> composedTypes)Get the first common ancestor typeCode given a list of composed types.protected java.lang.StringgetFirstCommonElement(java.util.List<java.util.List<java.lang.String>> collections)Get the first common element given multiple collections.protected FlexibleSearchAttributeValueConvertergetFlexibleSearchAttributeValueConverter()protected FlexibleSearchServicegetFlexibleSearchService()protected java.util.List<PK>getInheritedTypePrimaryKeys(java.util.List<ComposedTypeModel> composedTypes)Get all the inherited type primary keys given a list of composed types.protected PermissionCRUDServicegetPermissionCRUDService()protected SearchHelpergetSearchHelper()protected java.util.List<SortStatementFormatter>getSortStatementFormatters()protected java.util.List<java.lang.String>getTypeCodesFromSearchData(CMSItemSearchData cmsItemSearchData)Get the list of typeCodes given the cmsItemSearchData.protected TypeServicegetTypeService()protected java.util.List<ComposedTypeModel>getValidComposedTypes(CMSItemSearchData cmsItemSearchData)Get the list of all valid composed types given cmsItemSearchDataprotected java.util.List<ComposedTypeModel>getValidComposedTypes(java.util.List<java.lang.String> typeCodes)Get the list of all valid composed types given a list of typeCodesbooleanhasCommonAncestorForTypeCodes(java.util.List<java.lang.String> typeCodes)Validate if there is a common ancestor typeCode given a list of typeCodesprotected java.lang.StringBuilderprepareQueryBuilder(java.util.List<ComposedTypeModel> composedTypes, java.lang.String typeCode, java.util.Map<java.lang.String,java.lang.Object> queryParameters)Prepare the query builder to set the parent query typeCode, the inherited typeCodes and the excluded typeCodes.voidsetCatalogVersionService(CatalogVersionService catalogVersionService)voidsetCmsItemSearchTypeBlacklistMap(java.util.Map<java.lang.String,java.util.List<java.lang.String>> cmsItemSearchTypeBlacklistMap)voidsetDefaultSortStatementFormatter(SortStatementFormatter defaultSortStatementFormatter)voidsetFlexibleSearchAttributeValueConverter(FlexibleSearchAttributeValueConverter flexibleSearchAttributeValueConverter)voidsetFlexibleSearchService(FlexibleSearchService flexibleSearchService)voidsetPermissionCRUDService(PermissionCRUDService permissionCRUDService)voidsetSearchHelper(SearchHelper searchHelper)voidsetSortStatementFormatters(java.util.List<SortStatementFormatter> sortStatementFormatters)voidsetTypeService(TypeService typeService)protected java.util.function.Predicate<java.lang.String>typeCodeExists()protected voidvalidateCommonAncestorTypeCode(java.util.List<java.lang.String> typeCodes)protected voidvalidateSearchData(CMSItemSearchData cmsItemSearchData, PageableData pageableData)Validate the cms item search data and pageable data
-
-
-
Field Detail
-
QUERY
public static final java.lang.String QUERY
- See Also:
- Constant Field Values
-
TYPECODES_QUERY_PARAM
@Deprecated(since="2105", forRemoval=true) public static final java.lang.String TYPECODES_QUERY_PARAMDeprecated, for removal: This API element is subject to removal in a future version.since 2105, no longer needed.- See Also:
- Constant Field Values
-
TYPECODES_ABSTRACT_PAGE
public static final java.lang.String TYPECODES_ABSTRACT_PAGE
- See Also:
- Constant Field Values
-
TYPE_PKS_QUERY_PARAM
public static final java.lang.String TYPE_PKS_QUERY_PARAM
- See Also:
- Constant Field Values
-
CATALOG_VERSION_QUERY_PARAM
public static final java.lang.String CATALOG_VERSION_QUERY_PARAM
- See Also:
- Constant Field Values
-
MASK_CHECK
public static final java.lang.String MASK_CHECK
- See Also:
- Constant Field Values
-
MASK_CHECK_ABSTRACTPAGE
public static final java.lang.String MASK_CHECK_ABSTRACTPAGE
- See Also:
- Constant Field Values
-
MASK_QUERY_PARAM
public static final java.lang.String MASK_QUERY_PARAM
- See Also:
- Constant Field Values
-
ITEM_SEARCH_PARAM_CHECK
public static final java.lang.String ITEM_SEARCH_PARAM_CHECK
- See Also:
- Constant Field Values
-
ITEM_SEARCH_PARAM_CHECK_NULL
public static final java.lang.String ITEM_SEARCH_PARAM_CHECK_NULL
- See Also:
- Constant Field Values
-
EXCLUDED_TYPES_QUERY_PARAM
public static final java.lang.String EXCLUDED_TYPES_QUERY_PARAM
- See Also:
- Constant Field Values
-
ORDER_BY
public static final java.lang.String ORDER_BY
- See Also:
- Constant Field Values
-
-
Method Detail
-
findCMSItems
public SearchResult<CMSItemModel> findCMSItems(CMSItemSearchData cmsItemSearchData, PageableData pageableData)
Paged Search for CMSItems CMSItem search params:- mask (optional) value does the search on uid and name.
- typeCode or typeCodes values are optional, if used only one of them must be provided. The default typeCode
value if not provided is
CMSItemModel._TYPECODE. - itemSearchParams (optional) is a map of key-value pairs of query parameter fields and Object values. The
key-value pair is ignored if the key doesn't belong to any provided typeCode(s). You can use
nullas value. - sort (optional) value is the requested ordering for the search results. The ordering is ignored for any column that doesn't belong to the provided typeCode(s).
- Specified by:
findCMSItemsin interfaceCMSItemSearchService- Parameters:
cmsItemSearchData- All the required and optional search params, excluding pagingpageableData- Paging search params- Returns:
- The search results and paging information
-
hasCommonAncestorForTypeCodes
public boolean hasCommonAncestorForTypeCodes(java.util.List<java.lang.String> typeCodes)
Description copied from interface:CMSItemSearchServiceValidate if there is a common ancestor typeCode given a list of typeCodes- Specified by:
hasCommonAncestorForTypeCodesin interfaceCMSItemSearchService- Parameters:
typeCodes- the list of typeCodes- Returns:
- true, if a common ancestor for the given typeCodes exist.
-
validateCommonAncestorTypeCode
protected void validateCommonAncestorTypeCode(java.util.List<java.lang.String> typeCodes)
-
validateSearchData
protected void validateSearchData(CMSItemSearchData cmsItemSearchData, PageableData pageableData)
Validate the cms item search data and pageable data- Parameters:
cmsItemSearchData-pageableData-- Throws:
java.lang.IllegalArgumentException- if both typeCode and typeCodes are used.
-
prepareQueryBuilder
protected java.lang.StringBuilder prepareQueryBuilder(java.util.List<ComposedTypeModel> composedTypes, java.lang.String typeCode, java.util.Map<java.lang.String,java.lang.Object> queryParameters)
Prepare the query builder to set the parent query typeCode, the inherited typeCodes and the excluded typeCodes.- Parameters:
composedTypes-typeCode-queryParameters-- Returns:
- the query builder
-
getValidComposedTypes
protected java.util.List<ComposedTypeModel> getValidComposedTypes(CMSItemSearchData cmsItemSearchData)
Get the list of all valid composed types given cmsItemSearchData- Parameters:
cmsItemSearchData-- Returns:
- the list of valid composed types
-
getValidComposedTypes
protected java.util.List<ComposedTypeModel> getValidComposedTypes(java.util.List<java.lang.String> typeCodes)
Get the list of all valid composed types given a list of typeCodes- Parameters:
typeCodes-- Returns:
- the list of valid composed types
-
typeCodeExists
protected java.util.function.Predicate<java.lang.String> typeCodeExists()
-
getFirstCommonAncestorTypeCode
protected java.lang.String getFirstCommonAncestorTypeCode(java.util.List<ComposedTypeModel> composedTypes)
Get the first common ancestor typeCode given a list of composed types. This is collecting all the super types of each composed type in the list and returns the top-level common super type.- Parameters:
composedTypes- the list of composed types- Returns:
- the
Stringrepresentation of the first common ancestor typeCode
-
getAllSuperTypeCodes
protected java.util.List<java.lang.String> getAllSuperTypeCodes(ComposedTypeModel composedType)
Get the list of all the super typeCodes given a composedType, including the composedType typeCode.- Parameters:
composedType-- Returns:
- the
ListofStringrepresentation of all the super typeCodes given a composedType, including the composedType typeCode.
-
getInheritedTypePrimaryKeys
protected java.util.List<PK> getInheritedTypePrimaryKeys(java.util.List<ComposedTypeModel> composedTypes)
Get all the inherited type primary keys given a list of composed types.- Parameters:
composedTypes- the list of composed types- Returns:
- the list of the inherited type primary keys given a list of composed types
-
getAllSubTypes
protected java.util.List<ComposedTypeModel> getAllSubTypes(ComposedTypeModel composedType)
Get the list of all the sub types given a composedType. The given composedType is included in the list if it's not abstract.- Parameters:
composedType-- Returns:
- the
ListofComposedTypeModelrepresentation of all the sub types given a composedType,
-
getFirstCommonElement
protected java.lang.String getFirstCommonElement(java.util.List<java.util.List<java.lang.String>> collections)
Get the first common element given multiple collections. Assumption is that each collection is already ordered.- Parameters:
collections- the collections to iterate over- Returns:
- the
Stringrepresentation of the first common element from amongst all the given Collections.
-
getTypeCodesFromSearchData
protected java.util.List<java.lang.String> getTypeCodesFromSearchData(CMSItemSearchData cmsItemSearchData)
Get the list of typeCodes given the cmsItemSearchData. UseCMSItemModel_TYPECODE by default if typeCode(s) is blank.- Parameters:
cmsItemSearchData-- Returns:
- the list of typeCodes
-
appendTypeExclusions
protected void appendTypeExclusions(java.util.List<ComposedTypeModel> composedTypes, java.lang.StringBuilder queryBuilder, java.util.Map<java.lang.String,java.lang.Object> queryParameters)
Append the type primary keys to be excluded from the query to the query builder.
A type primary key is added to the exclusion list when:- the type is blacklisted
- the user does not have READ permission for the type
- Parameters:
composedTypes- the composedTypes which may have a list of blacklisted types definedqueryBuilder- the query builder for the query statementqueryParameters- map of key-value pairs of query parameter fields and Object values
-
appendSearchParams
protected void appendSearchParams(java.util.Map<java.lang.String,java.lang.String> itemSearchParams, java.lang.StringBuilder queryBuilder, java.util.Map<java.lang.String,java.lang.Object> queryParameters, java.lang.String typeCode)Append the item search data to the query builder- Parameters:
itemSearchParams- the item search paramsqueryBuilder- the query builder for the query statementqueryParameters- map of key-value pairs of query parameter fields and Object valuestypeCode- the typeCode
-
appendSort
protected void appendSort(java.lang.String sortNameAndDirection, java.lang.StringBuilder queryBuilder, java.lang.String typeCode)Append theORDER BYclause to the query builder- Parameters:
sortNameAndDirection- string containing the field name to be sorted and the sort orderqueryBuilder- the query builder for the query statementtypeCode- the typeCode
-
attributeExistsForType
protected java.util.function.Predicate<Sort> attributeExistsForType(java.lang.String typeCode)
-
buildSortStatement
protected java.lang.String buildSortStatement(java.lang.String typeCode, Sort sort)Create theStringrepresentation of the sort parameter and direction by formatting the sort parameter by applying the syntax required by the Flexible Search query. This uses a customSortStatementFormatterto format the sort parameter value if applicable, otherwise the default formatter is used instead.- Parameters:
typeCode- the typeCode value of the cms items to be retrievedsort- theSortobject containing the parameter to be sorted and the sort direction- Returns:
- the
Stringrepresentation of the formatted sort parameter and direction
-
getCatalogVersionService
protected CatalogVersionService getCatalogVersionService()
-
setCatalogVersionService
public void setCatalogVersionService(CatalogVersionService catalogVersionService)
-
getFlexibleSearchService
protected FlexibleSearchService getFlexibleSearchService()
-
setFlexibleSearchService
public void setFlexibleSearchService(FlexibleSearchService flexibleSearchService)
-
getFlexibleSearchAttributeValueConverter
protected FlexibleSearchAttributeValueConverter getFlexibleSearchAttributeValueConverter()
-
setFlexibleSearchAttributeValueConverter
public void setFlexibleSearchAttributeValueConverter(FlexibleSearchAttributeValueConverter flexibleSearchAttributeValueConverter)
-
getTypeService
protected TypeService getTypeService()
-
setTypeService
public void setTypeService(TypeService typeService)
-
getSortStatementFormatters
protected java.util.List<SortStatementFormatter> getSortStatementFormatters()
-
setSortStatementFormatters
public void setSortStatementFormatters(java.util.List<SortStatementFormatter> sortStatementFormatters)
-
getDefaultSortStatementFormatter
protected SortStatementFormatter getDefaultSortStatementFormatter()
-
setDefaultSortStatementFormatter
public void setDefaultSortStatementFormatter(SortStatementFormatter defaultSortStatementFormatter)
-
getCmsItemSearchTypeBlacklistMap
protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> getCmsItemSearchTypeBlacklistMap()
-
setCmsItemSearchTypeBlacklistMap
public void setCmsItemSearchTypeBlacklistMap(java.util.Map<java.lang.String,java.util.List<java.lang.String>> cmsItemSearchTypeBlacklistMap)
-
getSearchHelper
protected SearchHelper getSearchHelper()
-
setSearchHelper
public void setSearchHelper(SearchHelper searchHelper)
-
getPermissionCRUDService
protected PermissionCRUDService getPermissionCRUDService()
-
setPermissionCRUDService
public void setPermissionCRUDService(PermissionCRUDService permissionCRUDService)
-
-