Class CustomObjectSync
- java.lang.Object
-
- com.commercetools.sync.commons.BaseSync<com.commercetools.api.models.custom_object.CustomObject,com.commercetools.api.models.custom_object.CustomObjectDraft,NoopResourceUpdateAction,CustomObjectSyncStatistics,CustomObjectSyncOptions>
-
- com.commercetools.sync.customobjects.CustomObjectSync
-
public class CustomObjectSync extends BaseSync<com.commercetools.api.models.custom_object.CustomObject,com.commercetools.api.models.custom_object.CustomObjectDraft,NoopResourceUpdateAction,CustomObjectSyncStatistics,CustomObjectSyncOptions>
This class syncs custom object drafts with the corresponding custom objects in the CTP project.
-
-
Field Summary
-
Fields inherited from class com.commercetools.sync.commons.BaseSync
statistics, syncOptions
-
-
Constructor Summary
Constructors Constructor Description CustomObjectSync(CustomObjectSyncOptions syncOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.concurrent.CompletionStage<CustomObjectSyncStatistics>
process(java.util.List<com.commercetools.api.models.custom_object.CustomObjectDraft> customObjectDrafts)
Iterates through the wholecustomObjectDrafts
list and accumulates its valid drafts to batches.protected java.util.concurrent.CompletionStage<CustomObjectSyncStatistics>
processBatch(java.util.List<com.commercetools.api.models.custom_object.CustomObjectDraft> batch)
This method first creates a newSet
of validCustomObjectDraft
elements.-
Methods inherited from class com.commercetools.sync.commons.BaseSync
executeSupplierIfConcurrentModificationException, getStatistics, getSyncOptions, handleError, sync, syncBatches
-
-
-
-
Constructor Detail
-
CustomObjectSync
public CustomObjectSync(@Nonnull CustomObjectSyncOptions syncOptions)
-
-
Method Detail
-
process
protected java.util.concurrent.CompletionStage<CustomObjectSyncStatistics> process(@Nonnull java.util.List<com.commercetools.api.models.custom_object.CustomObjectDraft> customObjectDrafts)
Iterates through the wholecustomObjectDrafts
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.custom_object.CustomObject,com.commercetools.api.models.custom_object.CustomObjectDraft,NoopResourceUpdateAction,CustomObjectSyncStatistics,CustomObjectSyncOptions>
- Parameters:
customObjectDrafts
-List
ofCustomObjectDraft
's that would be synced into CTP project.- Returns:
CompletionStage
withCustomObjectSyncStatistics
holding statistics of all sync processes performed by this sync instance.
-
processBatch
protected java.util.concurrent.CompletionStage<CustomObjectSyncStatistics> processBatch(@Nonnull java.util.List<com.commercetools.api.models.custom_object.CustomObjectDraft> batch)
This method first creates a newSet
of validCustomObjectDraft
elements. For more on the rules of validation, check:CustomObjectBatchValidator.validateAndCollectReferencedKeys(List)
. Using the resulting set ofvalidCustomObjectDrafts
, the matching custom objects in the target CTP project are fetched then the methodsyncBatch(Set, Set)
is called to perform the sync (update or create requests accordingly) on the target project.In case of error during of fetching of existing custom objects, the error callback will be triggered. And the sync process would stop for the given batch.
- Specified by:
processBatch
in classBaseSync<com.commercetools.api.models.custom_object.CustomObject,com.commercetools.api.models.custom_object.CustomObjectDraft,NoopResourceUpdateAction,CustomObjectSyncStatistics,CustomObjectSyncOptions>
- Parameters:
batch
- batch of drafts that need to be synced- Returns:
- a
CompletionStage
containing an instance ofCustomObjectSyncStatistics
which contains information about the result of syncing the supplied batch to the target project.
-
-