use of com.commercetools.sync.commons.utils.TriConsumer in project commercetools-project-sync by commercetools.
the class ProductSyncer method of.
@Nonnull
public static ProductSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock, @Nullable final ProductSyncCustomRequest productSyncCustomRequest) {
final QuadConsumer<SyncException, Optional<ProductDraft>, Optional<ProductProjection>, List<UpdateAction<Product>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> {
final String resourceKey = oldResource.map(WithKey::getKey).orElse(IDENTIFIER_NOT_PRESENT);
logErrorCallback(LOGGER, "product", exception, resourceKey, updateActions);
};
final TriConsumer<SyncException, Optional<ProductDraft>, Optional<ProductProjection>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "product", exception, oldResource);
final ProductSyncOptions syncOptions = ProductSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
final ProductSync productSync = new ProductSync(syncOptions);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
return new ProductSyncer(productSync, sourceClient, targetClient, customObjectService, clock, productSyncCustomRequest);
}
use of com.commercetools.sync.commons.utils.TriConsumer in project commercetools-project-sync by commercetools.
the class ProductTypeSyncer method of.
@Nonnull
public static ProductTypeSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
final QuadConsumer<SyncException, Optional<ProductTypeDraft>, Optional<ProductType>, List<UpdateAction<ProductType>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "product type", exception, oldResource, updateActions);
final TriConsumer<SyncException, Optional<ProductTypeDraft>, Optional<ProductType>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "product type", exception, oldResource);
final ProductTypeSyncOptions syncOptions = ProductTypeSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
final ProductTypeSync productTypeSync = new ProductTypeSync(syncOptions);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
return new ProductTypeSyncer(productTypeSync, sourceClient, targetClient, customObjectService, clock);
}
use of com.commercetools.sync.commons.utils.TriConsumer 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);
}
use of com.commercetools.sync.commons.utils.TriConsumer 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);
}
use of com.commercetools.sync.commons.utils.TriConsumer 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);
}
Aggregations