Class CtpQueryUtils
- java.lang.Object
-
- com.commercetools.sync.commons.utils.CtpQueryUtils
-
public final class CtpQueryUtils extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends GraphQlBaseResult<U>,U extends GraphQlBaseResource>
java.util.concurrent.CompletionStage<java.lang.Void>queryAll(io.sphere.sdk.client.SphereClient client, GraphQlBaseRequest<T> graphQlRequest, java.util.function.Consumer<java.util.Set<U>> pageConsumer)
Creates a graphQL query to fetch all elements where keys matching given set of keys with pagination using a combination of limit and id sorting.static <T extends GraphQlBaseResult<U>,U extends GraphQlBaseResource>
java.util.concurrent.CompletionStage<java.lang.Void>queryAll(io.sphere.sdk.client.SphereClient client, GraphQlBaseRequest<T> graphQlRequest, java.util.function.Consumer<java.util.Set<U>> pageConsumer, int pageSize)
Creates a graphQL query to fetch all elements where keys matching given set of keys with pagination using a combination of limit and id sorting.static <T extends io.sphere.sdk.models.ResourceView,C extends io.sphere.sdk.queries.QueryDsl<T,C>>
java.util.concurrent.CompletionStage<java.lang.Void>queryAll(io.sphere.sdk.client.SphereClient client, io.sphere.sdk.queries.QueryDsl<T,C> query, java.util.function.Consumer<java.util.List<T>> pageConsumer)
Queries all elements matching a query by using a limit based pagination with a combination of id sorting and a page size 500.static <T extends io.sphere.sdk.models.ResourceView,C extends io.sphere.sdk.queries.QueryDsl<T,C>>
java.util.concurrent.CompletionStage<java.lang.Void>queryAll(io.sphere.sdk.client.SphereClient client, io.sphere.sdk.queries.QueryDsl<T,C> query, java.util.function.Consumer<java.util.List<T>> pageConsumer, int pageSize)
Queries all elements matching a query by using a limit based pagination with a combination of id sorting and the suppliedpageSize
.static <T extends io.sphere.sdk.models.ResourceView,C extends io.sphere.sdk.queries.QueryDsl<T,C>,S>
java.util.concurrent.CompletionStage<java.util.List<S>>queryAll(io.sphere.sdk.client.SphereClient client, io.sphere.sdk.queries.QueryDsl<T,C> query, java.util.function.Function<java.util.List<T>,S> pageMapper)
Queries all elements matching a query by using a limit based pagination with a combination of id sorting and a page size 500.static <T extends io.sphere.sdk.models.ResourceView,C extends io.sphere.sdk.queries.QueryDsl<T,C>,S>
java.util.concurrent.CompletionStage<java.util.List<S>>queryAll(io.sphere.sdk.client.SphereClient client, io.sphere.sdk.queries.QueryDsl<T,C> query, java.util.function.Function<java.util.List<T>,S> pageMapper, int pageSize)
Queries all elements matching a query by using a limit based pagination with a combination of id sorting and the suppliedpageSize
.
-
-
-
Method Detail
-
queryAll
@Nonnull public static <T extends io.sphere.sdk.models.ResourceView,C extends io.sphere.sdk.queries.QueryDsl<T,C>,S> java.util.concurrent.CompletionStage<java.util.List<S>> queryAll(@Nonnull io.sphere.sdk.client.SphereClient client, @Nonnull io.sphere.sdk.queries.QueryDsl<T,C> query, @Nonnull java.util.function.Function<java.util.List<T>,S> pageMapper)
Queries all elements matching a query by using a limit based pagination with a combination of id sorting and a page size 500. More on the algorithm can be found here: http://dev.commercetools.com/http-api.html#offset.The method takes a callback
Function
that returns a result of type<S>
that is returned on every page of elements queried. Eventually, the method returns aCompletionStage
that contains a list of all the results of the callbacks returned from every page.NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in parallel.
- Type Parameters:
T
- type of one query result elementC
- type of the queryS
- type of the returned result of the callback function on every page.- Parameters:
client
- commercetools clientquery
- query containing predicates and expansion pathspageMapper
- callback function that is called on every page queried- Returns:
- a completion stage containing a list of mapped pages as a result.
-
queryAll
@Nonnull public static <T extends io.sphere.sdk.models.ResourceView,C extends io.sphere.sdk.queries.QueryDsl<T,C>> java.util.concurrent.CompletionStage<java.lang.Void> queryAll(@Nonnull io.sphere.sdk.client.SphereClient client, @Nonnull io.sphere.sdk.queries.QueryDsl<T,C> query, @Nonnull java.util.function.Consumer<java.util.List<T>> pageConsumer)
Queries all elements matching a query by using a limit based pagination with a combination of id sorting and a page size 500. More on the algorithm can be found here: http://dev.commercetools.com/http-api.html#offsetThe method takes a consumer
Consumer
that is applied on every page of elements queried.NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in parallel.
- Type Parameters:
T
- type of one query result elementC
- type of the query- Parameters:
client
- commercetools clientquery
- query containing predicates and expansion pathspageConsumer
- consumer applied on every page queried- Returns:
- a completion stage containing void as a result after the consumer was applied on all pages.
-
queryAll
@Nonnull public static <T extends io.sphere.sdk.models.ResourceView,C extends io.sphere.sdk.queries.QueryDsl<T,C>,S> java.util.concurrent.CompletionStage<java.util.List<S>> queryAll(@Nonnull io.sphere.sdk.client.SphereClient client, @Nonnull io.sphere.sdk.queries.QueryDsl<T,C> query, @Nonnull java.util.function.Function<java.util.List<T>,S> pageMapper, int pageSize)
Queries all elements matching a query by using a limit based pagination with a combination of id sorting and the suppliedpageSize
. More on the algorithm can be found here: http://dev.commercetools.com/http-api.html#offset.The method takes a callback
Function
that returns a result of type<S>
that is returned on every page of elements queried. Eventually, the method returns aCompletionStage
that contains a list of all the results of the callbacks returned from every page.NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in parallel.
- Type Parameters:
T
- type of one query result elementC
- type of the queryS
- type of the returned result of the callback function on every page.- Parameters:
client
- commercetools clientquery
- query containing predicates and expansion pathspageMapper
- callback function that is called on every page queriedpageSize
- the page size.- Returns:
- a completion stage containing a list of mapped pages as a result.
-
queryAll
@Nonnull public static <T extends io.sphere.sdk.models.ResourceView,C extends io.sphere.sdk.queries.QueryDsl<T,C>> java.util.concurrent.CompletionStage<java.lang.Void> queryAll(@Nonnull io.sphere.sdk.client.SphereClient client, @Nonnull io.sphere.sdk.queries.QueryDsl<T,C> query, @Nonnull java.util.function.Consumer<java.util.List<T>> pageConsumer, int pageSize)
Queries all elements matching a query by using a limit based pagination with a combination of id sorting and the suppliedpageSize
. More on the algorithm can be found here: http://dev.commercetools.com/http-api.html#offsetThe method takes a
Consumer
that is applied on every page of the queried elements.NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in parallel.
- Type Parameters:
T
- type of one query result elementC
- type of the query- Parameters:
client
- commercetools clientquery
- query containing predicates and expansion pathspageConsumer
- consumer applied on every page queriedpageSize
- the page size- Returns:
- a completion stage containing void as a result after the consumer was applied on all pages.
-
queryAll
@Nonnull public static <T extends GraphQlBaseResult<U>,U extends GraphQlBaseResource> java.util.concurrent.CompletionStage<java.lang.Void> queryAll(@Nonnull io.sphere.sdk.client.SphereClient client, @Nonnull GraphQlBaseRequest<T> graphQlRequest, @Nonnull java.util.function.Consumer<java.util.Set<U>> pageConsumer, int pageSize)
Creates a graphQL query to fetch all elements where keys matching given set of keys with pagination using a combination of limit and id sorting.The method takes a
Consumer
that is applied on every page of the queried elements.NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in parallel.
- Type Parameters:
T
- the result type which extendsGraphQlBaseResult
U
- the resource type which extendsGraphQlBaseResource
- Parameters:
client
- commercetools clientgraphQlRequest
- graphql query containing predicates and pagination limitspageConsumer
- consumer applied on every page queriedpageSize
- the page size.- Returns:
- a completion stage containing void as a result after the consumer was applied on all pages.
-
queryAll
@Nonnull public static <T extends GraphQlBaseResult<U>,U extends GraphQlBaseResource> java.util.concurrent.CompletionStage<java.lang.Void> queryAll(@Nonnull io.sphere.sdk.client.SphereClient client, @Nonnull GraphQlBaseRequest<T> graphQlRequest, @Nonnull java.util.function.Consumer<java.util.Set<U>> pageConsumer)
Creates a graphQL query to fetch all elements where keys matching given set of keys with pagination using a combination of limit and id sorting.The method takes a
Consumer
that is applied on every page of the queried elements.NOTE: This method fetches all paged results sequentially as opposed to fetching the pages in parallel.
- Type Parameters:
T
- the result type which extendsGraphQlBaseResult
U
- the resource type which extendsGraphQlBaseResource
- Parameters:
client
- commercetools clientgraphQlRequest
- graphql query containing predicates and pagination limitspageConsumer
- consumer applied on every page queried- Returns:
- a completion stage containing void as a result after the consumer was applied on all pages.
-
-