Class ShoppingListReferenceResolutionUtils
- java.lang.Object
-
- com.commercetools.sync.shoppinglists.utils.ShoppingListReferenceResolutionUtils
-
public final class ShoppingListReferenceResolutionUtils extends java.lang.Object
Util class which provides utilities that can be used when syncing shopping lists from a source commercetools project to a target one.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static io.sphere.sdk.shoppinglists.queries.ShoppingListQuery
buildShoppingListQuery()
Builds aShoppingListQuery
for fetching shopping lists from a source CTP project with all the needed references expanded for the sync: Customer Custom Type of the Shopping List Variants of the LineItems Custom Types of the LineItems Custom Types of the TextLineItemsstatic io.sphere.sdk.shoppinglists.ShoppingListDraft
mapToShoppingListDraft(io.sphere.sdk.shoppinglists.ShoppingList shoppingList)
Returns a @link ShoppingListDraft} consisting of the result of applying the mapping fromShoppingList
toShoppingListDraft
with considering reference resolution.static java.util.List<io.sphere.sdk.shoppinglists.ShoppingListDraft>
mapToShoppingListDrafts(java.util.List<io.sphere.sdk.shoppinglists.ShoppingList> shoppingLists)
Returns aList
<ShoppingListDraft
> consisting of the results of applying the mapping fromShoppingList
toShoppingListDraft
with considering reference resolution.
-
-
-
Method Detail
-
mapToShoppingListDrafts
@Nonnull public static java.util.List<io.sphere.sdk.shoppinglists.ShoppingListDraft> mapToShoppingListDrafts(@Nonnull java.util.List<io.sphere.sdk.shoppinglists.ShoppingList> shoppingLists)
Returns aList
<ShoppingListDraft
> consisting of the results of applying the mapping fromShoppingList
toShoppingListDraft
with considering reference resolution.Mapping of Reference fields for the reference resolution Reference field from to customer Reference
<Customer
>ResourceIdentifier
<Customer
>custom.type Reference
<Type
>ResourceIdentifier
<Type
>lineItems.custom.type Set
<Reference
<Type
>>Set
<ResourceIdentifier
<Type
>>textLineItems.custom.type Set
<Reference
<Type
>>Set
<ResourceIdentifier
<Type
>>Note: The aforementioned references should be expanded with a key. Any reference that is not expanded will have its id in place and not replaced by the key will be considered as existing resources on the target commercetools project and the library will issues an update/create API request without reference resolution.
- Parameters:
shoppingLists
- the shopping lists with expanded references.- Returns:
- a
List
ofShoppingListDraft
built from the suppliedList
ofShoppingList
.
-
mapToShoppingListDraft
@Nonnull public static io.sphere.sdk.shoppinglists.ShoppingListDraft mapToShoppingListDraft(@Nonnull io.sphere.sdk.shoppinglists.ShoppingList shoppingList)
Returns a @link ShoppingListDraft} consisting of the result of applying the mapping fromShoppingList
toShoppingListDraft
with considering reference resolution.Mapping of Reference fields for the reference resolution Reference field from to customer Reference
<Customer
>ResourceIdentifier
<Customer
>custom.type Reference
<Type
>ResourceIdentifier
<Type
>lineItems.custom.type Set
<Reference
<Type
>>Set
<ResourceIdentifier
<Type
>>textLineItems.custom.type Set
<Reference
<Type
>>Set
<ResourceIdentifier
<Type
>>Note: The aforementioned references should be expanded with a key. Any reference that is not expanded will have its id in place and not replaced by the key will be considered as existing resources on the target commercetools project and the library will issues an update/create API request without reference resolution.
- Parameters:
shoppingList
- the shopping list with expanded references.- Returns:
- a
ShoppingListDraft
built from the suppliedShoppingList
.
-
buildShoppingListQuery
public static io.sphere.sdk.shoppinglists.queries.ShoppingListQuery buildShoppingListQuery()
Builds aShoppingListQuery
for fetching shopping lists from a source CTP project with all the needed references expanded for the sync:- Customer
- Custom Type of the Shopping List
- Variants of the LineItems
- Custom Types of the LineItems
- Custom Types of the TextLineItems
Note: Please only use this util if you desire to sync all the aforementioned references from a source commercetools project. Otherwise, it is more efficient to build the query without expansions, if they are not needed, to avoid unnecessarily bigger payloads fetched from the source project.
- Returns:
- the query for fetching shopping lists from the source CTP project with all the aforementioned references expanded.
-
-