Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#300 - Type Sync Feature. #333

Merged
merged 181 commits into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
181 commits
Select commit Hold shift + click to select a range
0dcb394
#300: Adds implementations for the type sync.
ahmetoz Sep 13, 2018
aedf087
#300: fix checkStyles
ahmetoz Sep 13, 2018
878c733
#300: add integration test for type sync utilities.
ahmetoz Sep 18, 2018
7b129fd
#300: add unit and integration tests for the type sync feature.
ahmetoz Sep 19, 2018
f6e2bc7
#300: suppress warning coming from findBugs
ahmetoz Sep 20, 2018
c2bb617
#300: documentation and benchmark for type sync.
ahmetoz Sep 21, 2018
5d1fc58
#300: add constant to type sync benchmark util
ahmetoz Sep 24, 2018
62923b5
#300: fix checkstyleBenchmark
ahmetoz Sep 24, 2018
73cb3af
Merge branch 'master' into 300-feature-type-sync
ahmetoz Sep 24, 2018
973cb09
#300: updates releases notes.
ahmetoz Sep 24, 2018
f4fc415
#300: PR review changes, mostly documentation and indentions.
ahmetoz Sep 25, 2018
2ddf05b
#300: PR changes
ahmetoz Sep 26, 2018
6f14845
#300 - update type sync docs.
ahmetoz Oct 5, 2018
9801dbd
#300 - update type sync java docs and change some indention.
ahmetoz Oct 5, 2018
de42db0
#300 - update type sync java doc.
ahmetoz Oct 5, 2018
5a357ce
#300 - typo
ahmetoz Oct 5, 2018
18970e9
#300 - add comment for updating field definition's type
ahmetoz Oct 5, 2018
338b833
Merge branches '300-feature-type-sync' and 'master' of https://github…
ahmetoz Oct 8, 2018
079b1df
#300 - change order
ahmetoz Oct 8, 2018
f7a4c76
#300 - refactor with using filterEmptyOptionals util
ahmetoz Oct 8, 2018
850246d
#300 - refactor, do not block error callback
ahmetoz Oct 8, 2018
4807bf5
#300 - refactor, comment
ahmetoz Oct 8, 2018
c6b88d1
#300 - checkStyle fix
ahmetoz Oct 8, 2018
2dc8da9
#300 - adds tests for TypeServiceImpl
ahmetoz Oct 8, 2018
1d882cb
#300 - refactor tests.
ahmetoz Oct 8, 2018
8f45ac2
#300 - fix some typos and grammar in type document.
ahmetoz Oct 9, 2018
4f5a08e
#300 - Review changes.
ahmetoz Oct 15, 2018
19a5800
#300 - Review changes for benchmark.
ahmetoz Oct 15, 2018
026071b
#301 - update release notes for type sync
ahmetoz Oct 15, 2018
f448662
#301 - fix import.
ahmetoz Oct 15, 2018
416c974
Merge branches '300-feature-type-sync' and 'master' of https://github…
ahmetoz Oct 15, 2018
bf6aa7a
Merge branch 'master' into 300-feature-type-sync
ahmetoz Oct 16, 2018
3913290
#300 - remove uuid flag from type sync options
ahmetoz Oct 16, 2018
7b35d79
Merge branch '300-feature-type-sync' of https://github.com/commerceto…
ahmetoz Oct 18, 2018
256554e
#300- refactor type service and add test.
ahmetoz Oct 18, 2018
8f1362f
#300- refactor docs
ahmetoz Oct 18, 2018
cb2dabd
#300- refactor make internal
ahmetoz Oct 18, 2018
8879163
#300- update release notes - add benchmark test as an enhancement entity
ahmetoz Oct 18, 2018
d608fea
#300 - check controls for the field type on update actions
ahmetoz Oct 18, 2018
ea28dfb
#300 - fix checkStyle
ahmetoz Oct 18, 2018
ac55840
#300 - fix IT.
ahmetoz Oct 18, 2018
c0792c1
Merge branch '302-refactor-product-type' into 300-refactor-type-and-p…
ahmetoz Oct 18, 2018
27ef3db
#318, #300 - refactoring the enum value usages.
ahmetoz Oct 22, 2018
2dccbf0
Merge branch 'master' of https://github.com/commercetools/commercetoo…
ahmetoz Nov 8, 2018
33b3039
#300 - refactor, move enum update actions on buildActions to buildEnu…
ahmetoz Nov 8, 2018
11a32b1
#300 - make field definition build actions internal
ahmetoz Nov 9, 2018
251be4b
#300 - revert changes on fetchMatchingTypesByKeys.
ahmetoz Nov 9, 2018
dee188b
#300 - filter null values on buildFieldDefinitionsUpdateActions
ahmetoz Nov 9, 2018
4cea407
#300 - refactor to use static helpers on collections
ahmetoz Nov 11, 2018
03d1832
#300 - fix test
ahmetoz Nov 11, 2018
84f4e6b
#300 - move commons.utils.enums package to commons.utils package
ahmetoz Nov 11, 2018
9e7aefa
#300 - cme (without max retry handler )
ahmetoz Nov 13, 2018
a18a997
Merge branches '300-refactor-type-and-product-type-together' and 'mas…
ahmetoz Nov 13, 2018
c9cf9c9
#300 - fix check style errors
ahmetoz Nov 13, 2018
7934050
#300 - remove method, use simple map function, it is not required to …
ahmetoz Nov 13, 2018
7b6cf52
#300 - update release notes for type changes
ahmetoz Nov 23, 2018
7cf453a
#300 - add retry fetch test case
ahmetoz Nov 23, 2018
40ab163
Merge branch 'master' into 300-refactor-type-and-product-type-together
ahmetoz Nov 23, 2018
5f09521
#300 - refactor, use syncBatches from BaseSync
ahmetoz Nov 23, 2018
a787872
#300 - update README.md for type.
ahmetoz Nov 26, 2018
fbb2d52
#300 - update type sync caveats
ahmetoz Nov 26, 2018
76c5a44
#300 - rename method name cacheAndFetch to fetchAndCache with correct…
ahmetoz Nov 26, 2018
0c449e0
#300 - refactor TypeService using BaseService.
ahmetoz Nov 26, 2018
eed7055
#300 - update caveats for removing localized enum values.
ahmetoz Nov 26, 2018
08fae3c
#300 - remove unnecessary comments.
ahmetoz Nov 26, 2018
cdb6d17
#300 - update product type caveats - set type
ahmetoz Nov 26, 2018
cb0f24e
#300 - update and add todo's in java docs for missing update actions.
ahmetoz Nov 26, 2018
3151401
#300 - refactor Type IT packages
ahmetoz Nov 26, 2018
72293e4
#300 - update getCause wrapper on test, this change occurred because …
ahmetoz Nov 26, 2018
65314d1
#300 grammar fix
heshamMassoud Nov 26, 2018
ccd2a3f
Update docs/usage/TYPE_SYNC.md
lojzatran Nov 28, 2018
18d52d8
Update src/test/java/com/commercetools/sync/types/utils/typeactionuti…
lojzatran Nov 28, 2018
9f34e58
Update src/test/java/com/commercetools/sync/types/utils/typeactionuti…
lojzatran Nov 28, 2018
a98d0e9
Update src/test/java/com/commercetools/sync/types/utils/typeactionuti…
lojzatran Nov 28, 2018
1d7a357
Update src/main/java/com/commercetools/sync/types/utils/FieldDefiniti…
lojzatran Nov 28, 2018
6c40713
Update src/main/java/com/commercetools/sync/producttypes/utils/Attrib…
lojzatran Nov 28, 2018
fd5e63c
#300 - close brackets in java docs
ahmetoz Nov 28, 2018
f7b3fde
#300 - update throws java doc for buildRemoveFieldDefinitionOrFieldDe…
ahmetoz Nov 28, 2018
02a5fff
#300 - update java docs for buildActions for enumValues.
ahmetoz Nov 28, 2018
8a0fdfc
Merge branch '300-refactor-type-and-product-type-together' of https:/…
ahmetoz Nov 28, 2018
de9b450
Merge branch 'master' into 300-refactor-type-and-product-type-together
ahmetoz Nov 28, 2018
1fb755d
Merge branches '300-refactor-type-and-product-type-together' and 'mas…
ahmetoz Dec 4, 2018
5b74a01
#300 fix java doc
ahmetoz Dec 4, 2018
a6c5536
#300 handle fetchMatchingTypesByKeys using CtpQueryUtils.
ahmetoz Dec 4, 2018
7311535
#300 handle failed fetch exception in type sync.
ahmetoz Dec 4, 2018
af1cb49
#300 remove redundant return
ahmetoz Dec 4, 2018
b5a1a70
#300 add unit test for type failed fetch scenario
ahmetoz Dec 4, 2018
eb9e216
#300 update type sync documentation
ahmetoz Dec 4, 2018
de9c4ee
#300 add ctpprojectsource IT for type resource.
ahmetoz Dec 4, 2018
fb16164
#300 refactor type ITs.
ahmetoz Dec 4, 2018
60963f9
#300 documentation empty char fix.
heshamMassoud Dec 4, 2018
fef7fef
#300 fix order
heshamMassoud Dec 4, 2018
778eb3e
#300 add type doc to docs/readme..
ahmetoz Dec 4, 2018
f3e95f3
#300 update grammar for type caveats and add issue link for settype.
ahmetoz Dec 4, 2018
e2d9cd8
#300 add type sync to documentation.
ahmetoz Dec 4, 2018
6d86832
#300 fix checkstyle error.
ahmetoz Dec 4, 2018
64235a3
#300: Fix links.
heshamMassoud Dec 5, 2018
ba4340f
#300: Remove unneeded link.
heshamMassoud Dec 5, 2018
ba93530
#300: Remove comma in the end.
heshamMassoud Dec 5, 2018
c52f909
#300: Add missing article.
heshamMassoud Dec 5, 2018
6ee9d00
#300 fix wrong resource in javadoc
heshamMassoud Dec 5, 2018
3a4cd16
#300 update java doc
heshamMassoud Dec 5, 2018
e565aac
#300 fix grammar in javadoc
heshamMassoud Dec 5, 2018
f23ebfb
#300 fix grammar in javadoc
heshamMassoud Dec 5, 2018
8a5dd4d
#300 make `TypeSync` constructor protected
ahmetoz Dec 5, 2018
1f7c285
#300 revert product type doc, fix some changes from merge conflict.
ahmetoz Dec 5, 2018
86d2a26
Merge branch '300-refactor-type-and-product-type-together' into 300-u…
heshamMassoud Dec 5, 2018
8b0a195
#300: Fix caveat in Type sync doc and add same caveat in productType …
heshamMassoud Dec 5, 2018
db311a6
#300: Remove extra space.
heshamMassoud Dec 5, 2018
f7b45c2
Merge pull request #348 from commercetools/300-update-documentation-f…
heshamMassoud Dec 5, 2018
226b165
#300: Remove potentially in Javadoc.
heshamMassoud Dec 5, 2018
98ec540
#300: Remove shadowed fields in TypeService.
heshamMassoud Dec 5, 2018
a50052e
#300: Formatting.
heshamMassoud Dec 5, 2018
4208b33
#300 add static import for AssertionsForStatistics
ahmetoz Dec 5, 2018
d237b07
#300 remove populateSourceProject because it's not needed.
ahmetoz Dec 5, 2018
5843e50
#300 remove confusing commented out code from assertFieldDefinitionsA…
ahmetoz Dec 5, 2018
0be0a76
#300 remove confusing **potentially** injected from java docs.
ahmetoz Dec 5, 2018
6242598
#300 do not shadow BaseService
ahmetoz Dec 5, 2018
0bd9b5b
Merge branches '300-refactor-type-and-product-type-together' and 'mas…
ahmetoz Dec 5, 2018
4c2f436
#300 update type service to fix compile errors
ahmetoz Dec 5, 2018
f59ebb7
#300 remove constructor
ahmetoz Dec 5, 2018
dd9d5cb
#300 refactor fetchCachedTypeId
ahmetoz Dec 5, 2018
76bb31b
#300 refactor fetchMatchingTypesByKeys and fix ignored test
ahmetoz Dec 5, 2018
d4c77c8
Merge branches '300-refactor-type-and-product-type-together' and '300…
ahmetoz Dec 5, 2018
8ce297f
#300 update type sync and type services
ahmetoz Dec 5, 2018
ff6d6f7
#300 fix benchmarks for type and product type
ahmetoz Dec 5, 2018
25f9a5f
#300: Remove empty space.
heshamMassoud Dec 5, 2018
76e4473
#300: Statically import assertion utils.
heshamMassoud Dec 5, 2018
ddf7e89
#300: Remove release notes for non exposed methods.
heshamMassoud Dec 5, 2018
291c5dc
#300: Reword release note entries.
heshamMassoud Dec 5, 2018
c87687b
#300: Fix bug in calculating diff of avg in benchmarks.
heshamMassoud Dec 5, 2018
1dd8d7e
#300: Delete types only from target.
heshamMassoud Dec 5, 2018
d29bfcd
#300: Making unneeded public fields private.
heshamMassoud Dec 5, 2018
c13e21a
#300: Adjust line spacing.
heshamMassoud Dec 5, 2018
903c0ca
#300: Use simpler name update.
heshamMassoud Dec 5, 2018
7efd69d
#300: Fix Javadoc.
heshamMassoud Dec 5, 2018
9fdb665
#300: Fix line spacing.
heshamMassoud Dec 5, 2018
f7f8cc1
#300: Fix Javadoc.
heshamMassoud Dec 5, 2018
9d66f49
#300: Remove braces for 1-liner.
heshamMassoud Dec 5, 2018
1154d69
#300: Use optional assertion.
heshamMassoud Dec 5, 2018
32d00af
#300: Remove unneeded variable reassignment.
heshamMassoud Dec 5, 2018
7fe0b60
#300: Move method and remove key check since it's required by CTP.
heshamMassoud Dec 5, 2018
28ed07a
#300: Remove unneeded variable and format method sig.
heshamMassoud Dec 5, 2018
94e9019
#300: Fix method names.
heshamMassoud Dec 5, 2018
f5895cd
#300: Statically import, improve indentation and remove unneeded asse…
heshamMassoud Dec 5, 2018
98c7b50
#300: Fix typos.
heshamMassoud Dec 5, 2018
f5da17e
#300: Remove redundant supressions.
heshamMassoud Dec 6, 2018
7d77067
#300: Add @nonnull annotation.
heshamMassoud Dec 6, 2018
694042f
#300: Statically import util.
heshamMassoud Dec 6, 2018
9057af9
#300: Remove excessive line spacing.
heshamMassoud Dec 6, 2018
a08da1f
#300: Refactor TypeSyncUtils.
heshamMassoud Dec 6, 2018
f9d086f
#300: Refactor util name.
heshamMassoud Dec 6, 2018
cfc1582
#300: Fix Javadoc.
heshamMassoud Dec 6, 2018
577a850
#300: Fix indentation.
heshamMassoud Dec 6, 2018
fd5cff6
#300: Fix Javadoc.
heshamMassoud Dec 6, 2018
85dab40
#300: Add note about FieldType and AttributeType changes.
heshamMassoud Dec 6, 2018
bd01fdb
#300: Add a test case for a new draft with different order.
heshamMassoud Dec 6, 2018
2128a66
#300: Remove unneeded asserts.
heshamMassoud Dec 6, 2018
658a005
#300: Add a unit test with a definition with a null name.
heshamMassoud Dec 6, 2018
d3f8dd8
#300: Fix unit test names.
heshamMassoud Dec 6, 2018
db1835e
#300: Add unit test for fieldDefinition with null FieldType.
heshamMassoud Dec 6, 2018
dcb95f4
#300: Unexpose enum differs.
heshamMassoud Dec 6, 2018
b5bfa67
#300: Fix Javadocs.
heshamMassoud Dec 6, 2018
bbaab01
#300: Add more readable line spacing.
heshamMassoud Dec 6, 2018
a87995d
#300: Move tests to accessible package.
heshamMassoud Dec 6, 2018
5bbf06d
#300: Unexpose generic enum differ.
heshamMassoud Dec 6, 2018
2459b38
#300: Remove redundant empty check.
heshamMassoud Dec 6, 2018
f6e34d2
#300: Replace singleton lists with optionals.
heshamMassoud Dec 6, 2018
4ab3f1d
#300: Change test names.
heshamMassoud Dec 6, 2018
f84764f
#300: Fix unit tests.
heshamMassoud Dec 6, 2018
a4ecf2d
#300: Use query builder.
heshamMassoud Dec 6, 2018
0c1e47f
#300: Fix Javadocs.
heshamMassoud Dec 6, 2018
24dca2c
#300: Change fixtures class name, package and contents.
heshamMassoud Dec 6, 2018
7f6912c
#300: Avoid star import for FieldDefinitionFixtures.
heshamMassoud Dec 6, 2018
9c96839
#300: Add unit tests for mixed cases.
heshamMassoud Dec 6, 2018
b7d4e54
#300: Move fixtures into fixtures class.
heshamMassoud Dec 6, 2018
767825f
#300: Remove unneeded field definitions from test.
heshamMassoud Dec 6, 2018
98abc39
#300: Reword notes.
heshamMassoud Dec 6, 2018
7d20528
#300 fix checksStyles
ahmetoz Dec 6, 2018
edf0981
#300: Fix Checkstyle issues.
heshamMassoud Dec 6, 2018
5377ce7
Merge pull request #349 from commercetools/300-type-sync-review
heshamMassoud Dec 6, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Currently this library supports synchronising the following entities in commerce
- [Products](/docs/usage/PRODUCT_SYNC.md)
- [InventoryEntries](/docs/usage/INVENTORY_SYNC.md)
- [ProductTypes](/docs/usage/PRODUCT_TYPE_SYNC.md)
- [Types](/docs/usage/TYPE_SYNC.md)

![commercetools-java-sync-final 001](https://user-images.githubusercontent.com/9512131/31230702-0f2255a6-a9e5-11e7-9412-04ed52641dde.png)
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
Expand Down
7 changes: 5 additions & 2 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
</module>
<module name="AvoidStarImport">
heshamMassoud marked this conversation as resolved.
Show resolved Hide resolved
<property name="excludes" value="com.commercetools.sync.products.utils.productvariantupdateactionutils.prices.PriceDraftFixtures,
com.commercetools.sync.products.utils.productvariantupdateactionutils.prices.PriceFixtures"/>
com.commercetools.sync.products.utils.productvariantupdateactionutils.prices.PriceFixtures,
com.commercetools.sync.commons.utils.LocalizedEnumValueFixtures,
com.commercetools.sync.commons.utils.PlainEnumValueFixtures,
com.commercetools.sync.types.utils.FieldDefinitionFixtures"/>
<property name="allowClassImports" value="false"/>
<property name="allowStaticMemberImports" value="false"/>
</module>
Expand Down Expand Up @@ -206,4 +209,4 @@
<property name="ignorePrimitiveTypes" value="true"/>
</module>
</module>
</module>
</module>
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Currently this library supports synchronising the following entities in commerce
- [Products](usage/PRODUCT_SYNC.md)
- [InventoryEntries](usage/INVENTORY_SYNC.md)
- [ProductTypes](usage/PRODUCT_TYPE_SYNC.md)
- [Types](usage/TYPE_SYNC.md)

![commercetools-java-sync-final 001](https://user-images.githubusercontent.com/9512131/31230702-0f2255a6-a9e5-11e7-9412-04ed52641dde.png)

Expand Down
12 changes: 8 additions & 4 deletions docs/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,28 @@
[Javadoc](https://commercetools.github.io/commercetools-sync-java/v/v1.0.0-M15/) |
[Jar](https://bintray.com/commercetools/maven/commercetools-sync-java/v1.0.0-M15)

- 🎉 **New Features** (1)
- 🎉 **New Features** (9)
- **Commons** - Added `OptionalUtils#filterEmptyOptionals` which are utility methods that filter out the
empty optionals in a supplied list (with a varargs variation) returning a list of the contents of the non-empty
optionals. [#255](https://github.com/commercetools/commercetools-sync-java/issues/255)
- **Type Sync** - Support for syncing types. [#300](https://github.com/commercetools/commercetools-sync-java/issues/300) For more info how to use it please refer to [Type usage doc](/docs/usage/TYPE_SYNC.md).
- **Type Sync** - Exposed `TypeSyncUtils#buildActions` which calculates all needed update actions after comparing a `Type` and a `TypeDraft`. [#300](https://github.com/commercetools/commercetools-sync-java/issues/300)
- **Type Sync** - Exposed `TypeUpdateActionUtils` which contains utils for calculating needed update actions after comparing individual fields of a `Type` and a `TypeDraft`. [#300](https://github.com/commercetools/commercetools-sync-java/issues/300)

- 📋 **Documentation** (4)
- **Commons** - Added the documentation github pages. https://commercetools.github.io/commercetools-sync-java
- **Commons** - Added a [Quick Start Guide](/docs/usage/QUICK_START.md) for a convinient entry into the library.
- **Commons** - Moved documentation of sync options to a separate [doc](/docs/usage/SYNC_OPTIONS.md).
- **Commons** - Added a the earliest compatible version of the commercetools-jvm-sdk](https://github.com/commercetools/commercetools-jvm-sdk) as a prerequisite for using the library.

- 🛠️ **Enhancements** (16)
- 🛠️ **Enhancements** (17)
- **ProductType Sync** - Added concurrency modification exception handling. [#325](https://github.com/commercetools/commercetools-sync-java/issues/325)
- **Commons** - `ProductSyncUtils#buildActions`, `CategorySyncUtils#buildActions`, `InventorySyncUtils#buildActions` and `ProductTypeSyncUtils#buildActions` now don't apply the `beforeUpdateCallback` implicitly.
If you want, you can apply it explicitly on the result of the `..#buildActions` method. [#302](https://github.com/commercetools/commercetools-sync-java/issues/302)
- **Product Sync** - Reference keys are not validated if they are in UUID format anymore. [#166](https://github.com/commercetools/commercetools-sync-java/issues/166)
- **Category Sync** - Reference keys are not validated if they are in UUID format anymore. [#166](https://github.com/commercetools/commercetools-sync-java/issues/166)
- **Inventory Sync** - Reference keys are not validated if they are in UUID format anymore. [#166](https://github.com/commercetools/commercetools-sync-java/issues/166)
- **ProductType Sync** - Added `ProductTypeSyncBenchmark` to benchmark the product type sync, to be able to compare the performance of the sync with the future releases. [#301](https://github.com/commercetools/commercetools-sync-java/issues/301)
- **ProductType Sync** - Added benchmarks for the `productType` sync to be able to compare the performance of the sync with the future releases. [#301](https://github.com/commercetools/commercetools-sync-java/issues/301)
- **Commons** - Bumped commercetools-jvm-sdk to version [1.37.0](http://commercetools.github.io/commercetools-jvm-sdk/apidocs/io/sphere/sdk/meta/ReleaseNotes.html#v1_37_0).
- **Commons** - Bumped `mockito` to 2.23.4.
- **Commons** - Bumped `com.adarshr.test-logger` to 1.6.0.
Expand All @@ -63,7 +66,8 @@
- **Commons** - Bumped `com.adarshr.test-logger` to 1.6.0.
- **Commons** - Bumped `org.ajoberstar.grgit` to 3.0.0.
- **Commons** - Bumped gradle to version [gradle-5.0](https://docs.gradle.org/5.0/release-notes.html)

- **Type Sync** - Added benchmarks for the `type` sync to be able to compare the performance of the sync with the future releases. [#300](https://github.com/commercetools/commercetools-sync-java/issues/300)

- 🚧 **Breaking Changes** (11)
- **Product Sync** - `allowUuid` option is now removed. [#166](https://github.com/commercetools/commercetools-sync-java/issues/166)
- **Category Sync** - `allowUuid` option is now removed. [#166](https://github.com/commercetools/commercetools-sync-java/issues/166)
Expand Down
19 changes: 16 additions & 3 deletions docs/usage/PRODUCT_TYPE_SYNC.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ against a [ProductTypeDraft](https://docs.commercetools.com/http-api-projects-pr
- [Sync list of product type drafts](#sync-list-of-product-type-drafts)
- [Prerequisites](#prerequisites)
- [Running the sync](#running-the-sync)
- [Important to Note](#important-to-note)
- [More examples of how to use the sync](#more-examples-of-how-to-use-the-sync)
- [Build all update actions](#build-all-update-actions)
- [Build particular update action(s)](#build-particular-update-actions)
- [Caveats](#caveats)
Expand All @@ -26,8 +28,8 @@ against a [ProductTypeDraft](https://docs.commercetools.com/http-api-projects-pr

#### Prerequisites

1. The sync expects a list of `ProductTypeDrafts`s that have their `key` fields set to be matched with
product types in the target CTP project. Also, the product types in the target project are expected to have the `key`
1. The sync expects a list of `ProductTypeDraft`s that have their `key` fields set to be matched with
product types in the target CTP project. Also, the product types in the target project are expected to have the `key`
fields set, otherwise they won't be matched.

2. Create a `sphereClient` [as described here](IMPORTANT_USAGE_TIPS.md#sphereclient-creation).
Expand Down Expand Up @@ -64,8 +66,18 @@ __Note__ The statistics object contains the processing time of the last batch on

1. The sync processing time should not take into account the time between supplying batches to the sync.
2. It is not known by the sync which batch is going to be the last one supplied.

#### Important to Note

1. If two matching `attributeDefinition`s (old and new) on the matching `productType`s (old and new) have a different `AttributeType`, the sync will
**remove** the existing `attributeDefinition` and then **add** a new `attributeDefinition` with the new `AttributeType`.

More examples of how to use the sync can be found [here](https://github.com/commercetools/commercetools-sync-java/tree/master/src/integration-test/java/com/commercetools/sync/integration/producttypes/ProductTypeSyncIT.java).
2. The `attributeDefinition` for which the `AttributeType` is not defined (`null`) will not be synced.

#### More examples of how to use the sync

1. [Sync from another CTP project as a source](https://github.com/commercetools/commercetools-sync-java/tree/master/src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/producttypes/ProductTypeSyncIT.java).
2. [Sync from an external source](https://github.com/commercetools/commercetools-sync-java/tree/master/src/integration-test/java/com/commercetools/sync/integration/externalsource/producttypes/ProductTypeSyncIT.java).

*Make sure to read the [Important Usage Tips](IMPORTANT_USAGE_TIPS.md) for optimal performance.*

Expand All @@ -88,3 +100,4 @@ More examples of those utils for different fields can be found [here](https://gi

## Caveats
1. Syncing product types with an attribute of type [NestedType](https://docs.commercetools.com/http-api-projects-productTypes.html#nestedtype) is not supported yet.
2. Currently the sync would handle changes to Enum or LocalizedEnum Types but not [Set](https://docs.commercetools.com/http-api-projects-types.html#settype) of either. [#313](https://github.com/commercetools/commercetools-sync-java/issues/313)
3 changes: 2 additions & 1 deletion docs/usage/QUICK_START.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ implementation 'com.commercetools:commercetools-sync-java:v1.0.0-M14'

#### More Details
*[Product Sync](PRODUCT_SYNC.md), [ProductType Sync](PRODUCT_TYPE_SYNC.md),
[Category Sync](CATEGORY_SYNC.md), [Inventory Sync](INVENTORY_SYNC.md)*
[Category Sync](CATEGORY_SYNC.md), [Inventory Sync](INVENTORY_SYNC.md),
[Type Sync](TYPE_SYNC.md)*
101 changes: 101 additions & 0 deletions docs/usage/TYPE_SYNC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Type Sync

Module used for importing/syncing Types into a commercetools project.
It also provides utilities for generating update actions based on the comparison of a [Type](https://docs.commercetools.com/http-api-projects-types.html#type)
against a [TypeDraft](https://docs.commercetools.com/http-api-projects-types.html#typedraft).

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Usage](#usage)
- [Sync list of type drafts](#sync-list-of-type-drafts)
- [Prerequisites](#prerequisites)
- [Running the sync](#running-the-sync)
- [Important to Note](#important-to-note)
- [More examples of how to use the sync](#more-examples-of-how-to-use-the-sync)
- [Build all update actions](#build-all-update-actions)
- [Build particular update action(s)](#build-particular-update-actions)
- [Caveats](#caveats)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Usage

### Sync list of type drafts

#### Prerequisites
1. The sync expects a list of `TypeDraft`s that have their `key` fields set to be matched with
types in the target CTP project. Also, the types in the target project are expected to have the `key`
fields set, otherwise they won't be matched.

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

3. After the `sphereClient` is set up, a `TypeSyncOptions` should be be built as follows:
````java
// instantiating a TypeSyncOptions
final TypeSyncOptions typeSyncOptions = TypeSyncOptionsBuilder.of(sphereClient).build();
````

[More information about Sync Options](SYNC_OPTIONS.md).

#### Running the sync
After all the aforementioned points in the previous section have been fulfilled, to run the sync:
````java
// instantiating a type sync
final TypeSync typeSync = new TypeSync(typeSyncOptions);

// execute the sync on your list of types
CompletionStage<TypeSyncStatistics> syncStatisticsStage = typeSync.sync(typeDrafts);
````
The result of the completing the `syncStatisticsStage` in the previous code snippet contains a `TypeSyncStatistics`
which contains all the stats of the sync process; which includes a report message, the total number of updated, created,
failed, processed types and the processing time of the last sync batch in different time units and in a
human-readable format.

````java
final TypeSyncStatistics stats = syncStatisticsStage.toCompletebleFuture().join();
stats.getReportMessage();
/*"Summary: 2000 types were processed in total (1000 created, 995 updated, 5 failed to sync)."*/
````

__Note__ The statistics object contains the processing time of the last batch only. This is due to two reasons:

1. The sync processing time should not take into account the time between supplying batches to the sync.
2. It is not known by the sync which batch is going to be the last one supplied.

#### Important to Note
1. If two matching `fieldDefinition`s (old and new) on the matching `type`s (old and new) have a different `FieldType`, the sync will
**remove** the existing `fieldDefinition` and then **add** a new `fieldDefinition` with the new `FieldType`.

2. The `fieldDefinition` for which the `fieldType` is not defined (`null`) will not be synced.

#### More examples of how to use the sync

1. [Sync from another CTP project as a source](https://github.com/commercetools/commercetools-sync-java/tree/master/src/integration-test/java/com/commercetools/sync/integration/ctpprojectsource/types/TypeSyncIT.java).
2. [Sync from an external source](https://github.com/commercetools/commercetools-sync-java/tree/master/src/integration-test/java/com/commercetools/sync/integration/externalsource/types/TypeSyncIT.java).

*Make sure to read the [Important Usage Tips](IMPORTANT_USAGE_TIPS.md) for optimal performance.*

### Build all update actions

A utility method provided by the library to compare a `Type` with a new `TypeDraft` and results in a list of type update actions.
```java
List<UpdateAction<Type>> updateActions = TypeSyncUtils.buildActions(type, typeDraft, typeSyncOptions);
```

### Build particular update action(s)

Utility methods provided by the library to compare the specific fields of a `Type` and a new `TypeDraft`, and in turn builds
the update action. One example is the `buildChangeNameUpdateAction` which compares names:
````java
Optional<UpdateAction<Type>> updateAction = TypeUpdateActionUtils.buildChangeNameAction(oldType, typeDraft);
````
More examples of those utils for different types can be found [here](https://github.com/commercetools/commercetools-sync-java/tree/master/src/test/java/com/commercetools/sync/types/utils/TypeUpdateActionUtilsTest.java).

## Caveats

1. Updating the label of enum values and localized enum values of field definition is not supported yet. [#339](https://github.com/commercetools/commercetools-sync-java/issues/339)
2. Removing the enum values and localized enum values from the field definition is not supported yet. [#339](https://github.com/commercetools/commercetools-sync-java/issues/339)
3. Updating the input hint of a field definition is not supported yet. [#339](https://github.com/commercetools/commercetools-sync-java/issues/339)
4. Currently the sync would handle changes to Enum or LocalizedEnum Types but not [Set](https://docs.commercetools.com/http-api-projects-types.html#settype) of either. [#313](https://github.com/commercetools/commercetools-sync-java/issues/313)
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ nav:
- Quick Start: usage/QUICK_START.md
- Product Sync: usage/PRODUCT_SYNC.md
- ProductType Sync: usage/PRODUCT_TYPE_SYNC.md
- Type Sync: usage/TYPE_SYNC.md
- Category Sync: usage/CATEGORY_SYNC.md
- InventoryEntry Sync: usage/INVENTORY_SYNC.md
- Advanced:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class BenchmarkUtils {
static final String PRODUCT_SYNC = "productSync";
static final String INVENTORY_SYNC = "inventorySync";
static final String CATEGORY_SYNC = "categorySync";
static final String TYPE_SYNC = "typeSync";
static final String PRODUCT_TYPE_SYNC = "productTypeSync";
static final String CREATES_ONLY = "createsOnly";
static final String UPDATES_ONLY = "updatesOnly";
Expand Down Expand Up @@ -107,9 +108,9 @@ private static double calculateAvg(@Nonnull final List<JsonNode> results) {
}

private static ObjectNode createVersionNode(@Nonnull final ObjectNode rootNode, @Nonnull final String version) {
final ObjectNode newVersionNode = createSyncNode(
final ObjectNode newVersionNode = createSyncNode(createSyncNode(createSyncNode(
createSyncNode(createSyncNode(JsonNodeFactory.instance.objectNode(),
PRODUCT_SYNC), INVENTORY_SYNC), CATEGORY_SYNC);
PRODUCT_SYNC), INVENTORY_SYNC), CATEGORY_SYNC), PRODUCT_TYPE_SYNC), TYPE_SYNC);
return (ObjectNode) rootNode.set(version, newVersionNode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void sync_ExistingProducts_ShouldUpdateProducts() throws IOException {


// Calculate time taken for benchmark and assert it lies within threshold
final double diff = calculateDiff(SyncSolutionInfo.LIB_VERSION, PRODUCT_SYNC, CREATES_ONLY, totalTime);
final double diff = calculateDiff(SyncSolutionInfo.LIB_VERSION, PRODUCT_SYNC, UPDATES_ONLY, totalTime);
assertThat(diff)
.withFailMessage(format("Diff of benchmark '%e' is longer than expected threshold of '%d'.", diff,
THRESHOLD))
Expand Down Expand Up @@ -222,7 +222,7 @@ public void sync_WithSomeExistingProducts_ShouldSyncProducts() throws IOExceptio


// Calculate time taken for benchmark and assert it lies within threshold
final double diff = calculateDiff(SyncSolutionInfo.LIB_VERSION, PRODUCT_SYNC, CREATES_ONLY, totalTime);
final double diff = calculateDiff(SyncSolutionInfo.LIB_VERSION, PRODUCT_SYNC, CREATES_AND_UPDATES, totalTime);
assertThat(diff)
.withFailMessage(format("Diff of benchmark '%e' is longer than expected threshold of '%d'.", diff,
THRESHOLD))
Expand Down
Loading