Class InventorySync
- java.lang.Object
-
- com.commercetools.sync.commons.BaseSync<com.commercetools.api.models.inventory.InventoryEntry,com.commercetools.api.models.inventory.InventoryEntryDraft,com.commercetools.api.models.inventory.InventoryEntryUpdateAction,InventorySyncStatistics,InventorySyncOptions>
-
- com.commercetools.sync.inventories.InventorySync
-
public final class InventorySync extends BaseSync<com.commercetools.api.models.inventory.InventoryEntry,com.commercetools.api.models.inventory.InventoryEntryDraft,com.commercetools.api.models.inventory.InventoryEntryUpdateAction,InventorySyncStatistics,InventorySyncOptions>
Default implementation of inventories sync process.
-
-
Field Summary
-
Fields inherited from class com.commercetools.sync.commons.BaseSync
statistics, syncOptions
-
-
Constructor Summary
Constructors Constructor Description InventorySync(InventorySyncOptions syncOptions)
Takes aInventorySyncOptions
instance to instantiate a newInventorySync
instance that could be used to sync inventory drafts with the given inventory entries in the CTP project specified in the injectedInventorySyncOptions
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.concurrent.CompletionStage<InventorySyncStatistics>
process(java.util.List<com.commercetools.api.models.inventory.InventoryEntryDraft> inventoryEntryDrafts)
Iterates through the wholeinventories
list and accumulates its valid drafts to batches.protected java.util.concurrent.CompletionStage<InventorySyncStatistics>
processBatch(java.util.List<com.commercetools.api.models.inventory.InventoryEntryDraft> batch)
Fetches existingInventoryEntry
objects from CTP project that correspond to passedbatchOfDrafts
.-
Methods inherited from class com.commercetools.sync.commons.BaseSync
executeSupplierIfConcurrentModificationException, getStatistics, getSyncOptions, handleError, sync, syncBatches
-
-
-
-
Constructor Detail
-
InventorySync
public InventorySync(@Nonnull InventorySyncOptions syncOptions)
Takes aInventorySyncOptions
instance to instantiate a newInventorySync
instance that could be used to sync inventory drafts with the given inventory entries in the CTP project specified in the injectedInventorySyncOptions
instance.- Parameters:
syncOptions
- the container of all the options of the sync process including the CTP project client and/or configuration and other sync-specific options.
-
-
Method Detail
-
process
@Nonnull protected java.util.concurrent.CompletionStage<InventorySyncStatistics> process(@Nonnull java.util.List<com.commercetools.api.models.inventory.InventoryEntryDraft> inventoryEntryDrafts)
Iterates through the wholeinventories
list and accumulates its valid drafts to batches. Every batch is then processed byprocessBatch(List)
.Inherited doc: Given a list of resource (e.g. categories, products, etc..) drafts. This method compares each new resource in this list with it's corresponding old resource in a given CTP project, and in turn it either issues update actions on the existing resource if it exists or create it if it doesn't.
- Specified by:
process
in classBaseSync<com.commercetools.api.models.inventory.InventoryEntry,com.commercetools.api.models.inventory.InventoryEntryDraft,com.commercetools.api.models.inventory.InventoryEntryUpdateAction,InventorySyncStatistics,InventorySyncOptions>
- Parameters:
inventoryEntryDrafts
-List
ofInventoryEntryDraft
resources that would be synced into CTP project.- Returns:
CompletionStage
withInventorySyncStatistics
holding statistics of all sync processes performed by this sync instance
-
processBatch
protected java.util.concurrent.CompletionStage<InventorySyncStatistics> processBatch(@Nonnull java.util.List<com.commercetools.api.models.inventory.InventoryEntryDraft> batch)
Fetches existingInventoryEntry
objects from CTP project that correspond to passedbatchOfDrafts
. Having existing inventory entries fetched,batchOfDrafts
is compared and synced with fetched objects bysyncBatch(Set, Set)
function. When fetching existing inventory entries results in an empty optional thenbatchOfDrafts
isn't processed.- Specified by:
processBatch
in classBaseSync<com.commercetools.api.models.inventory.InventoryEntry,com.commercetools.api.models.inventory.InventoryEntryDraft,com.commercetools.api.models.inventory.InventoryEntryUpdateAction,InventorySyncStatistics,InventorySyncOptions>
- Parameters:
batch
- batch of drafts that need to be synced- Returns:
CompletionStage
ofVoid
that indicates method progress.
-
-