Class 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 supplied pageSize.
      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 supplied pageSize.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 a CompletionStage 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 element
        C - type of the query
        S - type of the returned result of the callback function on every page.
        Parameters:
        client - commercetools client
        query - query containing predicates and expansion paths
        pageMapper - 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#offset

        The 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 element
        C - type of the query
        Parameters:
        client - commercetools client
        query - query containing predicates and expansion paths
        pageConsumer - 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 supplied pageSize. 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 a CompletionStage 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 element
        C - type of the query
        S - type of the returned result of the callback function on every page.
        Parameters:
        client - commercetools client
        query - query containing predicates and expansion paths
        pageMapper - callback function that is called on every page queried
        pageSize - 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 supplied pageSize. More on the algorithm can be found here: http://dev.commercetools.com/http-api.html#offset

        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 - type of one query result element
        C - type of the query
        Parameters:
        client - commercetools client
        query - query containing predicates and expansion paths
        pageConsumer - consumer applied on every page queried
        pageSize - 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 extends GraphQlBaseResult
        U - the resource type which extends GraphQlBaseResource
        Parameters:
        client - commercetools client
        graphQlRequest - graphql query containing predicates and pagination limits
        pageConsumer - consumer applied on every page queried
        pageSize - 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 extends GraphQlBaseResult
        U - the resource type which extends GraphQlBaseResource
        Parameters:
        client - commercetools client
        graphQlRequest - graphql query containing predicates and pagination limits
        pageConsumer - consumer applied on every page queried
        Returns:
        a completion stage containing void as a result after the consumer was applied on all pages.