Class ProductBatchItemHandler<T extends ComprehensiveProduct>
java.lang.Object
com.broadleafcommerce.dataexchange.service.AbstractBatchItemHandler<T,T>
com.broadleafcommerce.dataexchange.service.product.ProductBatchItemHandler<T>
- All Implemented Interfaces:
BatchItemHandler<T,T>
public class ProductBatchItemHandler<T extends ComprehensiveProduct>
extends AbstractBatchItemHandler<T,T>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionProductBatchItemHandler(CatalogProvider<T, Variant> catalogProvider, ProductBatchItemHandlerHelper<T> helper, VariantBatchItemHandler<Variant> variantBatchItemHandler, AdvancedTagProvider<AdvancedTag, ProductTag> tagProvider, ProductTagBatchItemHandler<ProductTag> tagBatchItemHandler, List<ProductRelatedBatchItemHandler<T, ?>> childItemHandlers, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected CompletableFuture<Void>buildProductTranslationsMap(HandlerArgs<T, T> args) protected Function<? super Void,? extends CompletionStage<Void>> buildSaveTagFutures(HandlerArgs<T, T> args) protected @NotNull Function<Void,CompletionStage<Void>> buildSaveTranslationFutures(HandlerArgs<T, T> args) booleancanHandle(ExchangeObject exchangeObject) Determines if this handler can handle the given exchange object.createSupplementalFutures(HandlerArgs<T, T> args) Create any supplemental futures that should be executed after the main future.protected CompletableFuture<Void>deleteVariantsFuture(HandlerArgs<T, T> args, BatchContext<T> tBatchContext) protected BatchItemOperationTypefindVariantOperationType(HandlerArgs<T, T> args, ExchangeObject exchangeObject) protected CatalogProvider<T,Variant> protected List<ProductRelatedBatchItemHandler<T,?>> protected ProductBatchItemHandlerHelper<T>protected ProductTagBatchItemHandler<ProductTag>protected AdvancedTagProvider<AdvancedTag,ProductTag> protected VariantBatchItemHandler<Variant>handle(HandlerArgs<T, T> args) Perform the necessary actions on the item in the batch.handleCreate(HandlerArgs<T, T> args) Handle the create operation.protected CompletableFuture<Void>handleProductTags(HandlerArgs<T, T> args) handleUpdate(HandlerArgs<T, T> args) Handle the update operation.protected voidinitTranslationsList(T savedProduct) protected CompletableFuture<Void>loadExistingTags(HandlerArgs<T, T> args) postHandle(HandlerArgs<T, T> args) This method is called after the item has been saved.preHandle(HandlerArgs<T, T> handlerArgs) Perform any necessary actions before the item is handled (e.g.protected TresolveExistingProducts(T product, BatchContext<T> batchContext) saveProduct(T product, BatchContext<T> batchContext, org.springframework.core.task.AsyncTaskExecutor executor, org.springframework.retry.support.RetryTemplate retryTemplate) protected RunnablesaveProductTranslationRunnable(List<Translation> translations, Locale locale, HandlerArgs<T, T> args) protected CompletableFuture<Void>saveTranslationsFuture(HandlerArgs<T, T> args) Methods inherited from class com.broadleafcommerce.dataexchange.service.AbstractBatchItemHandler
applyHandle, applyPostOperations, buildTranslationMap, createFutureInternal, execute, execute, execute, execute, getSavedTopLevel, getTypeFactory, isNewlyCreatedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.dataexchange.service.BatchItemHandler
completedFuture, createCompletableFuture, createCompletableFuture, handleDelete, populateCorrelationId, retryableRunnable, retryableSupplier, shouldAbort
-
Field Details
-
VARIANTS_TO_CREATE
- See Also:
-
VARIANTS_TO_UPDATE
- See Also:
-
VARIANTS_TO_DELETE
- See Also:
-
PRODUCT_TRANSLATIONS_MAP
- See Also:
-
EXISTING_PRODUCT_TAGS
- See Also:
-
-
Constructor Details
-
ProductBatchItemHandler
public ProductBatchItemHandler(CatalogProvider<T, Variant> catalogProvider, ProductBatchItemHandlerHelper<T> helper, VariantBatchItemHandler<Variant> variantBatchItemHandler, AdvancedTagProvider<AdvancedTag, ProductTag> tagProvider, ProductTagBatchItemHandler<ProductTag> tagBatchItemHandler, List<ProductRelatedBatchItemHandler<T, ?>> childItemHandlers, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
saveProduct
public CompletableFuture<Void> saveProduct(T product, BatchContext<T> batchContext, org.springframework.core.task.AsyncTaskExecutor executor, org.springframework.retry.support.RetryTemplate retryTemplate) -
preHandle
Description copied from interface:BatchItemHandlerPerform any necessary actions before the item is handled (e.g. fetching data, determining save/delete, etc.).- Parameters:
handlerArgs- The handler arguments- Returns:
- A runnable that will be executed before the item is handled. If no action is necessary, returns null.
-
handle
Description copied from interface:BatchItemHandlerPerform the necessary actions on the item in the batch. Accepts an instance ofHandlerArgsand returns the handled item, which is then passed toBatchItemHandler.postHandle(HandlerArgs).- Returns:
- A function that accepts an instance of
HandlerArgs. If no further handling is necessary, this method or the supplier may return null.
-
handleCreate
Description copied from interface:BatchItemHandlerHandle the create operation. This method is called whenHandlerArgs.getOperationType()isBatchItemOperationType.CREATE. -
handleUpdate
Description copied from interface:BatchItemHandlerHandle the update operation. This method is called whenHandlerArgs.getOperationType()isBatchItemOperationType.UPDATE. -
createSupplementalFutures
Description copied from interface:BatchItemHandlerCreate any supplemental futures that should be executed after the main future. This should be implemented to handle any child entities that need to be processed after the main entity is handled.CompletableFuture<Void> future1 = ... CompletableFuture<Void> future2 = ... return CompletableFuture.allOf(future1, future2);NOTE: See class level documentation for important information about composing futures.
- Parameters:
args- The handler arguments- Returns:
- A completable future that will execute any supplemental futures. By default, this returns a completed future.
-
findVariantOperationType
protected BatchItemOperationType findVariantOperationType(HandlerArgs<T, T> args, ExchangeObject exchangeObject) -
deleteVariantsFuture
protected CompletableFuture<Void> deleteVariantsFuture(HandlerArgs<T, T> args, BatchContext<T> tBatchContext) -
postHandle
Description copied from interface:BatchItemHandlerThis method is called after the item has been saved. Any items that should be done after the item is saved should be done here. At minimum, the implementation should set the savedItem result on the parent. At this point, the item is considered "done" and no high risk operations (e.g. API calls) should be done here.- Parameters:
args- the handler arguments. Returns null if no action is necessary.
-
handleProductTags
-
buildSaveTagFutures
protected Function<? super Void,? extends CompletionStage<Void>> buildSaveTagFutures(HandlerArgs<T, T> args) -
loadExistingTags
-
saveTranslationsFuture
-
buildProductTranslationsMap
-
buildSaveTranslationFutures
@NotNull protected @NotNull Function<Void,CompletionStage<Void>> buildSaveTranslationFutures(HandlerArgs<T, T> args) -
saveProductTranslationRunnable
protected Runnable saveProductTranslationRunnable(List<Translation> translations, Locale locale, HandlerArgs<T, T> args) -
initTranslationsList
-
canHandle
Description copied from interface:BatchItemHandlerDetermines if this handler can handle the given exchange object.- Parameters:
exchangeObject- the exchange object- Returns:
- true if this handler can handle the exchange object, false otherwise
-
resolveExistingProducts
-
getCatalogProvider
-
getChildItemHandlers
-
getHelper
-
getVariantBatchItemHandler
-
getTagProvider
-
getTagBatchItemHandler
-