Class CatalogTrackableSolrQueryContributor

java.lang.Object
com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor
com.broadleafcommerce.search.provider.solr.CatalogTrackableSolrQueryContributor
All Implemented Interfaces:
SolrQueryContributor, org.springframework.core.Ordered

public class CatalogTrackableSolrQueryContributor extends AbstractSolrQueryContributor
Add query filters to narrow query results down to the most specific Catalog context provided.
  • Field Summary

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addMarketplaceFilter(@NonNull org.apache.solr.client.solrj.SolrQuery solrQuery, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @NonNull com.broadleafcommerce.data.tracking.core.tenant.domain.Application application)
    Adds filtering when the requested Application is a marketplace.
    protected String
    addPendingMarketplaceApplicationFilter(com.broadleafcommerce.data.tracking.core.tenant.domain.Application application, String marketplaceApplication)
     
    protected void
    contributeInternal(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, org.springframework.data.domain.Pageable page, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, String locale, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Customize the provided solrQuery with some additional behavior.
    boolean
     
    protected String
    Create a filter for documents with no specified catalog.
    protected String
    Create a filter to exclude documents for which more specific versions exist for this catalog context.
    protected Set<String>
    getApplicationCatalogs(com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Retrieve all catalogs visible from the current application.
    protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils
     
    protected Set<String>
    getCatalogsForApplication(com.broadleafcommerce.data.tracking.core.tenant.domain.Application application, boolean isIncludePending)
    Retrieve all catalogs visible for the current application.
    protected Set<String>
    getForcedCatalogs(com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Retrieve currently specified visible catalogs.
    void
    setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)
     
    protected boolean
    shouldContribute(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, org.springframework.data.domain.Pageable page, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Determines if this contributor should run.

    Methods inherited from class com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor

    contribute

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.broadleafcommerce.search.provider.solr.SolrQueryContributor

    getOrder, isTypeAheadRequest
  • Constructor Details

    • CatalogTrackableSolrQueryContributor

      public CatalogTrackableSolrQueryContributor()
  • Method Details

    • contributeInternal

      protected void contributeInternal(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, org.springframework.data.domain.Pageable page, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, @Nullable String locale, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from class: AbstractSolrQueryContributor
      Customize the provided solrQuery with some additional behavior.
      Specified by:
      contributeInternal in class AbstractSolrQueryContributor
      Parameters:
      solrQuery - The query to customize
      searchRequest - The search query request
      fieldDefinitions - The fields to perform the search on
      page - Page information for page to retrieve for query
      properties - Additional properties for this query
      locale - The locale of this search
      context - The context information surrounding sandboxing/multitenant state
    • getForcedCatalogs

      protected Set<String> getForcedCatalogs(com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Retrieve currently specified visible catalogs.
      Parameters:
      context - The context information surrounding sandboxing/multitenant state
      Returns:
      Catalogs narrowed to only specified visible catalogs
    • addMarketplaceFilter

      protected void addMarketplaceFilter(@NonNull @NonNull org.apache.solr.client.solrj.SolrQuery solrQuery, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.tenant.domain.Application application)
      Adds filtering when the requested Application is a marketplace. This will add filtering by SolrNarrowFields.MARKETPLACE_APPLICATIONS as well as isolated catalog ids.
      Parameters:
      solrQuery - Query to add the filter to
      context - Additional context info
      application - Requested application
    • addPendingMarketplaceApplicationFilter

      protected String addPendingMarketplaceApplicationFilter(com.broadleafcommerce.data.tracking.core.tenant.domain.Application application, String marketplaceApplication)
    • getApplicationCatalogs

      protected Set<String> getApplicationCatalogs(com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Retrieve all catalogs visible from the current application.
      Parameters:
      context - The context information surrounding sandboxing/multitenant state
      Returns:
      Catalogs narrowed to all catalogs visible from the current application.
    • getCatalogsForApplication

      protected Set<String> getCatalogsForApplication(com.broadleafcommerce.data.tracking.core.tenant.domain.Application application, boolean isIncludePending)
      Retrieve all catalogs visible for the current application. Includes catalogs from inheritance lines, and optionally pending catalogs.
      Parameters:
      application - The application to retrieve visible catalogs from
      isIncludePending - Should pending catalogs be retrieved
      Returns:
      All catalogs visible for the application context
    • filterOnNoCatalog

      protected String filterOnNoCatalog()
      Create a filter for documents with no specified catalog.

      Note that the nested negative filter must contain a "*:* AND" as well. See https://stackoverflow.com/questions/7363819

      Returns:
      A filter for documents with no specified catalog.
    • filterOverriddenCatalogs

      protected String filterOverriddenCatalogs(Set<String> catalogIds)
      Create a filter to exclude documents for which more specific versions exist for this catalog context.
      Parameters:
      catalogIds - The IDs of the catalogs which are used for this context
      Returns:
      Filter query to exclude less specific catalog documents
    • shouldContribute

      protected boolean shouldContribute(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, org.springframework.data.domain.Pageable page, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from class: AbstractSolrQueryContributor
      Determines if this contributor should run.
      Specified by:
      shouldContribute in class AbstractSolrQueryContributor
      Parameters:
      solrQuery - The query to customize
      searchRequest - The search query request
      page - Page information for page to retrieve for query
      properties - Additional properties for this query.
      context - The context information surrounding sandboxing/multitenant state
      Returns:
      whether this contributor should run
    • contributeOnTypeAhead

      public boolean contributeOnTypeAhead()
      Returns:
      Should this contributor be executed on TypeAhead requests?
    • getAuthenticationUtils

      protected com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils getAuthenticationUtils()
    • setAuthenticationUtils

      @Autowired public void setAuthenticationUtils(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils)