Search in sources :

Example 6 with QuadConsumer

use of com.commercetools.sync.commons.utils.QuadConsumer in project commercetools-project-sync by commercetools.

the class StateSyncer method of.

public static StateSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
    final QuadConsumer<SyncException, Optional<StateDraft>, Optional<State>, List<UpdateAction<State>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "state", exception, oldResource, updateActions);
    final TriConsumer<SyncException, Optional<StateDraft>, Optional<State>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "state", exception, oldResource);
    StateSyncOptions syncOptions = StateSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
    StateSync stateSync = new StateSync(syncOptions);
    CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
    return new StateSyncer(stateSync, sourceClient, targetClient, customObjectService, clock);
}
Also used : StateSyncStatistics(com.commercetools.sync.states.helpers.StateSyncStatistics) SyncException(com.commercetools.sync.commons.exceptions.SyncException) StateQuery(io.sphere.sdk.states.queries.StateQuery) LoggerFactory(org.slf4j.LoggerFactory) UpdateAction(io.sphere.sdk.commands.UpdateAction) QuadConsumer(com.commercetools.sync.commons.utils.QuadConsumer) SyncUtils.logWarningCallback(com.commercetools.project.sync.util.SyncUtils.logWarningCallback) SphereClient(io.sphere.sdk.client.SphereClient) TriConsumer(com.commercetools.sync.commons.utils.TriConsumer) Nonnull(javax.annotation.Nonnull) StateSyncOptionsBuilder(com.commercetools.sync.states.StateSyncOptionsBuilder) SyncUtils.logErrorCallback(com.commercetools.project.sync.util.SyncUtils.logErrorCallback) Logger(org.slf4j.Logger) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) StateSync(com.commercetools.sync.states.StateSync) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions) State(io.sphere.sdk.states.State) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) Syncer(com.commercetools.project.sync.Syncer) StateTransformUtils.toStateDrafts(com.commercetools.sync.states.utils.StateTransformUtils.toStateDrafts) Clock(java.time.Clock) Optional(java.util.Optional) StateDraft(io.sphere.sdk.states.StateDraft) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) StateSync(com.commercetools.sync.states.StateSync) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) Optional(java.util.Optional) State(io.sphere.sdk.states.State) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) List(java.util.List) SyncException(com.commercetools.sync.commons.exceptions.SyncException) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions)

Example 7 with QuadConsumer

use of com.commercetools.sync.commons.utils.QuadConsumer in project commercetools-project-sync by commercetools.

the class TaxCategorySyncer method of.

@Nonnull
public static TaxCategorySyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
    final QuadConsumer<SyncException, Optional<TaxCategoryDraft>, Optional<TaxCategory>, List<UpdateAction<TaxCategory>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "tax category", exception, oldResource, updateActions);
    final TriConsumer<SyncException, Optional<TaxCategoryDraft>, Optional<TaxCategory>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "tax category", exception, oldResource);
    final TaxCategorySyncOptions syncOptions = TaxCategorySyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
    final TaxCategorySync taxCategorySync = new TaxCategorySync(syncOptions);
    final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
    return new TaxCategorySyncer(taxCategorySync, sourceClient, targetClient, customObjectService, clock);
}
Also used : TaxCategorySync(com.commercetools.sync.taxcategories.TaxCategorySync) TaxCategorySyncStatistics(com.commercetools.sync.taxcategories.helpers.TaxCategorySyncStatistics) SyncException(com.commercetools.sync.commons.exceptions.SyncException) TaxCategoryDraft(io.sphere.sdk.taxcategories.TaxCategoryDraft) LoggerFactory(org.slf4j.LoggerFactory) UpdateAction(io.sphere.sdk.commands.UpdateAction) TaxCategoryQuery(io.sphere.sdk.taxcategories.queries.TaxCategoryQuery) CompletableFuture(java.util.concurrent.CompletableFuture) QuadConsumer(com.commercetools.sync.commons.utils.QuadConsumer) SyncUtils.logWarningCallback(com.commercetools.project.sync.util.SyncUtils.logWarningCallback) TaxRateDraft(io.sphere.sdk.taxcategories.TaxRateDraft) SphereClient(io.sphere.sdk.client.SphereClient) TriConsumer(com.commercetools.sync.commons.utils.TriConsumer) Nonnull(javax.annotation.Nonnull) TaxCategoryDraftBuilder(io.sphere.sdk.taxcategories.TaxCategoryDraftBuilder) SyncUtils.logErrorCallback(com.commercetools.project.sync.util.SyncUtils.logErrorCallback) TaxRate(io.sphere.sdk.taxcategories.TaxRate) Logger(org.slf4j.Logger) TaxCategorySyncOptionsBuilder(com.commercetools.sync.taxcategories.TaxCategorySyncOptionsBuilder) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) Collectors(java.util.stream.Collectors) List(java.util.List) TaxCategorySyncOptions(com.commercetools.sync.taxcategories.TaxCategorySyncOptions) CompletionStage(java.util.concurrent.CompletionStage) Syncer(com.commercetools.project.sync.Syncer) TaxRateDraftBuilder(io.sphere.sdk.taxcategories.TaxRateDraftBuilder) Clock(java.time.Clock) Optional(java.util.Optional) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) TaxCategory(io.sphere.sdk.taxcategories.TaxCategory) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) TaxCategorySync(com.commercetools.sync.taxcategories.TaxCategorySync) Optional(java.util.Optional) TaxCategorySyncOptions(com.commercetools.sync.taxcategories.TaxCategorySyncOptions) TaxCategory(io.sphere.sdk.taxcategories.TaxCategory) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) List(java.util.List) SyncException(com.commercetools.sync.commons.exceptions.SyncException) Nonnull(javax.annotation.Nonnull)

Example 8 with QuadConsumer

use of com.commercetools.sync.commons.utils.QuadConsumer in project commercetools-project-sync by commercetools.

the class TypeSyncer method of.

@Nonnull
public static TypeSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
    final QuadConsumer<SyncException, Optional<TypeDraft>, Optional<Type>, List<UpdateAction<Type>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "type", exception, oldResource, updateActions);
    final TriConsumer<SyncException, Optional<TypeDraft>, Optional<Type>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "type", exception, oldResource);
    final TypeSyncOptions syncOptions = TypeSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
    final TypeSync typeSync = new TypeSync(syncOptions);
    final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
    return new TypeSyncer(typeSync, sourceClient, targetClient, customObjectService, clock);
}
Also used : TypeDraft(io.sphere.sdk.types.TypeDraft) TypeSyncOptionsBuilder(com.commercetools.sync.types.TypeSyncOptionsBuilder) SyncException(com.commercetools.sync.commons.exceptions.SyncException) LoggerFactory(org.slf4j.LoggerFactory) UpdateAction(io.sphere.sdk.commands.UpdateAction) CompletableFuture(java.util.concurrent.CompletableFuture) QuadConsumer(com.commercetools.sync.commons.utils.QuadConsumer) TypeSyncOptions(com.commercetools.sync.types.TypeSyncOptions) SyncUtils.logWarningCallback(com.commercetools.project.sync.util.SyncUtils.logWarningCallback) SphereClient(io.sphere.sdk.client.SphereClient) TypeQuery(io.sphere.sdk.types.queries.TypeQuery) TriConsumer(com.commercetools.sync.commons.utils.TriConsumer) TypeDraftBuilder(io.sphere.sdk.types.TypeDraftBuilder) Nonnull(javax.annotation.Nonnull) SyncUtils.logErrorCallback(com.commercetools.project.sync.util.SyncUtils.logErrorCallback) Logger(org.slf4j.Logger) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) TypeSyncStatistics(com.commercetools.sync.types.helpers.TypeSyncStatistics) TypeSync(com.commercetools.sync.types.TypeSync) Collectors(java.util.stream.Collectors) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) Syncer(com.commercetools.project.sync.Syncer) Clock(java.time.Clock) Optional(java.util.Optional) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) Type(io.sphere.sdk.types.Type) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) Type(io.sphere.sdk.types.Type) Optional(java.util.Optional) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) List(java.util.List) TypeSyncOptions(com.commercetools.sync.types.TypeSyncOptions) SyncException(com.commercetools.sync.commons.exceptions.SyncException) TypeSync(com.commercetools.sync.types.TypeSync) Nonnull(javax.annotation.Nonnull)

Example 9 with QuadConsumer

use of com.commercetools.sync.commons.utils.QuadConsumer in project commercetools-project-sync by commercetools.

the class CategorySyncer method of.

@Nonnull
public static CategorySyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
    final QuadConsumer<SyncException, Optional<CategoryDraft>, Optional<Category>, List<UpdateAction<Category>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "category", exception, oldResource, updateActions);
    final TriConsumer<SyncException, Optional<CategoryDraft>, Optional<Category>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "category", exception, oldResource);
    final CategorySyncOptions syncOptions = CategorySyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
    final CategorySync categorySync = new CategorySync(syncOptions);
    final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
    return new CategorySyncer(categorySync, sourceClient, targetClient, customObjectService, clock);
}
Also used : CategorySyncStatistics(com.commercetools.sync.categories.helpers.CategorySyncStatistics) SyncException(com.commercetools.sync.commons.exceptions.SyncException) LoggerFactory(org.slf4j.LoggerFactory) UpdateAction(io.sphere.sdk.commands.UpdateAction) QuadConsumer(com.commercetools.sync.commons.utils.QuadConsumer) CategoryDraft(io.sphere.sdk.categories.CategoryDraft) CategoryQuery(io.sphere.sdk.categories.queries.CategoryQuery) SyncUtils.logWarningCallback(com.commercetools.project.sync.util.SyncUtils.logWarningCallback) SphereClient(io.sphere.sdk.client.SphereClient) CategorySync(com.commercetools.sync.categories.CategorySync) TriConsumer(com.commercetools.sync.commons.utils.TriConsumer) Nonnull(javax.annotation.Nonnull) SyncUtils.logErrorCallback(com.commercetools.project.sync.util.SyncUtils.logErrorCallback) Logger(org.slf4j.Logger) Category(io.sphere.sdk.categories.Category) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) CategorySyncOptionsBuilder(com.commercetools.sync.categories.CategorySyncOptionsBuilder) CategorySyncOptions(com.commercetools.sync.categories.CategorySyncOptions) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) Syncer(com.commercetools.project.sync.Syncer) CategoryTransformUtils.toCategoryDrafts(com.commercetools.sync.categories.utils.CategoryTransformUtils.toCategoryDrafts) Clock(java.time.Clock) Optional(java.util.Optional) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) Category(io.sphere.sdk.categories.Category) Optional(java.util.Optional) CategorySyncOptions(com.commercetools.sync.categories.CategorySyncOptions) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) List(java.util.List) SyncException(com.commercetools.sync.commons.exceptions.SyncException) CategorySync(com.commercetools.sync.categories.CategorySync) Nonnull(javax.annotation.Nonnull)

Example 10 with QuadConsumer

use of com.commercetools.sync.commons.utils.QuadConsumer in project commercetools-project-sync by commercetools.

the class CustomerSyncer method of.

public static CustomerSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
    final QuadConsumer<SyncException, Optional<CustomerDraft>, Optional<Customer>, List<UpdateAction<Customer>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "customer", exception, oldResource, updateActions);
    final TriConsumer<SyncException, Optional<CustomerDraft>, Optional<Customer>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "customer", exception, oldResource);
    final CustomerSyncOptions customerSyncOptions = CustomerSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
    final CustomerSync customerSync = new CustomerSync(customerSyncOptions);
    final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
    return new CustomerSyncer(customerSync, sourceClient, targetClient, customObjectService, clock);
}
Also used : SyncException(com.commercetools.sync.commons.exceptions.SyncException) LoggerFactory(org.slf4j.LoggerFactory) UpdateAction(io.sphere.sdk.commands.UpdateAction) QuadConsumer(com.commercetools.sync.commons.utils.QuadConsumer) CustomerSyncStatistics(com.commercetools.sync.customers.helpers.CustomerSyncStatistics) SyncUtils.logWarningCallback(com.commercetools.project.sync.util.SyncUtils.logWarningCallback) CustomerQuery(io.sphere.sdk.customers.queries.CustomerQuery) CustomerTransformUtils.toCustomerDrafts(com.commercetools.sync.customers.utils.CustomerTransformUtils.toCustomerDrafts) SphereClient(io.sphere.sdk.client.SphereClient) TriConsumer(com.commercetools.sync.commons.utils.TriConsumer) Nonnull(javax.annotation.Nonnull) SyncUtils.logErrorCallback(com.commercetools.project.sync.util.SyncUtils.logErrorCallback) Logger(org.slf4j.Logger) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) CustomerSync(com.commercetools.sync.customers.CustomerSync) Customer(io.sphere.sdk.customers.Customer) CustomerSyncOptionsBuilder(com.commercetools.sync.customers.CustomerSyncOptionsBuilder) List(java.util.List) CustomerSyncOptions(com.commercetools.sync.customers.CustomerSyncOptions) CompletionStage(java.util.concurrent.CompletionStage) Syncer(com.commercetools.project.sync.Syncer) Clock(java.time.Clock) Optional(java.util.Optional) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) CustomerDraft(io.sphere.sdk.customers.CustomerDraft) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) Optional(java.util.Optional) CustomerSyncOptions(com.commercetools.sync.customers.CustomerSyncOptions) Customer(io.sphere.sdk.customers.Customer) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) List(java.util.List) SyncException(com.commercetools.sync.commons.exceptions.SyncException) CustomerSync(com.commercetools.sync.customers.CustomerSync)

Aggregations

SyncException (com.commercetools.sync.commons.exceptions.SyncException)12 QuadConsumer (com.commercetools.sync.commons.utils.QuadConsumer)12 UpdateAction (io.sphere.sdk.commands.UpdateAction)12 List (java.util.List)12 Optional (java.util.Optional)12 Nonnull (javax.annotation.Nonnull)12 Syncer (com.commercetools.project.sync.Syncer)11 CustomObjectService (com.commercetools.project.sync.service.CustomObjectService)11 CustomObjectServiceImpl (com.commercetools.project.sync.service.impl.CustomObjectServiceImpl)11 SyncUtils.logErrorCallback (com.commercetools.project.sync.util.SyncUtils.logErrorCallback)11 SyncUtils.logWarningCallback (com.commercetools.project.sync.util.SyncUtils.logWarningCallback)11 TriConsumer (com.commercetools.sync.commons.utils.TriConsumer)11 SphereClient (io.sphere.sdk.client.SphereClient)11 Clock (java.time.Clock)11 CompletionStage (java.util.concurrent.CompletionStage)11 Logger (org.slf4j.Logger)11 LoggerFactory (org.slf4j.LoggerFactory)11 IDENTIFIER_NOT_PRESENT (com.commercetools.project.sync.util.SyncUtils.IDENTIFIER_NOT_PRESENT)4 CompletableFuture (java.util.concurrent.CompletableFuture)3 Collectors (java.util.stream.Collectors)3