public class DeliveryParameterBuilder
extends java.lang.Object
For example given the following criteria:
DeliveryClient deliveryClient = new DeliveryClient("02a70003-e864-464e-b62c-e0ede97deb8c");
List<ArticleItem> articles = deliveryClient.getItems(
ArticleItem.class,
DeliveryParameterBuilder.params()
.filterEquals("system.type", "article")
.projection("title", "summary", "post_date", "teaser_image")
.filterContains("elements.personas", "coffee_lover")
.orderByDesc("elements.post_date")
.linkedItemsDepth(0)
.page(null, 3)
.build());
Note: When using DeliveryClient.getItems(Class, List), if the type is
registered with the client via
DeliveryClient.registerType(Class),
DeliveryClient.registerType(String, Class), or
DeliveryClient.scanClasspathForMappings(String), the operator
.filterEquals("system.type", your_mapped_type will automatically be
added prior to the request if
'system_type' is not part of any other parameter in the request already.
When retrieving a list of content items from your project with
DeliveryClient.getItems(List) and/or
DeliveryClient.getItems(Class, List), you can filter large sets of
content items by building query operators
from content elements and system attributes. Note that the query operators do
not apply to linked items
represented by the ContentItemsListingResponse.getLinkedItems() field
in the response.
If you want to limit the listing response only to certain elements, see
projection(String...).
To filter by system attribute values, you need to use a query attribute in
the 'system.<attribute_name>'
format. The system attributes include 'id', 'name', 'codename', 'type',
'sitemap_locations', and 'last_modified'. For
example, to retrieve only content items based on the Article content type,
you can use
.filterEquals("system.type", "article" as a query operator.
To filter by content element values, you need to use a query attribute in the
'elements.<element_codename>' format. For example, to retrieve only
content items whose
NumberElement named 'Price' has a value of 16, you can use
.filterEquals("elements.price", "13" as
a query operator.
You can use the following filtering operators both with the system attributes and element values:
filterEquals(String, String)filterLessThan(String, String)filterLessThanEquals(String, String)filterGreaterThan(String, String)filterGreaterThanEquals(String, String)filterRange(String, String, String)filterIn(String, String...)filterIn(String, Collection)filterContains(String, String)filterAny(String, String...)filterAny(String, Collection)filterAll(String, String...)filterAll(String, Collection)
You can use the filterContains(String, String),
filterAny(String, String...),
filterAny(String, Collection),
filterAny(String, String...), and
filterAny(String, Collection) filtering operators only with arrays.
Array attributes in Kontent
include the sitemap locations system object
(System.getSitemapLocations()), and the AssetsElement,
LinkedItem, MultipleChoiceElement, and
TaxonomyElement content elements. All the
other system attributes and content type elements are simple types, such as
strings or numbers.
The filtering operators filterLessThan(String, String),
filterLessThanEquals(String, String),
filterGreaterThan(String, String),
filterGreaterThanEquals(String, String), and
filterRange(String, String, String) work best with numbers. For
example, you can retrieve products with
price larger or equal to 15 by using
.filterGreaterThanEquals("elements.price", "15"). Attributes that
store
dates (such as the last_modified system attribute or
DateTimeElements) are represented as strings.
If you use the filters on attributes with string values, the Delivery API
tries to perform a string comparison. For
example, to retrieve content items modified during February and March you'd
need to use a query such as
.filterRange("system.last_modified", "2018-02-01", "2018-03-31"),
specifying both the start and end dates.
Paging
You can get only a small subset of a large collection of content items with
the page(Integer, Integer)
operator. The first argument is the number of pages to skip, with the second
being the page size. Using these
argument, you can display a specific page of results and iterate over a list
of content items or types.
For example, when you have a
ContentItemsListingResponse.getPagination() with a
Pagination.getCount()
of 10 items, you can use .page(10, 10) to retrieve the second page of
results.
For details about the pagination data in each listing response, see the
Pagination object.
Choose which parts of content to retrieve with the
projection(String...) operator.
For example, to retrieve only the elements with codenames 'title', 'summary',
and 'related_articles':
.projection("title", "summary", "related_articles")
Content items might reference linked items using the LinkedItem.
Recursively, these
linked items can reference another LinkedItem element. By default,
only one level of
linked items are returned.
If you want to include more than one level of linked items in a response, use
the
linkedItemsDepth(Integer) operator.
If you want to exclude all linked items, use the
excludeLinkedItems() operator.
Note: When retrieving content items, linked items cannot be filtered.
| Constructor and Description |
|---|
DeliveryParameterBuilder() |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<NameValuePair> |
build()
Builds the query parameters to pass into the
DeliveryClient from this
DeliveryParametersBuilder. |
DeliveryParameterBuilder |
excludeLinkedItems()
Excludes all linked items.
|
DeliveryParameterBuilder |
filterAll(java.lang.String attribute,
java.util.Collection<java.lang.String> values)
Attribute with an array of values contains the specified list of values.
|
DeliveryParameterBuilder |
filterAll(java.lang.String attribute,
java.lang.String... values)
Attribute with an array of values contains the specified list of values.
|
DeliveryParameterBuilder |
filterAny(java.lang.String attribute,
java.util.Collection<java.lang.String> values)
Attribute with an array of values contains any value from the specified list
of values.
|
DeliveryParameterBuilder |
filterAny(java.lang.String attribute,
java.lang.String... values)
Attribute with an array of values contains any value from the specified list
of values.
|
DeliveryParameterBuilder |
filterContains(java.lang.String attribute,
java.lang.String value)
Attribute with an array of values contains the specified value.
|
DeliveryParameterBuilder |
filterEmpty(java.lang.String attribute)
Attribute value is empty.
|
DeliveryParameterBuilder |
filterEquals(java.lang.String attribute,
java.lang.String value)
Attribute value is the same as the specified value.
|
DeliveryParameterBuilder |
filterGreaterThan(java.lang.String attribute,
java.lang.String value)
Attribute value is greater than the specified value.
|
DeliveryParameterBuilder |
filterGreaterThanEquals(java.lang.String attribute,
java.lang.String value)
Attribute value is greater than or equals the specified value.
|
DeliveryParameterBuilder |
filterIn(java.lang.String attribute,
java.util.Collection<java.lang.String> values)
Attribute value is in the specified list of values.
|
DeliveryParameterBuilder |
filterIn(java.lang.String attribute,
java.lang.String... values)
Attribute value is in the specified list of values.
|
DeliveryParameterBuilder |
filterLessThan(java.lang.String attribute,
java.lang.String value)
Attribute value is less than the specified value.
|
DeliveryParameterBuilder |
filterLessThanEquals(java.lang.String attribute,
java.lang.String value)
Attribute value is less than or equals the specified value.
|
DeliveryParameterBuilder |
filterNotEmpty(java.lang.String attribute)
Attribute value is not empty.
|
DeliveryParameterBuilder |
filterNotEquals(java.lang.String attribute,
java.lang.String value)
Attribute value is not the same as the specified value.
|
DeliveryParameterBuilder |
filterNotIn(java.lang.String attribute,
java.util.Collection<java.lang.String> values)
Attribute value is not in the specified list of values.
|
DeliveryParameterBuilder |
filterNotIn(java.lang.String attribute,
java.lang.String... values)
Attribute value is not in the specified list of values.
|
DeliveryParameterBuilder |
filterRange(java.lang.String attribute,
java.lang.String lower,
java.lang.String upper)
Attribute value falls in the specified range of two values, both inclusive.
|
DeliveryParameterBuilder |
includeTotalCount()
Adds the information about the total number of content items matching your
query.
|
DeliveryParameterBuilder |
language(java.util.Locale language)
Determines which language variant of content to return.
|
DeliveryParameterBuilder |
language(java.lang.String language)
Determines which language variant of content to return.
|
DeliveryParameterBuilder |
linkedItemsDepth(java.lang.Integer depth)
Choose the depth of linked items to return.
|
DeliveryParameterBuilder |
orderByAsc(java.lang.String attribute)
Sort the
ContentItemsListingResponse by the attribute in ascending
order. |
DeliveryParameterBuilder |
orderByDesc(java.lang.String attribute)
Sort the
ContentItemsListingResponse by the attribute in descending
order. |
DeliveryParameterBuilder |
page(java.lang.Integer skip,
java.lang.Integer limit)
Allows a subset of a query.
|
static DeliveryParameterBuilder |
params()
Constructs a new DeliveryParameterBuilder.
|
DeliveryParameterBuilder |
projection(java.lang.String... elements)
Choose which parts of content to retrieve.
|
public static DeliveryParameterBuilder params()
public DeliveryParameterBuilder filterEquals(java.lang.String attribute, java.lang.String value)
attribute - The attribute.value - The value.public DeliveryParameterBuilder filterNotEquals(java.lang.String attribute, java.lang.String value)
attribute - The attribute.value - The value.public DeliveryParameterBuilder filterEmpty(java.lang.String attribute)
attribute - The attribute.public DeliveryParameterBuilder filterNotEmpty(java.lang.String attribute)
attribute - The attribute.public DeliveryParameterBuilder filterLessThan(java.lang.String attribute, java.lang.String value)
attribute - The attribute.value - The value.public DeliveryParameterBuilder filterLessThanEquals(java.lang.String attribute, java.lang.String value)
attribute - The attribute.value - The value.public DeliveryParameterBuilder filterGreaterThan(java.lang.String attribute, java.lang.String value)
attribute - The attribute.value - The value.public DeliveryParameterBuilder filterGreaterThanEquals(java.lang.String attribute, java.lang.String value)
attribute - The attribute.value - The value.public DeliveryParameterBuilder filterRange(java.lang.String attribute, java.lang.String lower, java.lang.String upper)
attribute - The attribute.lower - The lower bound value.upper - The upper bound value.public DeliveryParameterBuilder filterIn(java.lang.String attribute, java.lang.String... values)
attribute - The attribute.values - The values.public DeliveryParameterBuilder filterIn(java.lang.String attribute, java.util.Collection<java.lang.String> values)
attribute - The attribute.values - The values.public DeliveryParameterBuilder filterNotIn(java.lang.String attribute, java.lang.String... values)
attribute - The attribute.values - The values.public DeliveryParameterBuilder filterNotIn(java.lang.String attribute, java.util.Collection<java.lang.String> values)
attribute - The attribute.values - The values.public DeliveryParameterBuilder filterContains(java.lang.String attribute, java.lang.String value)
attribute - The attribute.value - The value.public DeliveryParameterBuilder filterAny(java.lang.String attribute, java.lang.String... values)
attribute - The attribute.values - The values.public DeliveryParameterBuilder filterAny(java.lang.String attribute, java.util.Collection<java.lang.String> values)
attribute - The attribute.values - The values.public DeliveryParameterBuilder filterAll(java.lang.String attribute, java.lang.String... values)
attribute - The attribute.values - The values.public DeliveryParameterBuilder filterAll(java.lang.String attribute, java.util.Collection<java.lang.String> values)
attribute - The attribute.values - The values.public DeliveryParameterBuilder orderByAsc(java.lang.String attribute)
ContentItemsListingResponse by the attribute in ascending
order. As with filtering, you can use
both the 'system' and 'elements' attributes to sort data.attribute - The attribute to sort on.public DeliveryParameterBuilder orderByDesc(java.lang.String attribute)
ContentItemsListingResponse by the attribute in descending
order. As with filtering, you can
use both the 'system' and 'elements' attributes to sort data.attribute - The attribute to sort on.public DeliveryParameterBuilder page(java.lang.Integer skip, java.lang.Integer limit)
DeliveryClient.getItems(List) and
DeliveryClient.getItems(Class, List). If the Page convention
is desired, use
DeliveryClient.getPageOfItems(Class, List).skip - The number of items to skip. For the second page of 10, use the
value '10' and limit of '10'.
The API treats 'null' as a '0' skip value.limit - The size of the page.Pagination,
Page,
More
on Pagingpublic DeliveryParameterBuilder projection(java.lang.String... elements)
.projection("title", "summary", "related_articles")elements - The elements to retrieve.public DeliveryParameterBuilder linkedItemsDepth(java.lang.Integer depth)
depth - The number of levels of depth to return.public DeliveryParameterBuilder excludeLinkedItems()
.linkedItemsDepth(0)public DeliveryParameterBuilder language(java.lang.String language)
language - The language variant to return.public DeliveryParameterBuilder language(java.util.Locale language)
language - The language variant to return.public DeliveryParameterBuilder includeTotalCount()
public java.util.List<NameValuePair> build()
DeliveryClient from this
DeliveryParametersBuilder.