Class DefaultFlexibleCMSItemSearchService
java.lang.Object
de.hybris.platform.cms2.cmsitems.service.impl.DefaultFlexibleCMSItemSearchService
- All Implemented Interfaces:
CMSItemSearchService
The DefaultFlexibleCMSItemSearchService is a
CMSItemSearchService implementation 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
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringDeprecated, for removal: This API element is subject to removal in a future version.since 2105, no longer needed.static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappendSearchParams(Map<String, String> itemSearchParams, StringBuilder queryBuilder, Map<String, Object> queryParameters, String typeCode) Append the item search data to the query builderprotected voidappendSort(String sortNameAndDirection, StringBuilder queryBuilder, String typeCode) Append theORDER BYclause to the query builderprotected voidappendTypeExclusions(List<ComposedTypeModel> composedTypes, StringBuilder queryBuilder, Map<String, Object> queryParameters) Append the type primary keys to be excluded from the query to the query builder.attributeExistsForType(String typeCode) protected voidbuildQueryBuilder(StringBuilder queryBuilder, Map<String, Object> queryParameters, String typeCode, String field, String value) protected StringbuildSortStatement(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.findCMSItems(CMSItemSearchData cmsItemSearchData, PageableData pageableData) Paged Search for CMSItemsprotected List<ComposedTypeModel>getAllSubTypes(ComposedTypeModel composedType) Get the list of all the sub types given a composedType.getAllSuperTypeCodes(ComposedTypeModel composedType) Get the list of all the super typeCodes given a composedType, including the composedType typeCode.protected CatalogVersionServiceprotected SortStatementFormatterprotected StringgetFirstCommonAncestorTypeCode(List<ComposedTypeModel> composedTypes) Get the first common ancestor typeCode given a list of composed types.protected StringgetFirstCommonElement(List<List<String>> collections) Get the first common element given multiple collections.protected FlexibleSearchAttributeValueConverterprotected FlexibleSearchServicegetInheritedTypePrimaryKeys(List<ComposedTypeModel> composedTypes) Get all the inherited type primary keys given a list of composed types.protected PermissionCRUDServiceprotected SearchHelperprotected List<SortStatementFormatter>getTypeCodesFromSearchData(CMSItemSearchData cmsItemSearchData) Get the list of typeCodes given the cmsItemSearchData.protected TypeServiceprotected List<ComposedTypeModel>getValidComposedTypes(CMSItemSearchData cmsItemSearchData) Get the list of all valid composed types given cmsItemSearchDataprotected List<ComposedTypeModel>getValidComposedTypes(List<String> typeCodes) Get the list of all valid composed types given a list of typeCodesbooleanhasCommonAncestorForTypeCodes(List<String> typeCodes) Validate if there is a common ancestor typeCode given a list of typeCodesprotected StringBuilderprepareQueryBuilder(List<ComposedTypeModel> composedTypes, String typeCode, Map<String, Object> queryParameters) Prepare the query builder to set the parent query typeCode, the inherited typeCodes and the excluded typeCodes.voidsetCatalogVersionService(CatalogVersionService catalogVersionService) voidsetCmsItemSearchTypeBlacklistMap(Map<String, List<String>> cmsItemSearchTypeBlacklistMap) voidsetDefaultSortStatementFormatter(SortStatementFormatter defaultSortStatementFormatter) voidsetFlexibleSearchAttributeValueConverter(FlexibleSearchAttributeValueConverter flexibleSearchAttributeValueConverter) voidsetFlexibleSearchService(FlexibleSearchService flexibleSearchService) voidsetPermissionCRUDService(PermissionCRUDService permissionCRUDService) voidsetSearchHelper(SearchHelper searchHelper) voidsetSortStatementFormatters(List<SortStatementFormatter> sortStatementFormatters) voidsetTypeService(TypeService typeService) protected voidvalidateCommonAncestorTypeCode(List<String> typeCodes) protected voidvalidateSearchData(CMSItemSearchData cmsItemSearchData, PageableData pageableData) Validate the cms item search data and pageable data
-
Field Details
-
QUERY
- See Also:
-
UNKONW_TYPE_CODE
- See Also:
-
TYPECODES_QUERY_PARAM
Deprecated, for removal: This API element is subject to removal in a future version.since 2105, no longer needed.- See Also:
-
TYPECODES_ABSTRACT_PAGE
- See Also:
-
TYPE_PKS_QUERY_PARAM
- See Also:
-
CATALOG_VERSION_QUERY_PARAM
- See Also:
-
MASK_CHECK
- See Also:
-
MASK_CHECK_ABSTRACTPAGE
- See Also:
-
MASK_QUERY_PARAM
- See Also:
-
ITEM_SEARCH_PARAM_CHECK
- See Also:
-
ITEM_SEARCH_PARAM_CHECK_NULL
- See Also:
-
EXCLUDED_TYPES_QUERY_PARAM
- See Also:
-
ORDER_BY
- See Also:
-
-
Constructor Details
-
DefaultFlexibleCMSItemSearchService
public DefaultFlexibleCMSItemSearchService()
-
-
Method Details
-
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
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
-
validateSearchData
Validate the cms item search data and pageable data- Parameters:
cmsItemSearchData-pageableData-- Throws:
IllegalArgumentException- if both typeCode and typeCodes are used.
-
prepareQueryBuilder
protected StringBuilder prepareQueryBuilder(List<ComposedTypeModel> composedTypes, String typeCode, Map<String, 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
Get the list of all valid composed types given cmsItemSearchData- Parameters:
cmsItemSearchData-- Returns:
- the list of valid composed types
-
getValidComposedTypes
Get the list of all valid composed types given a list of typeCodes- Parameters:
typeCodes-- Returns:
- the list of valid composed types
-
typeCodeExists
-
getFirstCommonAncestorTypeCode
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
Get the list of all the super typeCodes given a composedType, including the composedType typeCode. -
getInheritedTypePrimaryKeys
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
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
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
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(List<ComposedTypeModel> composedTypes, StringBuilder queryBuilder, Map<String, 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(Map<String, String> itemSearchParams, StringBuilder queryBuilder, Map<String, Object> queryParameters, 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
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
-
buildQueryBuilder
-
buildSortStatement
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. -
getCatalogVersionService
-
setCatalogVersionService
-
getFlexibleSearchService
-
setFlexibleSearchService
-
getFlexibleSearchAttributeValueConverter
-
setFlexibleSearchAttributeValueConverter
public void setFlexibleSearchAttributeValueConverter(FlexibleSearchAttributeValueConverter flexibleSearchAttributeValueConverter) -
getTypeService
-
setTypeService
-
getSortStatementFormatters
-
setSortStatementFormatters
-
getDefaultSortStatementFormatter
-
setDefaultSortStatementFormatter
-
getCmsItemSearchTypeBlacklistMap
-
setCmsItemSearchTypeBlacklistMap
-
getSearchHelper
-
setSearchHelper
-
getPermissionCRUDService
-
setPermissionCRUDService
-