Class VariantBatchItemHandler<T extends Variant>
java.lang.Object
com.broadleafcommerce.dataexchange.service.AbstractBatchItemHandler<T1,T2>
com.broadleafcommerce.dataexchange.service.product.ProductRelatedBatchItemHandler<ComprehensiveProduct,T>
com.broadleafcommerce.dataexchange.service.product.VariantBatchItemHandler<T>
- All Implemented Interfaces:
BatchItemHandler<ComprehensiveProduct,
T>
public class VariantBatchItemHandler<T extends Variant>
extends ProductRelatedBatchItemHandler<ComprehensiveProduct,T>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionVariantBatchItemHandler
(CatalogProvider<ComprehensiveProduct, T> catalogProvider, ProductTagBatchItemHandler<ProductTag> tagBatchItemHandler, AdvancedTagProvider<AdvancedTag, ProductTag> tagProvider, List<VariantRelatedBatchItemHandler<ComprehensiveProduct, ?>> childItemHandlers, ProductBatchItemHandlerHelper<ComprehensiveProduct> helper, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected Function<? super Void,
? extends CompletionStage<Void>> protected @NotNull Function<Void,
CompletionStage<Void>> boolean
canHandle
(ExchangeObject exchangeObject) Determines if this handler can handle the given exchange object.Create any supplemental futures that should be executed after the main future.protected CatalogProvider<ComprehensiveProduct,
T> protected List<VariantRelatedBatchItemHandler<ComprehensiveProduct,
?>> protected ProductTagBatchItemHandler<ProductTag>
protected AdvancedTagProvider<AdvancedTag,
ProductTag> Handle the create operation.Handle the delete operation.protected CompletableFuture<Void>
Handle the update operation.protected void
initTranslationsList
(T savedVariant) protected void
initVariantsList
(ComprehensiveProduct savedProduct) protected CompletableFuture<Void>
This method is called after the item has been saved.protected CompletableFuture<Void>
protected CompletableFuture<Void>
protected Runnable
saveVariantTranslationRunnable
(List<Translation> translations, Locale locale, HandlerArgs<ComprehensiveProduct, T> args) Methods inherited from class com.broadleafcommerce.dataexchange.service.AbstractBatchItemHandler
applyHandle, applyPostOperations, buildTranslationMap, createFutureInternal, execute, execute, execute, execute, getSavedTopLevel, getTypeFactory, isNewlyCreated
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.dataexchange.service.BatchItemHandler
completedFuture, createCompletableFuture, createCompletableFuture, handle, populateCorrelationId, preHandle, retryableRunnable, retryableSupplier, shouldAbort
-
Field Details
-
VARIANT_TRANSLATION_MAP
- See Also:
-
EXISTING_VARIANT_TAGS
Existing product tags map, keyed by tag name and ID.- See Also:
-
-
Constructor Details
-
VariantBatchItemHandler
public VariantBatchItemHandler(CatalogProvider<ComprehensiveProduct, T> catalogProvider, ProductTagBatchItemHandler<ProductTag> tagBatchItemHandler, AdvancedTagProvider<AdvancedTag, ProductTag> tagProvider, List<VariantRelatedBatchItemHandler<ComprehensiveProduct, ?>> childItemHandlers, ProductBatchItemHandlerHelper<ComprehensiveProduct> helper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
handleCreate
Description copied from interface:BatchItemHandler
Handle the create operation. This method is called whenHandlerArgs.getOperationType()
isBatchItemOperationType.CREATE
. -
handleUpdate
Description copied from interface:BatchItemHandler
Handle the update operation. This method is called whenHandlerArgs.getOperationType()
isBatchItemOperationType.UPDATE
. -
handleDelete
Description copied from interface:BatchItemHandler
Handle the delete operation. This method is called whenHandlerArgs.getOperationType()
isBatchItemOperationType.DELETE
.When performing a delete, unless there is additional logic that needs to be executed, the supplier should return null.
-
postHandle
Description copied from interface:BatchItemHandler
This 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.
-
initVariantsList
-
createSupplementalFutures
Description copied from interface:BatchItemHandler
Create 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.
-
handleTags
-
buildSaveTagFutures
protected Function<? super Void,? extends CompletionStage<Void>> buildSaveTagFutures(HandlerArgs<ComprehensiveProduct, T> args) -
loadExistingTags
-
saveTranslationsFutures
-
prepareVariantTranslations
protected CompletableFuture<Void> prepareVariantTranslations(HandlerArgs<ComprehensiveProduct, T> args) -
buildSaveTranslationFutures
@NotNull protected @NotNull Function<Void,CompletionStage<Void>> buildSaveTranslationFutures(HandlerArgs<ComprehensiveProduct, T> args) -
saveVariantTranslationRunnable
protected Runnable saveVariantTranslationRunnable(List<Translation> translations, Locale locale, HandlerArgs<ComprehensiveProduct, T> args) -
initTranslationsList
-
canHandle
Description copied from interface:BatchItemHandler
Determines 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
-
getCatalogProvider
-
getChildItemHandlers
-
getTagProvider
-
getTagBatchItemHandler
-
getHelper
-