Interface JpaVendorNarrowingCriteriaManager
- All Known Implementing Classes:
DefaultJpaVendorNarrowingCriteriaManager
Typically, consumers should rely on JpaVendorNarrowingQueryCustomizer rather than
interacting with this component directly.
Ultimately, the purpose of this component is to inject all
JpaVendorNarrowingCriteriaHandler beans, and then delegate to the one that supports
performing a given operation on a particular entity.
This is somewhat analogous to VendorVisibilityManager.
-
Method Summary
Modifier and TypeMethodDescription<D> jakarta.persistence.criteria.PredicatebuildVendorNarrowingCriteria(Set<String> restrictedVendorRefs, Class<D> persistedDomainTypeToRead, jakarta.persistence.criteria.CriteriaQuery<?> criteriaQuery, jakarta.persistence.criteria.Root<D> root, Map<String, Object> queryParameters, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given apersistedDomainTypeToReadthat is being read in a query, build and return aPredicatefor it that restricts results to only include data accessible from therestrictedVendorRefs.booleansupportsVendorDiscrimination(Class<?> persistedDomainEntityType) Ultimately reports whether this manager has aJpaVendorNarrowingCriteriaHandlerwhich can support the providedpersistedDomainEntityType.
-
Method Details
-
supportsVendorDiscrimination
Ultimately reports whether this manager has aJpaVendorNarrowingCriteriaHandlerwhich can support the providedpersistedDomainEntityType.This can be useful to determine whether an entity should participate in vendor-discrimination behavior.
- Parameters:
persistedDomainEntityType- the persisted-domain entity type for which to check vendor-handling support- Returns:
trueif there is aJpaVendorNarrowingCriteriaHandlerwhich can handle the entity,falseotherwise
-
buildVendorNarrowingCriteria
@Nullable <D> jakarta.persistence.criteria.Predicate buildVendorNarrowingCriteria(Set<String> restrictedVendorRefs, Class<D> persistedDomainTypeToRead, jakarta.persistence.criteria.CriteriaQuery<?> criteriaQuery, jakarta.persistence.criteria.Root<D> root, Map<String, Object> queryParameters, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given apersistedDomainTypeToReadthat is being read in a query, build and return aPredicatefor it that restricts results to only include data accessible from therestrictedVendorRefs.This is particularly useful to prevent vendor-restricted authentications from accessing data outside of their allowed vendors.
If no
JpaVendorNarrowingCriteriaHandlersupports this operation for the givenpersistedDomainTypeToRead,nullwill be returned with the assumption that there is no filtration that needs to be performed for that entity.- Type Parameters:
D- the persisted-domain type of the entity being queried- Parameters:
restrictedVendorRefs- the "vendorRef" (typically a vendor ID or code) of all vendors that data should be restricted to. Cannot be empty.persistedDomainTypeToRead- the persisted-domain type of the entity being queriedcriteriaQuery- the query for which vendor-narrowing criteria should be builtroot- the entity root for the queryqueryParameters- parameters that will be set on the querycriteriaBuilder- a standard criteria buildercontextInfo- context information surrounding multitenant state. While typical narrowing will not apply, this parameter may be useful to certain implementations for determining additional information about the request.- Returns:
- a
Predicatethat can appropriately filter query results to only include the records accessible fromrestrictedVendorRefs. Alternatively, returnsnullif no vendor narrowing should be applied. - See Also:
-