Class InventorySync
- java.lang.Object
 - 
- com.commercetools.sync.commons.BaseSync<io.sphere.sdk.inventory.InventoryEntryDraft,io.sphere.sdk.inventory.InventoryEntry,InventorySyncStatistics,InventorySyncOptions>
 - 
- com.commercetools.sync.inventories.InventorySync
 
 
 
- 
public final class InventorySync extends BaseSync<io.sphere.sdk.inventory.InventoryEntryDraft,io.sphere.sdk.inventory.InventoryEntry,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 aInventorySyncOptionsinstance to instantiate a newInventorySyncinstance that could be used to sync inventory drafts with the given inventory entries in the CTP project specified in the injectedInventorySyncOptionsinstance. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.concurrent.CompletionStage<InventorySyncStatistics>process(java.util.List<io.sphere.sdk.inventory.InventoryEntryDraft> inventoryEntryDrafts)Iterates through the wholeinventorieslist and accumulates its valid drafts to batches.protected java.util.concurrent.CompletionStage<InventorySyncStatistics>processBatch(java.util.List<io.sphere.sdk.inventory.InventoryEntryDraft> batch)Fetches existingInventoryEntryobjects 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 aInventorySyncOptionsinstance to instantiate a newInventorySyncinstance that could be used to sync inventory drafts with the given inventory entries in the CTP project specified in the injectedInventorySyncOptionsinstance.- 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<io.sphere.sdk.inventory.InventoryEntryDraft> inventoryEntryDrafts)
Iterates through the wholeinventorieslist 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:
 processin classBaseSync<io.sphere.sdk.inventory.InventoryEntryDraft,io.sphere.sdk.inventory.InventoryEntry,InventorySyncStatistics,InventorySyncOptions>- Parameters:
 inventoryEntryDrafts-ListofInventoryEntryDraftresources that would be synced into CTP project.- Returns:
 CompletionStagewithInventorySyncStatisticsholding statistics of all sync processes performed by this sync instance
 
- 
processBatch
protected java.util.concurrent.CompletionStage<InventorySyncStatistics> processBatch(@Nonnull java.util.List<io.sphere.sdk.inventory.InventoryEntryDraft> batch)
Fetches existingInventoryEntryobjects from CTP project that correspond to passedbatchOfDrafts. Having existing inventory entries fetched,batchOfDraftsis compared and synced with fetched objects bysyncBatch(Set, Set)function. When fetching existing inventory entries results in an empty optional thenbatchOfDraftsisn't processed.- Specified by:
 processBatchin classBaseSync<io.sphere.sdk.inventory.InventoryEntryDraft,io.sphere.sdk.inventory.InventoryEntry,InventorySyncStatistics,InventorySyncOptions>- Parameters:
 batch- batch of drafts that need to be synced- Returns:
 CompletionStageofVoidthat indicates method progress.
 
 - 
 
 -