public final class InventorySync extends BaseSync<io.sphere.sdk.inventory.InventoryEntryDraft,InventorySyncStatistics,InventorySyncOptions>
statistics, syncOptions| Constructor and Description |
|---|
InventorySync(InventorySyncOptions syncOptions)
Takes a
InventorySyncOptions instance to instantiate a new InventorySync instance that could be
used to sync inventory drafts with the given inventory entries in the CTP project specified in the injected
InventorySyncOptions instance. |
| Modifier and Type | Method and Description |
|---|---|
protected java.util.concurrent.CompletionStage<InventorySyncStatistics> |
process(java.util.List<io.sphere.sdk.inventory.InventoryEntryDraft> inventories)
Iterates through the whole
inventories list and accumulates its valid drafts to batches. |
protected java.util.concurrent.CompletionStage<InventorySyncStatistics> |
processBatch(java.util.List<io.sphere.sdk.inventory.InventoryEntryDraft> batchOfDrafts)
Fetches existing
InventoryEntry objects from CTP project that correspond to passed batchOfDrafts. |
protected java.util.concurrent.CompletionStage<InventorySyncStatistics> |
syncBatches(java.util.List<java.util.List<io.sphere.sdk.inventory.InventoryEntryDraft>> batches,
java.util.concurrent.CompletionStage<InventorySyncStatistics> result)
Given a list of resource (e.g.
|
executeSupplierIfConcurrentModificationException, getStatistics, getSyncOptions, syncpublic InventorySync(@Nonnull
InventorySyncOptions syncOptions)
InventorySyncOptions instance to instantiate a new InventorySync instance that could be
used to sync inventory drafts with the given inventory entries in the CTP project specified in the injected
InventorySyncOptions instance.syncOptions - the container of all the options of the sync process including the CTP project client and/or
configuration and other sync-specific options.@Nonnull protected java.util.concurrent.CompletionStage<InventorySyncStatistics> process(@Nonnull java.util.List<io.sphere.sdk.inventory.InventoryEntryDraft> inventories)
inventories list and accumulates its valid drafts to batches. Every batch
is then processed by processBatch(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.
process in class BaseSync<io.sphere.sdk.inventory.InventoryEntryDraft,InventorySyncStatistics,InventorySyncOptions>inventories - List of InventoryEntryDraft resources that would be synced into CTP project.CompletionStage with InventorySyncStatistics holding statistics of all sync
processes performed by this sync instanceprotected java.util.concurrent.CompletionStage<InventorySyncStatistics> syncBatches(@Nonnull java.util.List<java.util.List<io.sphere.sdk.inventory.InventoryEntryDraft>> batches, @Nonnull java.util.concurrent.CompletionStage<InventorySyncStatistics> result)
BaseSyncList<List> of resources, this method recursively calls
BaseSync.processBatch(List) on each batch, then removes it, until there are no more batches, in other words,
all batches have been synced.syncBatches in class BaseSync<io.sphere.sdk.inventory.InventoryEntryDraft,InventorySyncStatistics,InventorySyncOptions>batches - the batches of resources to sync.result - in the first call of this recursive method, this result is normally a completed future, it
used from within the method to recursively sync each batch once the previous batch has
finished syncing.CompletionStage<U> which contains as a result an instance of
BaseSyncStatistics representing the statistics of the sync process executed on the
given list of batches.protected java.util.concurrent.CompletionStage<InventorySyncStatistics> processBatch(@Nonnull java.util.List<io.sphere.sdk.inventory.InventoryEntryDraft> batchOfDrafts)
InventoryEntry objects from CTP project that correspond to passed batchOfDrafts.
Having existing inventory entries fetched, batchOfDrafts is compared and synced with fetched objects by
syncBatch(List, List) function. When fetching existing inventory entries results in
an empty optional then batchOfDrafts isn't processed.processBatch in class BaseSync<io.sphere.sdk.inventory.InventoryEntryDraft,InventorySyncStatistics,InventorySyncOptions>batchOfDrafts - batch of drafts that need to be syncedCompletionStage of Void that indicates method progress.