use of com.commercetools.project.sync.util.SyncUtils.IDENTIFIER_NOT_PRESENT in project commercetools-project-sync by commercetools.
the class ShoppingListSyncer method of.
public static ShoppingListSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
final QuadConsumer<SyncException, Optional<ShoppingListDraft>, Optional<ShoppingList>, List<UpdateAction<ShoppingList>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "shoppingList", exception, oldResource.map(ShoppingList::getKey).orElse(IDENTIFIER_NOT_PRESENT), updateActions);
final TriConsumer<SyncException, Optional<ShoppingListDraft>, Optional<ShoppingList>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "shoppingList", exception, oldResource.map(ShoppingList::getKey).orElse(IDENTIFIER_NOT_PRESENT));
final ShoppingListSyncOptions shoppingListSyncOptions = ShoppingListSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
final ShoppingListSync shoppingListSync = new ShoppingListSync(shoppingListSyncOptions);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
return new ShoppingListSyncer(shoppingListSync, sourceClient, targetClient, customObjectService, clock);
}
use of com.commercetools.project.sync.util.SyncUtils.IDENTIFIER_NOT_PRESENT 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.project.sync.util.SyncUtils.IDENTIFIER_NOT_PRESENT in project commercetools-project-sync by commercetools.
the class InventoryEntrySyncer method of.
public static InventoryEntrySyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
final QuadConsumer<SyncException, Optional<InventoryEntryDraft>, Optional<InventoryEntry>, List<UpdateAction<InventoryEntry>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "inventory entry", exception, oldResource.map(InventoryEntry::getSku).orElse(IDENTIFIER_NOT_PRESENT), updateActions);
final TriConsumer<SyncException, Optional<InventoryEntryDraft>, Optional<InventoryEntry>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "inventory entry", exception, oldResource.map(InventoryEntry::getSku).orElse(IDENTIFIER_NOT_PRESENT));
final InventorySyncOptions syncOptions = InventorySyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
final InventorySync inventorySync = new InventorySync(syncOptions);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
return new InventoryEntrySyncer(inventorySync, sourceClient, targetClient, customObjectService, clock);
}
Aggregations