Skip to content

Commit 0e01950

Browse files
ahmetozahalberkamp
andauthored
#138, #219 Reference resolution improvements. (#551)
Co-authored-by: andreas Halberkamp <andreas.halberkamp@commercetools.de>
1 parent 3bc1386 commit 0e01950

94 files changed

Lines changed: 2590 additions & 2080 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# commercetools sync
33
[![Build Status](https://travis-ci.org/commercetools/commercetools-sync-java.svg?branch=master)](https://travis-ci.org/commercetools/commercetools-sync-java)
44
[![codecov](https://codecov.io/gh/commercetools/commercetools-sync-java/branch/master/graph/badge.svg)](https://codecov.io/gh/commercetools/commercetools-sync-java)
5-
[![Benchmarks 1.9.1](https://img.shields.io/badge/Benchmarks-1.9.1-orange.svg)](https://commercetools.github.io/commercetools-sync-java/benchmarks/)
5+
[![Benchmarks 2.0.0](https://img.shields.io/badge/Benchmarks-2.0.0-orange.svg)](https://commercetools.github.io/commercetools-sync-java/benchmarks/)
66
[![Download](https://api.bintray.com/packages/commercetools/maven/commercetools-sync-java/images/download.svg) ](https://bintray.com/commercetools/maven/commercetools-sync-java/_latestVersion)
7-
[![Javadoc](http://javadoc-badge.appspot.com/com.commercetools/commercetools-sync-java.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/1.9.1/)
7+
[![Javadoc](http://javadoc-badge.appspot.com/com.commercetools/commercetools-sync-java.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/2.0.0/)
88
[![Known Vulnerabilities](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646/badge.svg)](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646)
99

1010
More at https://commercetools.github.io/commercetools-sync-java
@@ -36,7 +36,7 @@ The library supports synchronising the following entities in commercetools
3636
- [Ivy](#ivy)
3737
- [Roadmap](#roadmap)
3838
- [Release Notes](/docs/RELEASE_NOTES.md)
39-
- [Javadoc](https://commercetools.github.io/commercetools-sync-java/v/1.9.1/)
39+
- [Javadoc](https://commercetools.github.io/commercetools-sync-java/v/2.0.0/)
4040
- [Benchmarks](https://commercetools.github.io/commercetools-sync-java/benchmarks/)
4141

4242
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -78,26 +78,26 @@ Here are the most popular ones:
7878
<dependency>
7979
<groupId>com.commercetools</groupId>
8080
<artifactId>commercetools-sync-java</artifactId>
81-
<version>1.9.1</version>
81+
<version>2.0.0</version>
8282
</dependency>
8383
````
8484

8585
#### Gradle
8686

8787
````groovy
88-
implementation 'com.commercetools:commercetools-sync-java:1.9.1'
88+
implementation 'com.commercetools:commercetools-sync-java:2.0.0'
8989
````
9090

9191
#### SBT
9292

9393
````
94-
libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "1.9.1"
94+
libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "2.0.0"
9595
````
9696

9797
#### Ivy
9898

9999
````xml
100-
<dependency org="com.commercetools" name="commercetools-sync-java" rev="1.9.1"/>
100+
<dependency org="com.commercetools" name="commercetools-sync-java" rev="2.0.0"/>
101101
````
102102

103103

docs/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# commercetools sync
33
[![Build Status](https://travis-ci.org/commercetools/commercetools-sync-java.svg?branch=master)](https://travis-ci.org/commercetools/commercetools-sync-java)
44
[![codecov](https://codecov.io/gh/commercetools/commercetools-sync-java/branch/master/graph/badge.svg)](https://codecov.io/gh/commercetools/commercetools-sync-java)
5-
[![Benchmarks 1.9.1](https://img.shields.io/badge/Benchmarks-1.9.1-orange.svg)](https://commercetools.github.io/commercetools-sync-java/benchmarks/)
5+
[![Benchmarks 2.0.0](https://img.shields.io/badge/Benchmarks-2.0.0-orange.svg)](https://commercetools.github.io/commercetools-sync-java/benchmarks/)
66
[![Download](https://api.bintray.com/packages/commercetools/maven/commercetools-sync-java/images/download.svg) ](https://bintray.com/commercetools/maven/commercetools-sync-java/_latestVersion)
7-
[![Javadoc](http://javadoc-badge.appspot.com/com.commercetools/commercetools-sync-java.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/1.9.1/)
7+
[![Javadoc](http://javadoc-badge.appspot.com/com.commercetools/commercetools-sync-java.svg?label=Javadoc)](https://commercetools.github.io/commercetools-sync-java/v/2.0.0/)
88
[![Known Vulnerabilities](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646/badge.svg)](https://snyk.io/test/github/commercetools/commercetools-sync-java/4b2e26113d591bda158217c5dc1cf80a88665646)
99

1010

@@ -55,18 +55,18 @@ Here are the most popular ones:
5555
<dependency>
5656
<groupId>com.commercetools</groupId>
5757
<artifactId>commercetools-sync-java</artifactId>
58-
<version>1.9.1</version>
58+
<version>2.0.0</version>
5959
</dependency>
6060
````
6161
#### Gradle
6262
````groovy
63-
implementation 'com.commercetools:commercetools-sync-java:1.9.1'
63+
implementation 'com.commercetools:commercetools-sync-java:2.0.0'
6464
````
6565
#### SBT
6666
````
67-
libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "1.9.1"
67+
libraryDependencies += "com.commercetools" % "commercetools-sync-java" % "2.0.0"
6868
````
6969
#### Ivy
7070
````xml
71-
<dependency org="com.commercetools" name="commercetools-sync-java" rev="1.9.1"/>
71+
<dependency org="com.commercetools" name="commercetools-sync-java" rev="2.0.0"/>
7272
````

docs/RELEASE_NOTES.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,38 @@
3333
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/2.0.0...2.0.1) |
3434
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/2.0.1/) |
3535
[Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/2.0.1)
36-
-->
36+
37+
-->
3738

38-
<!--### 2.0.0 - Aug 21, 2020
39+
### 2.0.0 - Sept 14, 2020
3940
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/1.9.1...2.0.0) |
4041
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/2.0.0/) |
4142
[Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/2.0.0)
4243

43-
- 🚧 **Breaking Changes** (1)
44-
- **Refactoring of the error- and warning callbacks** - The signatures of the error- and warning callbacks was changed.
45-
From now on the resource draft of the source project, the resource of the target-project and optinally the failed update actions
46-
are passed to the callbacks. [#107](https://github.com/commercetools/commercetools-sync-java/issues/107)
47-
-->
44+
- 🚧 **Breaking Changes** (2)
45+
- Sync options:
46+
- The signatures of the `errorCallback` and `warningCallback` changed and their parameter lists are extended.
47+
From now on the resource draft of the source project, the resource of the target project and optionally the failed update actions
48+
passed to the callbacks. Refer [sync options](./usage/SYNC_OPTIONS.md) for more details. [#107](https://github.com/commercetools/commercetools-sync-java/issues/107)
49+
- Reference resolution utilities:
50+
- **Commons** - Renamed `replaceCustomTypeIdWithKeys` to `mapToCustomFieldsDraft`. [#138](https://github.com/commercetools/commercetools-sync-java/issues/138)
51+
- **Commons** - Renamed `replaceAssetsReferencesIdsWithKeys` to `mapToAssetDrafts`. [#138](https://github.com/commercetools/commercetools-sync-java/issues/138)
52+
- **Category Sync** - Renamed `replaceCategoriesReferenceIdsWithKeys` to `mapToCategoryDrafts`. [#138](https://github.com/commercetools/commercetools-sync-java/issues/138)
53+
- **CartDiscount Sync** - Renamed `replaceCartDiscountsReferenceIdsWithKeys` to `mapToCartDiscountDrafts`. [#138](https://github.com/commercetools/commercetools-sync-java/issues/138)
54+
- **Inventory Sync** - Renamed `replaceInventoriesReferenceIdsWithKeys` to `mapToInventoryEntryDrafts`. [#138](https://github.com/commercetools/commercetools-sync-java/issues/138)
55+
- **Product Sync** - Renamed `replaceProductsReferenceIdsWithKeys` to `mapToProductDrafts`. [#138](https://github.com/commercetools/commercetools-sync-java/issues/138)
56+
- **State Sync** - Renamed `replaceStateReferenceIdsWithKeys` to `mapToStateDrafts`. [#138](https://github.com/commercetools/commercetools-sync-java/issues/138)
57+
- **ProductType Sync** - Renamed `replaceProductTypesReferenceIdsWithKeys` to `mapToProductTypeDrafts`. [#138](https://github.com/commercetools/commercetools-sync-java/issues/138)
58+
59+
-**Enhancements** (1)
60+
- The library will fail fast for the non-existing references that found during the reference resolution. [#219](https://github.com/commercetools/commercetools-sync-java/issues/219)
61+
62+
- 🛠️ **Dependency Updates** (4)
63+
- `commercetools-jvm-sdk` `1.52.0` -> [`1.53.0`](http://commercetools.github.io/commercetools-jvm-sdk/apidocs/io/sphere/sdk/meta/ReleaseNotes.html#v1_53_0)
64+
- `org.assertj.assertj-core` `3.16.0` -> [`3.17.2`](https://assertj.github.io/doc/#assertj-core-3-17-2-release-notes)
65+
- `junit.jupiterApiVersion` `5.6.2` -> [`5.7.0`](https://github.com/junit-team/junit5/releases/tag/r5.7.0)
66+
- `mockito-junit-jupiter` `3.4.4` -> [`3.5.10`](https://github.com/mockito/mockito/releases/tag/v3.5.10)
67+
- `com.github.ben-manes.versions` `0.29.0` -> [`0.33.0`](https://github.com/ben-manes/gradle-versions-plugin/releases/tag/v0.33.0)
4868

4969
### 1.9.1 - Aug 5, 2020
5070
[Commits](https://github.com/commercetools/commercetools-sync-java/compare/1.9.0...1.9.1) |

docs/usage/CART_DISCOUNT_SYNC.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,19 @@ against a [CartDiscountDraft](https://docs.commercetools.com/http-api-projects-c
2828
cart discounts in the target CTP project. Also, the cart discounts in the target project are expected to have the `key`
2929
fields set, otherwise they won't be matched.
3030

31-
2. Every cartDiscount may have a reference to the `Type` of its custom fields. Types are matched by their `key`s.
32-
Therefore, in order for the sync to resolve the actual ids of those references in the target project, the `key` of the
33-
`Type` has to be supplied in the following way:
34-
35-
- Provide the `key` **value** on the `id` field of the reference. This means that calling `getId()` on the
36-
reference should return its `key`.
37-
38-
**Note**: When syncing from a source commercetools project, you can use this util which this library provides:
39-
[`replaceCartDiscountsReferenceIdsWithKeys`](https://commercetools.github.io/commercetools-sync-java/v/1.9.1/com/commercetools/sync/cartdiscounts/utils/CartDiscountReferenceReplacementUtils.html#replaceCartDiscountsReferenceIdsWithKeys-java.util.List-)
40-
that replaces the references id fields with keys, in order to make them ready for reference resolution by the sync:
31+
2. Every cartDiscount may have a reference to the `Type` of its custom fields.
32+
Types are matched by their `key`s. Therefore, in order for the sync to resolve the
33+
actual ids of the type reference, the `key` of the `Type` has to be supplied.
34+
35+
- When syncing from a source commercetools project, you can use [`mapToCartDiscountDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.0.0/com/commercetools/sync/cartdiscounts/utils/CartDiscountReferenceResolutionUtils.html#mapToCartDiscountDrafts-java.util.List-)
36+
method that maps from a `CartDiscount` to `CartDiscountDraft` in order to make them ready for reference resolution by the sync:
4137
````java
42-
// Puts the keys in the reference id fields to prepare for reference resolution
43-
final List<CartDiscountDraft> cartDiscountDrafts = replaceCartDiscountsReferenceIdsWithKeys(cartDiscounts);
38+
final List<CartDiscountDraft> cartDiscountDrafts = CartDiscountReferenceResolutionUtils.mapToCartDiscountDrafts(cartDiscounts);
4439
````
4540

4641
3. Create a `sphereClient` [as described here](IMPORTANT_USAGE_TIPS.md#sphereclient-creation).
4742

48-
4. After the `sphereClient` is set up, a `CartDiscountSyncOptions` should be be built as follows:
43+
4. After the `sphereClient` is set up, a `CartDiscountSyncOptions` should be built as follows:
4944
````java
5045
// instantiating a CartDiscountSyncOptions
5146
final CartDiscountSyncOptions cartDiscountSyncOptions = CartDiscountSyncOptionsBuilder.of(sphereClient).build();

docs/usage/CATEGORY_SYNC.md

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,16 @@ against a [CategoryDraft](https://docs.commercetools.com/http-api-projects-categ
3030
categories in the target CTP project. Also, the categories in the target project are expected to have the `key` fields set,
3131
otherwise they won't be matched.
3232

33-
2. Every category may have a reference to a `parent category` and a reference to the `Type` of its custom fields. Categories
34-
and Types are matched by their `key`s. Therefore, in order for the sync to resolve the
35-
actual ids of those references, the `key` of the `Type`/parent `Category` has to be supplied in the following way:
36-
- Provide the `key` value on the `id` field of the reference. This means that calling `getId()` on the
37-
reference would return its `key`.
38-
39-
**Note**: When syncing from a source commercetools project, you can use this util which this library provides:
40-
[`replaceCategoriesReferenceIdsWithKeys`](https://commercetools.github.io/commercetools-sync-java/v/1.9.1/com/commercetools/sync/categories/utils/CategoryReferenceReplacementUtils.html#replaceCategoriesReferenceIdsWithKeys-java.util.List-)
41-
that replaces the references id fields with keys, in order to make them ready for reference resolution by the sync:
42-
````java
43-
// Puts the keys in the reference id fields to prepare for reference resolution
44-
final List<CategoryDraft> categoryDrafts = replaceCategoriesReferenceIdsWithKeys(categories);
45-
````
46-
47-
Example of its usage can be found [here](https://github.com/commercetools/commercetools-sync-java/tree/master/src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/categories/CategorySyncIT.java#L130).
48-
33+
2. Every category may have a reference to a `parent category` and a reference to the `Type` of its custom fields.
34+
These references are matched by their `key`s. Therefore, in order for the sync to resolve the
35+
actual ids of the references, their `key`s has to be supplied.
36+
37+
- When syncing from a source commercetools project, you can use [`mapToCategoryDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.0.0/com/commercetools/sync/categories/utils/CategoryReferenceResolutionUtils.html#mapToCategoryDrafts-java.util.List-)
38+
method that maps from a `Category` to `CategoryDraft` in order to make them ready for reference resolution by the sync:
39+
````java
40+
final List<CategoryDraft> categoryDrafts = CategoryReferenceResolutionUtils.mapToCategoryDrafts(categories);
41+
````
42+
4943
3. Create a `sphereClient` [as described here](IMPORTANT_USAGE_TIPS.md#sphereclient-creation).
5044

5145
4. After the `sphereClient` is set up, a `CategorySyncOptions` should be built as follows:

docs/usage/IMPORTANT_USAGE_TIPS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ productSync.sync(batch1)
3131
By design, scaling the sync process should **not** be done by executing the batches themselves in parallel. However, it can be done either by:
3232

3333
- Changing the number of [max parallel requests](https://github.com/commercetools/commercetools-sync-java/tree/master/src/main/java/com/commercetools/sync/commons/utils/ClientConfigurationUtils.java#L116) within the `sphereClient` configuration. It defines how many requests the client can execute in parallel.
34-
- or changing the draft [batch size](https://commercetools.github.io/commercetools-sync-java/v/1.9.1/com/commercetools/sync/commons/BaseSyncOptionsBuilder.html#batchSize-int-). It defines how many drafts can one batch contain.
34+
- or changing the draft [batch size](https://commercetools.github.io/commercetools-sync-java/v/2.0.0/com/commercetools/sync/commons/BaseSyncOptionsBuilder.html#batchSize-int-). It defines how many drafts can one batch contain.
3535

3636
The current overridable default [configuration](https://github.com/commercetools/commercetools-sync-java/tree/master/src/main/java/com/commercetools/sync/commons/utils/ClientConfigurationUtils.java#L45) of the `sphereClient`
3737
is the recommended good balance for stability and performance for the sync process.

docs/usage/INVENTORY_SYNC.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,17 @@ against a [InventoryEntryDraft](https://docs.commercetools.com/http-api-projects
3030

3131
2. Every inventory entry may have a reference to a supply `Channel` and a reference to the `Type` of its custom fields. These
3232
references are matched by their `key`s. Therefore, in order for the sync to resolve the actual ids of those references,
33-
their `key`s has to be supplied in the following way:
34-
- Provide the `key` value on the `id` field of the reference. This means that calling `getId()` on the
35-
reference would return its `key`.
36-
37-
**Note**: When syncing from a source commercetools project, you can use this util which this library provides:
38-
[`replaceInventoriesReferenceIdsWithKeys`](https://commercetools.github.io/commercetools-sync-java/v/1.9.1/com/commercetools/sync/inventories/utils/InventoryReferenceReplacementUtils.html#replaceInventoriesReferenceIdsWithKeys-java.util.List-)
39-
that replaces the references id fields with keys, in order to make them ready for reference resolution by the sync:
40-
````java
41-
// Puts the keys in the reference id fields to prepare for reference resolution
42-
final List<InventoryEntryDraft> inventoryEntryDrafts = replaceInventoriesReferenceIdsWithKeys(inventoryEntries);
43-
````
33+
their `key`s has to be supplied.
34+
35+
- When syncing from a source commercetools project, you can use [`mapToInventoryEntryDrafts`](https://commercetools.github.io/commercetools-sync-java/v/2.0.0/com/commercetools/sync/inventories/utils/InventoryReferenceResolutionUtils.html#mapToInventoryEntryDrafts-java.util.List-)
36+
method that that maps from a `InventoryEntry` to `InventoryEntryDraft` in order to make them ready for reference resolution by the sync:
37+
````java
38+
final List<InventoryEntryDraft> inventoryEntryDrafts = InventoryReferenceResolutionUtils.mapToInventoryEntryDrafts(inventoryEntries);
39+
````
4440

4541
3. Create a `sphereClient` [as described here](IMPORTANT_USAGE_TIPS.md#sphereclient-creation).
4642

47-
4. After the `sphereClient` is setup, a `InventorySyncOptions` should be be built as follows:
43+
4. After the `sphereClient` is setup, a `InventorySyncOptions` should be built as follows:
4844
````java
4945
// instantiating a InventorySyncOptions
5046
final InventorySyncOptions inventorySyncOptions = InventorySyncOptionsBuilder.of(sphereClient).build();

0 commit comments

Comments
 (0)