Interface TemplateOnlyQueryExtensionHandler

All Superinterfaces:
ExtensionHandler
All Known Implementing Classes:
TemplateOnlyQueryExtensionManager

public interface TemplateOnlyQueryExtensionHandler extends ExtensionHandler
Extension handler (generally for DAO usage) that allows contribution to a query (presumably from another module). The intent of this handler is to manipulate a query to not include standard site catalogs (template only). This is useful in some caching situations where it is advantageous to only look at template catalog values. SparseTranslationOverrideStrategy is an example use case. This is generally used in multitenant scenarios.
Author:
Jeff Fischer
  • Method Details

    • refineQuery

      ExtensionResultStatusType refineQuery(Class<?> type, Object testObject, jakarta.persistence.TypedQuery query)
      Finish the query - possibly setting parameters
      Parameters:
      type - the class type for the query
      testObject - supporting implementations may use this object to test for possible catalog query optimizations. This value can be null, in which case it is ignored.
      query - the final Query instance to embellish
      Returns:
    • refineParameterRetrieve

      ExtensionResultStatusType refineParameterRetrieve(Class<?> type, Object testObject, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.CriteriaQuery criteria, jakarta.persistence.criteria.Root root, List<jakarta.persistence.criteria.Predicate> restrictions)
      Add additional restrictions to the fetch query. Use in conjunction with refineQuery(Class, Object, TypedQuery) to set actual parameter values before retrieving results.
      Parameters:
      type - the class type for the query
      testObject - supporting implementations may use this object to test for possible catalog query optimizations. This value can be null, in which case it is ignored.
      builder -
      criteria -
      root -
      restrictions - any additional JPA criteria restrictions should be added here
      Returns:
      the status of the extension operation
    • setup

      Perform any setup operations. This is usually done before executing the query and can serve to prepare the BroadleafRequestContext (if applicable).
      Parameters:
      type - the class type for the query
      Returns:
      the status of the extension operation
    • breakdown

      ExtensionResultStatusType breakdown(Class<?> type)
      Perform any breakdown operations. This is usually done after executing the query and can serve to reset the BroadleafRequestContext (if applicable)
      Parameters:
      type - the class type for the query
      Returns:
      the status of the extension operation
    • refineOrder

      ExtensionResultStatusType refineOrder(Class<?> type, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.CriteriaQuery criteria, jakarta.persistence.criteria.Root root, List<jakarta.persistence.criteria.Order> sorts)
      Add sorting to the fetch query
      Parameters:
      type - the class type for the query
      builder -
      criteria -
      root -
      sorts - any additional JPA order expressions should be added here
      Returns:
      the status of the extension operation
    • isValidState

      Determine if the current thread is in a valid state for sparse cache handling
      Parameters:
      response -
      Returns:
    • buildStatus

    • filterResults

      @Deprecated ExtensionResultStatusType filterResults(Class<?> type, Object testObject, List results)
      Deprecated.
      It's difficult to determine this efficiently at runtime. The current implementation will no longer check the use case described above.
      Validate and filter the results. This can be interesting when you have restricted the query with a test object and need to confirm the validity of the results. A nuanced example of this would be translations associated with a profile entity (e.g. StructuredContent). If you filter by the StructuredContent, you will be filtering translations by owning site. However, the resulting translations are not profile entities and will not available necessarily to the requesting site. As a result, we filter here and check the translations based on catalog visibility (Translations are dual discriminated). This is primarily to handle edge cases and will generally have no impact on the results.
      Parameters:
      type -
      testObject -
      results -
      Returns: