Class DefaultFlexibleCMSItemSearchService

java.lang.Object
de.hybris.platform.cms2.cmsitems.service.impl.DefaultFlexibleCMSItemSearchService
All Implemented Interfaces:
CMSItemSearchService

public class DefaultFlexibleCMSItemSearchService extends Object implements 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 Details

  • 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 null as 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:
      findCMSItems in interface CMSItemSearchService
      Parameters:
      cmsItemSearchData - All the required and optional search params, excluding paging
      pageableData - Paging search params
      Returns:
      The search results and paging information
    • hasCommonAncestorForTypeCodes

      public boolean hasCommonAncestorForTypeCodes(List<String> typeCodes)
      Description copied from interface: CMSItemSearchService
      Validate if there is a common ancestor typeCode given a list of typeCodes
      Specified by:
      hasCommonAncestorForTypeCodes in interface CMSItemSearchService
      Parameters:
      typeCodes - the list of typeCodes
      Returns:
      true, if a common ancestor for the given typeCodes exist.
    • validateCommonAncestorTypeCode

      protected void validateCommonAncestorTypeCode(List<String> typeCodes)
    • validateSearchData

      protected void validateSearchData(CMSItemSearchData cmsItemSearchData, PageableData pageableData)
      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

      protected 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 List<ComposedTypeModel> getValidComposedTypes(List<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 Predicate<String> typeCodeExists()
    • getFirstCommonAncestorTypeCode

      protected String getFirstCommonAncestorTypeCode(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 String representation of the first common ancestor typeCode
    • getAllSuperTypeCodes

      protected List<String> getAllSuperTypeCodes(ComposedTypeModel composedType)
      Get the list of all the super typeCodes given a composedType, including the composedType typeCode.
      Parameters:
      composedType -
      Returns:
      the List of String representation of all the super typeCodes given a composedType, including the composedType typeCode.
    • getInheritedTypePrimaryKeys

      protected List<PK> getInheritedTypePrimaryKeys(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 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 List of ComposedTypeModel representation of all the sub types given a composedType,
    • getFirstCommonElement

      protected String getFirstCommonElement(List<List<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 String representation of the first common element from amongst all the given Collections.
    • getTypeCodesFromSearchData

      protected List<String> getTypeCodesFromSearchData(CMSItemSearchData cmsItemSearchData)
      Get the list of typeCodes given the cmsItemSearchData. Use CMSItemModel _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 defined
      queryBuilder - the query builder for the query statement
      queryParameters - 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 params
      queryBuilder - the query builder for the query statement
      queryParameters - map of key-value pairs of query parameter fields and Object values
      typeCode - the typeCode
    • appendSort

      protected void appendSort(String sortNameAndDirection, StringBuilder queryBuilder, String typeCode)
      Append the ORDER BY clause to the query builder
      Parameters:
      sortNameAndDirection - string containing the field name to be sorted and the sort order
      queryBuilder - the query builder for the query statement
      typeCode - the typeCode
    • attributeExistsForType

      protected Predicate<Sort> attributeExistsForType(String typeCode)
    • buildQueryBuilder

      protected void buildQueryBuilder(StringBuilder queryBuilder, Map<String,Object> queryParameters, String typeCode, String field, String value)
    • buildSortStatement

      protected String buildSortStatement(String typeCode, Sort sort)
      Create the String representation of the sort parameter and direction by formatting the sort parameter by applying the syntax required by the Flexible Search query. This uses a custom SortStatementFormatter to 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 retrieved
      sort - the Sort object containing the parameter to be sorted and the sort direction
      Returns:
      the String representation 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 List<SortStatementFormatter> getSortStatementFormatters()
    • setSortStatementFormatters

      public void setSortStatementFormatters(List<SortStatementFormatter> sortStatementFormatters)
    • getDefaultSortStatementFormatter

      protected SortStatementFormatter getDefaultSortStatementFormatter()
    • setDefaultSortStatementFormatter

      public void setDefaultSortStatementFormatter(SortStatementFormatter defaultSortStatementFormatter)
    • getCmsItemSearchTypeBlacklistMap

      protected Map<String,List<String>> getCmsItemSearchTypeBlacklistMap()
    • setCmsItemSearchTypeBlacklistMap

      public void setCmsItemSearchTypeBlacklistMap(Map<String,List<String>> cmsItemSearchTypeBlacklistMap)
    • getSearchHelper

      protected SearchHelper getSearchHelper()
    • setSearchHelper

      public void setSearchHelper(SearchHelper searchHelper)
    • getPermissionCRUDService

      protected PermissionCRUDService getPermissionCRUDService()
    • setPermissionCRUDService

      public void setPermissionCRUDService(PermissionCRUDService permissionCRUDService)