Search in sources :

Example 1 with ASSETS

use of com.commercetools.sync.products.ActionGroup.ASSETS in project commercetools-sync-java by commercetools.

the class ProductUpdateActionUtils method collectAllVariantUpdateActions.

@Nonnull
private static List<UpdateAction<Product>> collectAllVariantUpdateActions(@Nonnull final List<UpdateAction<Product>> sameForAllUpdateActions, @Nonnull final ProductProjection oldProduct, @Nonnull final ProductDraft newProduct, @Nonnull final ProductVariant oldProductVariant, @Nonnull final ProductVariantDraft newProductVariant, @Nonnull final Map<String, AttributeMetaData> attributesMetaData, @Nonnull final ProductSyncOptions syncOptions) {
    final ArrayList<UpdateAction<Product>> updateActions = new ArrayList<>();
    final SyncFilter syncFilter = syncOptions.getSyncFilter();
    updateActions.addAll(buildActionsIfPassesFilter(syncFilter, ATTRIBUTES, () -> emptyIfNull(buildProductVariantAttributesUpdateActions(oldProduct, newProduct, oldProductVariant, newProductVariant, attributesMetaData, syncOptions)).stream().filter(collectedUpdateAction -> hasDuplicateSameForAllAction(sameForAllUpdateActions, collectedUpdateAction)).collect(Collectors.toList())));
    updateActions.addAll(buildActionsIfPassesFilter(syncFilter, IMAGES, () -> buildProductVariantImagesUpdateActions(oldProductVariant, newProductVariant)));
    updateActions.addAll(buildActionsIfPassesFilter(syncFilter, PRICES, () -> buildProductVariantPricesUpdateActions(oldProduct, newProduct, oldProductVariant, newProductVariant, syncOptions)));
    updateActions.addAll(buildActionsIfPassesFilter(syncFilter, ASSETS, () -> buildProductVariantAssetsUpdateActions(oldProduct, newProduct, oldProductVariant, newProductVariant, syncOptions)));
    buildActionIfPassesFilter(syncFilter, SKU, () -> buildProductVariantSkuUpdateAction(oldProductVariant, newProductVariant)).ifPresent(updateActions::add);
    return updateActions;
}
Also used : ProductVariant(io.sphere.sdk.products.ProductVariant) AddToCategory(io.sphere.sdk.products.commands.updateactions.AddToCategory) SKU(com.commercetools.sync.products.ActionGroup.SKU) Reference(io.sphere.sdk.models.Reference) ProductVariantDraft(io.sphere.sdk.products.ProductVariantDraft) SyncException(com.commercetools.sync.commons.exceptions.SyncException) CommonTypeUpdateActionUtils.buildUpdateActionForReferences(com.commercetools.sync.commons.utils.CommonTypeUpdateActionUtils.buildUpdateActionForReferences) SetCategoryOrderHint(io.sphere.sdk.products.commands.updateactions.SetCategoryOrderHint) UpdateAction(io.sphere.sdk.commands.UpdateAction) SearchKeywords(io.sphere.sdk.search.SearchKeywords) BaseSyncOptions(com.commercetools.sync.commons.BaseSyncOptions) ProductVariantUpdateActionUtils.buildProductVariantImagesUpdateActions(com.commercetools.sync.products.utils.ProductVariantUpdateActionUtils.buildProductVariantImagesUpdateActions) Collections.singletonList(java.util.Collections.singletonList) ChangeName(io.sphere.sdk.products.commands.updateactions.ChangeName) SetTaxCategory(io.sphere.sdk.products.commands.updateactions.SetTaxCategory) UnorderedCollectionSyncUtils.buildRemoveUpdateActions(com.commercetools.sync.internals.utils.UnorderedCollectionSyncUtils.buildRemoveUpdateActions) Map(java.util.Map) PRICES(com.commercetools.sync.products.ActionGroup.PRICES) AddVariant(io.sphere.sdk.products.commands.updateactions.AddVariant) ProductDraft(io.sphere.sdk.products.ProductDraft) ProductProjection(io.sphere.sdk.products.ProductProjection) ChangeMasterVariant(io.sphere.sdk.products.commands.updateactions.ChangeMasterVariant) Collectors.toSet(java.util.stream.Collectors.toSet) ProductVariantUpdateActionUtils.buildProductVariantAttributesUpdateActions(com.commercetools.sync.products.utils.ProductVariantUpdateActionUtils.buildProductVariantAttributesUpdateActions) Collections.emptyList(java.util.Collections.emptyList) Category(io.sphere.sdk.categories.Category) SetAttributeInAllVariants(io.sphere.sdk.products.commands.updateactions.SetAttributeInAllVariants) Set(java.util.Set) ActionGroup(com.commercetools.sync.products.ActionGroup) AttributeMetaData(com.commercetools.sync.products.AttributeMetaData) Product(io.sphere.sdk.products.Product) CommonTypeUpdateActionUtils.areResourceIdentifiersEqual(com.commercetools.sync.commons.utils.CommonTypeUpdateActionUtils.areResourceIdentifiersEqual) State(io.sphere.sdk.states.State) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) ChangeSlug(io.sphere.sdk.products.commands.updateactions.ChangeSlug) FilterUtils.executeSupplierIfPassesFilter(com.commercetools.sync.commons.utils.FilterUtils.executeSupplierIfPassesFilter) Objects(java.util.Objects) LocalizedString(io.sphere.sdk.models.LocalizedString) IMAGES(com.commercetools.sync.products.ActionGroup.IMAGES) List(java.util.List) Publish(io.sphere.sdk.products.commands.updateactions.Publish) Optional(java.util.Optional) Objects.nonNull(java.util.Objects.nonNull) ProductSyncOptions(com.commercetools.sync.products.ProductSyncOptions) ResourceIdentifier(io.sphere.sdk.models.ResourceIdentifier) CategoryOrderHints(io.sphere.sdk.products.CategoryOrderHints) SetMetaKeywords(io.sphere.sdk.products.commands.updateactions.SetMetaKeywords) SetSearchKeywords(io.sphere.sdk.products.commands.updateactions.SetSearchKeywords) CollectionUtils.collectionToMap(com.commercetools.sync.commons.utils.CollectionUtils.collectionToMap) SetMetaTitle(io.sphere.sdk.products.commands.updateactions.SetMetaTitle) HashMap(java.util.HashMap) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) SetDescription(io.sphere.sdk.products.commands.updateactions.SetDescription) TransitionState(io.sphere.sdk.products.commands.updateactions.TransitionState) SyncFilter(com.commercetools.sync.products.SyncFilter) CollectionUtils.emptyIfNull(com.commercetools.sync.commons.utils.CollectionUtils.emptyIfNull) ATTRIBUTES(com.commercetools.sync.products.ActionGroup.ATTRIBUTES) ProductVariantUpdateActionUtils.buildProductVariantSkuUpdateAction(com.commercetools.sync.products.utils.ProductVariantUpdateActionUtils.buildProductVariantSkuUpdateAction) CollectionUtils.filterCollection(com.commercetools.sync.commons.utils.CollectionUtils.filterCollection) SetMetaDescription(io.sphere.sdk.products.commands.updateactions.SetMetaDescription) Unpublish(io.sphere.sdk.products.commands.updateactions.Unpublish) Nonnull(javax.annotation.Nonnull) Collections.emptyMap(java.util.Collections.emptyMap) Optional.ofNullable(java.util.Optional.ofNullable) ProductVariantUpdateActionUtils.buildProductVariantPricesUpdateActions(com.commercetools.sync.products.utils.ProductVariantUpdateActionUtils.buildProductVariantPricesUpdateActions) ASSETS(com.commercetools.sync.products.ActionGroup.ASSETS) RemoveVariant(io.sphere.sdk.products.commands.updateactions.RemoveVariant) Collectors.toList(java.util.stream.Collectors.toList) StringUtils.isBlank(org.apache.commons.lang3.StringUtils.isBlank) CommonTypeUpdateActionUtils.buildUpdateActions(com.commercetools.sync.commons.utils.CommonTypeUpdateActionUtils.buildUpdateActions) BooleanUtils.toBoolean(org.apache.commons.lang3.BooleanUtils.toBoolean) CommonTypeUpdateActionUtils.buildUpdateAction(com.commercetools.sync.commons.utils.CommonTypeUpdateActionUtils.buildUpdateAction) ProductVariantUpdateActionUtils.buildProductVariantAssetsUpdateActions(com.commercetools.sync.products.utils.ProductVariantUpdateActionUtils.buildProductVariantAssetsUpdateActions) RemoveFromCategory(io.sphere.sdk.products.commands.updateactions.RemoveFromCategory) Collections(java.util.Collections) Referenceable(io.sphere.sdk.models.Referenceable) ResourceImpl(io.sphere.sdk.models.ResourceImpl) SyncFilter(com.commercetools.sync.products.SyncFilter) UpdateAction(io.sphere.sdk.commands.UpdateAction) ProductVariantUpdateActionUtils.buildProductVariantSkuUpdateAction(com.commercetools.sync.products.utils.ProductVariantUpdateActionUtils.buildProductVariantSkuUpdateAction) CommonTypeUpdateActionUtils.buildUpdateAction(com.commercetools.sync.commons.utils.CommonTypeUpdateActionUtils.buildUpdateAction) ArrayList(java.util.ArrayList) Nonnull(javax.annotation.Nonnull)

Aggregations

BaseSyncOptions (com.commercetools.sync.commons.BaseSyncOptions)1 SyncException (com.commercetools.sync.commons.exceptions.SyncException)1 CollectionUtils.collectionToMap (com.commercetools.sync.commons.utils.CollectionUtils.collectionToMap)1 CollectionUtils.emptyIfNull (com.commercetools.sync.commons.utils.CollectionUtils.emptyIfNull)1 CollectionUtils.filterCollection (com.commercetools.sync.commons.utils.CollectionUtils.filterCollection)1 CommonTypeUpdateActionUtils.areResourceIdentifiersEqual (com.commercetools.sync.commons.utils.CommonTypeUpdateActionUtils.areResourceIdentifiersEqual)1 CommonTypeUpdateActionUtils.buildUpdateAction (com.commercetools.sync.commons.utils.CommonTypeUpdateActionUtils.buildUpdateAction)1 CommonTypeUpdateActionUtils.buildUpdateActionForReferences (com.commercetools.sync.commons.utils.CommonTypeUpdateActionUtils.buildUpdateActionForReferences)1 CommonTypeUpdateActionUtils.buildUpdateActions (com.commercetools.sync.commons.utils.CommonTypeUpdateActionUtils.buildUpdateActions)1 FilterUtils.executeSupplierIfPassesFilter (com.commercetools.sync.commons.utils.FilterUtils.executeSupplierIfPassesFilter)1 UnorderedCollectionSyncUtils.buildRemoveUpdateActions (com.commercetools.sync.internals.utils.UnorderedCollectionSyncUtils.buildRemoveUpdateActions)1 ActionGroup (com.commercetools.sync.products.ActionGroup)1 ASSETS (com.commercetools.sync.products.ActionGroup.ASSETS)1 ATTRIBUTES (com.commercetools.sync.products.ActionGroup.ATTRIBUTES)1 IMAGES (com.commercetools.sync.products.ActionGroup.IMAGES)1 PRICES (com.commercetools.sync.products.ActionGroup.PRICES)1 SKU (com.commercetools.sync.products.ActionGroup.SKU)1 AttributeMetaData (com.commercetools.sync.products.AttributeMetaData)1 ProductSyncOptions (com.commercetools.sync.products.ProductSyncOptions)1 SyncFilter (com.commercetools.sync.products.SyncFilter)1