Class TemplateOnlyQueryExtensionManager
java.lang.Object
org.broadleafcommerce.common.extension.ExtensionManager<TemplateOnlyQueryExtensionHandler>
org.broadleafcommerce.common.extension.TemplateOnlyQueryExtensionManager
- All Implemented Interfaces:
InvocationHandler
,ExtensionHandler
,TemplateOnlyQueryExtensionHandler
@Service("blTemplateOnlyQueryExtensionManager")
public class TemplateOnlyQueryExtensionManager
extends ExtensionManager<TemplateOnlyQueryExtensionHandler>
implements TemplateOnlyQueryExtensionHandler
Provides specialized filter and restriction behavior for template-related (MT concept) queries. This is only meaningful
in a multi-tenant installation.
- Author:
- Jeff Fischer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ExtensionManagerOperation
static final ExtensionManagerOperation
static final ExtensionManagerOperation
static final ExtensionManagerOperation
static final ExtensionManagerOperation
static final ExtensionManagerOperation
static final ExtensionManagerOperation
static final ExtensionManagerOperation
Fields inherited from class org.broadleafcommerce.common.extension.ExtensionManager
extensionHandler, handlers, handlersSorted, LOCK_OBJECT
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPerform any breakdown operations.buildStatus
(Object entity, ExtensionResultHolder<ItemStatus> response) filterResults
(Class<?> type, Object testObject, List results) Validate and filter the results.boolean
If false, the ExtensionManager should skip this Handler.isValidState
(ExtensionResultHolder<Boolean> response) Determine if the current thread is in a valid state for sparse cache handlingrefineOrder
(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 queryrefineParameterRetrieve
(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.refineQuery
(Class<?> type, Object testObject, jakarta.persistence.TypedQuery query) Finish the query - possibly setting parametersPerform any setup operations.Methods inherited from class org.broadleafcommerce.common.extension.ExtensionManager
continueOnHandled, execute, getHandlers, getPriority, getProxy, invoke, registerHandler, setHandlers, shouldContinue, sortHandlers
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.broadleafcommerce.common.extension.ExtensionHandler
getPriority
-
Field Details
-
refineParameterRetrieve
-
refineQuery
-
setup
-
breakdown
-
refineOrder
-
isValidState
-
buildStatus
-
filterResults
-
-
Constructor Details
-
TemplateOnlyQueryExtensionManager
public TemplateOnlyQueryExtensionManager()
-
-
Method Details
-
refineParameterRetrieve
public 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) Description copied from interface:TemplateOnlyQueryExtensionHandler
Add additional restrictions to the fetch query. Use in conjunction withTemplateOnlyQueryExtensionHandler.refineQuery(Class, Object, TypedQuery)
to set actual parameter values before retrieving results.- Specified by:
refineParameterRetrieve
in interfaceTemplateOnlyQueryExtensionHandler
- Parameters:
type
- the class type for the querytestObject
- supporting implementations may use this object to test for possible catalog query optimizations. This value can be null, in which case it is ignored.restrictions
- any additional JPA criteria restrictions should be added here- Returns:
- the status of the extension operation
-
refineQuery
public ExtensionResultStatusType refineQuery(Class<?> type, Object testObject, jakarta.persistence.TypedQuery query) Description copied from interface:TemplateOnlyQueryExtensionHandler
Finish the query - possibly setting parameters- Specified by:
refineQuery
in interfaceTemplateOnlyQueryExtensionHandler
- Parameters:
type
- the class type for the querytestObject
- 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:
-
setup
Description copied from interface:TemplateOnlyQueryExtensionHandler
Perform any setup operations. This is usually done before executing the query and can serve to prepare the BroadleafRequestContext (if applicable).- Specified by:
setup
in interfaceTemplateOnlyQueryExtensionHandler
- Parameters:
type
- the class type for the query- Returns:
- the status of the extension operation
-
isEnabled
public boolean isEnabled()Description copied from interface:ExtensionHandler
If false, the ExtensionManager should skip this Handler.- Specified by:
isEnabled
in interfaceExtensionHandler
- Returns:
-
breakdown
Description copied from interface:TemplateOnlyQueryExtensionHandler
Perform any breakdown operations. This is usually done after executing the query and can serve to reset the BroadleafRequestContext (if applicable)- Specified by:
breakdown
in interfaceTemplateOnlyQueryExtensionHandler
- Parameters:
type
- the class type for the query- Returns:
- the status of the extension operation
-
refineOrder
public 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) Description copied from interface:TemplateOnlyQueryExtensionHandler
Add sorting to the fetch query- Specified by:
refineOrder
in interfaceTemplateOnlyQueryExtensionHandler
- Parameters:
type
- the class type for the querysorts
- any additional JPA order expressions should be added here- Returns:
- the status of the extension operation
-
isValidState
Description copied from interface:TemplateOnlyQueryExtensionHandler
Determine if the current thread is in a valid state for sparse cache handling- Specified by:
isValidState
in interfaceTemplateOnlyQueryExtensionHandler
- Returns:
-
buildStatus
public ExtensionResultStatusType buildStatus(Object entity, ExtensionResultHolder<ItemStatus> response) - Specified by:
buildStatus
in interfaceTemplateOnlyQueryExtensionHandler
-
filterResults
Description copied from interface:TemplateOnlyQueryExtensionHandler
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.- Specified by:
filterResults
in interfaceTemplateOnlyQueryExtensionHandler
- Returns:
-