Interface ProductCharacteristicService<P extends ProductCharacteristic>
- All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
- All Known Implementing Classes:
DefaultProductCharacteristicService
ProductCharacteristics. This is typically only called from the
ProductService for managing product characteristics as part of product CRUD operations.- Since:
- Catalog Service 2.3.0, Release Train 2.3.0
-
Method Summary
Modifier and TypeMethodDescriptionlongcountNonProductionRecordsByProductIdsInTenant(@NonNull Collection<String> productIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the count of non-production records that match the givenproductContextIdsand the given tenant context.Resolves a scenario where the query for product characteristics of a product/products actually produced multiple results for the sameProductCharacteristic.getFieldName()on the same product.readAllByProductContextIdAndCatalogContextId(@NonNull String productContextId, String catalogContextId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all product characteristics for a givenproductContextId, restricting results to only the items directly resident in the providedcatalogContextIdreadAllByProductContextIdAndInheritanceLine(Collection<String> contextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds all product characteristics by product context id for a given catalog inheritance line.readAllByProductContextIdIn(Collection<String> productContextIds, boolean deduplicateByFieldName, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all product characteristics for givenproductContextIds.readAllByProductContextIdIn(Collection<String> productContextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all product characteristics for givenproductContextIds.Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Method Details
-
readAllByProductContextIdAndCatalogContextId
List<P> readAllByProductContextIdAndCatalogContextId(@NonNull @NonNull String productContextId, @Nullable String catalogContextId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all product characteristics for a givenproductContextId, restricting results to only the items directly resident in the providedcatalogContextId- Parameters:
productContextId- the product context ID to find characteristics forcatalogContextId- the catalog context ID to restrict the results tocontextInfo- Request context information around sandbox and multitenant state- Returns:
- a list of characteristics associated with the product in the specified catalog
-
readAllByProductContextIdIn
List<P> readAllByProductContextIdIn(Collection<String> productContextIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all product characteristics for givenproductContextIds. This is the same asreadAllByProductContextIdIn(Collection, boolean, ContextInfo)withdeduplicateByFieldNameset to 'true'.- Parameters:
productContextIds- The product context idscontextInfo- Request context information around sandbox and multitenant state- Returns:
- All product characteristics for given
productContextIds.
-
readAllByProductContextIdIn
List<P> readAllByProductContextIdIn(Collection<String> productContextIds, boolean deduplicateByFieldName, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all product characteristics for given
productContextIds.The
deduplicateByFieldNameparameter, when set to true, resolves a scenario where the query for product characteristics of a product/products actually produced multiple results for the sameProductCharacteristic.getFieldName()on the same product. See the Javadocs ofdeduplicateProductCharacteristicsByFieldName(List)for an explanation of the edge cases this is handling.- Parameters:
productContextIds- The product context idsdeduplicateByFieldName- whether to deduplicate results for the same product by field namecontextInfo- Request context information around sandbox and multitenant state- Returns:
- All product characteristics for given
productContextIds.
-
deduplicateProductCharacteristicsByFieldName
Resolves a scenario where the query for product characteristics of a product/products actually produced multiple results for the same
ProductCharacteristic.getFieldName()on the same product.In most cases, this scenario should not arise. We're expecting the results to have gone through our standard catalog narrowing process to filter down
ProductCharacteristicsto just 1 instance perProductCharacteristic context ID. This should ensure only the most derived catalog representation is in play for eachProductCharacteristic context ID, and in most cases for everyProductCharacteristic.getFieldName()on a product, theProductCharacteristic.getId()will be unique.With that being said, consider a scenario where we started out with a product in TopTenantCatalog that didn't have any actual persisted ProductCharacteristic records and simply relied on the inherited defaults from its parent business type to be hydrated at read time. If, after that, an API caller went into ChildTenantCatalog (or application catalog) and specified a different value for any of those characteristics, that change would be interpreted as a new ProductCharacteristic creation in that catalog. It would not technically be considered an override from a DataTracking perspective, because there was no base ProductCharacteristic record in the parent catalog to override. It's a net new insert, and as a result will have a net new context ID. Then, imagine later, someone goes and modifies the value of the characteristic with the same fieldName at the top catalog level. There too, it would be seen as a new ProductCharacteristic creation and have its own new context ID. If you then come back to the child catalog context and read the persisted ProductCharacteristic records, narrowing won't help us because it only narrows by context ID. The results will end up including both the different ProductCharacteristic records for the same field name.
As a result, we must manually filter out duplicate field names and use this hook point to find the 'most derived' characteristic - usually just by finding the item with the deepest catalog level.
- Parameters:
input- a list of product characteristics, potentially for multiple different products. Generally speaking this input should already only be a list of 'most derived' entities narrowed by context ID. We are only expecting to handle duplicates based onProductCharacteristic.getProductId()+ProductCharacteristic.getFieldName()- Returns:
- a new list with duplicate field name results for the same product filtered out
-
readAllByProductContextIdAndInheritanceLine
List<P> readAllByProductContextIdAndInheritanceLine(Collection<String> contextIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds all product characteristics by product context id for a given catalog inheritance line. For more details on the filtration semantics and what can be expected in the result, please see the Javadocs ofCustomizedProductCharacteristicRepository.findAllByProductContextIdAndInheritanceLine(Collection, ContextInfo), which backs this method.- Parameters:
contextIds- the product context ids to findcontextInfo- the information surrounding sandboxing and multitenant state, used to determine the catalog inheritance line- Returns:
- All product characteristics by product context id for a given catalog inheritance line
-
countNonProductionRecordsByProductIdsInTenant
long countNonProductionRecordsByProductIdsInTenant(@NonNull @NonNull Collection<String> productIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the count of non-production records that match the givenproductContextIdsand the given tenant context.- Parameters:
productIds- IDs of parent Products to match againstcontext- Request context information around sandbox and multitenant state- Returns:
- the count of non-production records that match the given
productContextIdsand the given tenant context
-