Skip to content

Commit

Permalink
Merge branch 'sync-java-migration-v10' into DEVX-242_Make-subclass-of…
Browse files Browse the repository at this point in the history
…-syncer-compilable
  • Loading branch information
salander85 committed Oct 9, 2023
2 parents 06b99b5 + 7b3fd5c commit af9fdd8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
15 changes: 8 additions & 7 deletions src/main/java/com/commercetools/project/sync/Syncer.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,11 @@ public Syncer(
}

/**
* Fetches the sourceClient's project resources of type {@code ResourceT} with all needed
* references expanded and treats each page as a batch to the sync process. Then executes the sync
* process on every page sequentially. It then returns a completion stage containing a {@link
* Void} result after the execution of the sync process and logging the result.
* Fetches the sourceClient's project resources of type {@code ResourceT} with all needed references
* expanded and treats each page as a batch to the sync process. Then executes the sync process
* on every page sequentially. It then returns a completion stage
* containing a {@link Void} result after the execution of the sync process and logging the
* result.
*
* <p>Note: If {@param isFullSync} is {@code false}, i.e. a delta sync is required, the method
* checks if there was a last sync time stamp persisted as a custom object in the target project
Expand Down Expand Up @@ -264,9 +265,9 @@ private SyncStatisticsT syncPage(@Nonnull final List<ResourceT> page) {
}

/**
* Given a {@link List} representing a page of resources of type {@link ResourceT}, this method
* creates a list of drafts of type {@link ResourceDraftT} where reference ids of the references
* are replaced with keys and are ready for reference resolution by the sync process.
* Given a {@link List} representing a page of resources of type {@link ResourceT}, this method creates
* a list of drafts of type {@link ResourceDraftT} where reference ids of the references are
* replaced with keys and are ready for reference resolution by the sync process.
*
* @return a {@link CompletionStage} containing a list of drafts of type {@link ResourceDraftT}
* after being transformed from type {@link ResourceT}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
import java.time.ZonedDateTime;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public interface CustomObjectService {

/**
* Creates or updates a custom object with the container named 'commercetools-project-sync.{@param
* runnerName}.{@param syncModuleName}.timestampGenerator' and key equals 'timestampGenerator' and
* then reading the 'lastModifiedAt' field of the persisted custom object and returning it.
* Creates or updates a custom object with the container named
* 'commercetools-project-sync.{@param runnerName}.{@param syncModuleName}.timestampGenerator' and
* key equals 'timestampGenerator' and then reading the 'lastModifiedAt' field of the persisted custom
* object and returning it.
*
* @param syncModuleName the name of the resource being synced. E.g. productSync, categorySync,
* etc..
* @param runnerName the name of this specific running sync instance defined by the user.
* @return a {@link CompletionStage} containing the current CTP timestamp as {@link
* @return a {@link CompletableFuture} containing the current CTP timestamp as {@link
* ZonedDateTime}.
*/
@Nonnull
CompletionStage<ZonedDateTime> getCurrentCtpTimestamp(
CompletableFuture<ZonedDateTime> getCurrentCtpTimestamp(
@Nullable final String runnerName, @Nonnull final String syncModuleName);

/**
Expand All @@ -37,11 +37,11 @@ CompletionStage<ZonedDateTime> getCurrentCtpTimestamp(
* etc..
* @param runnerName the name of this specific running sync instance defined by the user.
* @return the custom object with container 'commercetools-project-sync.{@param
* runnerName}.{@param syncModuleName}' and key '{@param sourceProjectKey}', wrapped in an
* {@link Optional} as a result of a {@link CompletionStage}.
* runnerName}.{@param syncModuleName}' and key '{@param sourceProjectKey}', wrapped in an {@link Optional} as a
* result of a {@link CompletableFuture}.
*/
@Nonnull
CompletionStage<Optional<LastSyncCustomObject>> getLastSyncCustomObject(
CompletableFuture<Optional<LastSyncCustomObject>> getLastSyncCustomObject(
@Nonnull final String sourceProjectKey,
@Nonnull final String syncModuleName,
@Nullable final String runnerName);
Expand All @@ -57,8 +57,7 @@ CompletionStage<Optional<LastSyncCustomObject>> getLastSyncCustomObject(
* etc..
* @param runnerName the name of this specific running sync instance defined by the user.
* @param lastSyncCustomObject contains information about the last sync instance.
* @return a {@link CompletableFuture} of {@link ApiHttpResponse} with the created/updated custom
* object resource.
* @return a {@link CompletableFuture} of {@link ApiHttpResponse} with the created/updated custom object resource.
*/
@Nonnull
CompletableFuture<ApiHttpResponse<CustomObject>> createLastSyncCustomObject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

Expand All @@ -33,7 +32,7 @@ public CustomObjectServiceImpl(@Nonnull final ProjectApiRoot ctpClient) {

@Nonnull
@Override
public CompletionStage<ZonedDateTime> getCurrentCtpTimestamp(
public CompletableFuture<ZonedDateTime> getCurrentCtpTimestamp(
@Nullable final String runnerName, @Nonnull final String syncModuleName) {

final String container = buildCurrentCtpTimestampContainerName(syncModuleName, runnerName);
Expand All @@ -51,12 +50,10 @@ public CompletionStage<ZonedDateTime> getCurrentCtpTimestamp(
}

/**
* Helper to create a custom object of {@param customObjectDraft} on the CTP project defined by
* the {@code ctpClient}.
* Helper to create a custom object of {@param customObjectDraft} on the CTP project defined by the {@code ctpClient}.
*
* @param customObjectDraft draft of custom object to create
* @return a {@link CompletableFuture} of {@link ApiHttpResponse} with the created custom object
* resource.
* @return a {@link CompletableFuture} of {@link ApiHttpResponse} with the created custom object resource.
*/
@Nonnull
private CompletableFuture<ApiHttpResponse<CustomObject>> createCustomObject(
Expand Down

0 comments on commit af9fdd8

Please sign in to comment.