ODataQuery
import io.skipcheck.tm1.client.odata.ODataQuery;Used in the walkthroughs Connect and list your cubes, Read and write cells, Run a process and read its result, Test your code against a real TM1, Add TM1 to a Spring Boot application.
OData query options: $select, $expand (with nested options),
$filter, $orderby, $top, $skip, $count, custom
options such as TM1's !sandbox, and parameter aliases. Immutable: each method
returns a new query.
String query = ODataQuery.none()
.select("Name", "Type")
.expand("Hierarchies", h -> h.select("Name").top(5))
.filter(Filter.startsWith(ODataProperty.of("Name"), "Q"))
.toQueryString();
// $select=Name,Type&$expand=Hierarchies($select=Name;$top=5)&$filter=startswith(Name,'Q'),
// each value encoded
Options are written in a fixed order, lowercase with $ as OData 4.0 requires,
and each value is percent-encoded once by toQueryString. Nested options
inside $expand are separated by ;.
Members
none static | No options. |
select | Adds properties to $select. |
select | Adds properties to $select. |
expand | Expands a navigation property with no nested options. |
expand | Expands a navigation property, with nested options. |
expand | Expands a navigation property with no nested options. |
expand | Expands a navigation property, with nested options. |
filter | Sets $filter. |
orderBy | Adds an ascending $orderby key. |
orderByDescending | Adds a descending $orderby key. |
orderBy | Adds an ascending $orderby key. |
orderByDescending | Adds a descending $orderby key. |
top | Sets $top. |
skip | Sets $skip. |
withCount | Sets $count=true. |
option | Sets a custom query option, such as TM1's !sandbox. |
alias | Defines a parameter alias for a function call. |
isEmpty | True if this query has no options. |
toQueryString | The encoded query string, without a leading ?; empty if there are no options. |
toString | The query unencoded, for logs and messages. |
equals | |
hashCode | |
option | The custom option's value, e.g. |
none
staticstatic ODataQuery none()No options: the server's default response.
Returns
- the empty query
select
ODataQuery select(String... properties) Adds properties to $select. Like every option here it's an instance method,
so it works the same at the top level and inside
expand.
Parameters
properties- the property paths, added after any already selected
Returns
- a new query
select
ODataQuery select(ODataProperty... properties) Adds properties to $select.
Parameters
properties- the properties, added after any already selected
Returns
- a new query
expand
ODataQuery expand(String navigation)Expands a navigation property with no nested options.
Parameters
navigation- the navigation property's name
Returns
- a new query
expand
ODataQuery expand(String navigation, UnaryOperator<ODataQuery> options) Expands a navigation property, with nested options:
expand("Hierarchies", h -> h.select("Name")).
Parameters
navigation- the navigation property's name
options- adds the nested options to the query it's given: the empty query, or
the nested options so far if
navigationis already expanded
Returns
- a new query
expand
ODataQuery expand(ODataProperty navigation) Expands a navigation property with no nested options:
expand(Cube.DIMENSIONS).
Parameters
navigation- the navigation property
Returns
- a new query
expand
ODataQuery expand(ODataProperty navigation, UnaryOperator<ODataQuery> options) Expands a navigation property, with nested options:
expand(Dimension.HIERARCHIES, h -> h.select(Hierarchy.NAME)).
Parameters
navigation- the navigation property
options- adds the nested options to the query it's given, as for
expand
Returns
- a new query
filter
ODataQuery filter(Filter filter) Sets $filter.
Parameters
filter- the filter, replacing any set before
Returns
- a new query
orderBy
ODataQuery orderBy(String property) Adds an ascending $orderby key.
Parameters
property- the property path, after any keys already added
Returns
- a new query
orderByDescending
ODataQuery orderByDescending(String property) Adds a descending $orderby key.
Parameters
property- the property path, after any keys already added
Returns
- a new query
orderBy
ODataQuery orderBy(ODataProperty property) Adds an ascending $orderby key: orderBy(Element.NAME).
Parameters
property- the property, after any keys already added
Returns
- a new query
orderByDescending
ODataQuery orderByDescending(ODataProperty property) Adds a descending $orderby key.
Parameters
property- the property, after any keys already added
Returns
- a new query
top
ODataQuery top(int n) Sets $top: at most this many items.
Parameters
n- the maximum number of items, zero or more
Returns
- a new query
Throws
IllegalArgumentException- if
nis negative
skip
ODataQuery skip(int n) Sets $skip: skip this many items first.
Parameters
n- the number of items to skip, zero or more
Returns
- a new query
Throws
IllegalArgumentException- if
nis negative
withCount
ODataQuery withCount() Sets $count=true: include the total number of matching items.
Returns
- a new query
option
ODataQuery option(String name, String value) Sets a custom query option, such as TM1's !sandbox. Custom options must not
start with $ or @. Setting one again replaces it.
Parameters
name- the option's name, e.g.
!sandbox value- the option's value, unencoded
Returns
- a new query
Throws
IllegalArgumentException- if
nameisn't a valid custom option name
alias
ODataQuery alias(ODataPath.Alias alias, String literalOrJson) Defines a parameter alias for a function call: @p=<literal or JSON>,
written as given.
Parameters
alias- the alias, as used in the function call
literalOrJson- the alias's value, an OData literal or JSON, unencoded
Returns
- a new query
isEmpty
boolean isEmpty()True if this query has no options.
Returns
trueif there are no options
toQueryString
String toQueryString() The encoded query string, without a leading ?; empty if there are no
options.
Returns
- the encoded query string, or an empty string
toString
String toString()The query unencoded, for logs and messages.
equals
boolean equals(Object o)hashCode
int hashCode()option
String option(String name) The custom option's value, e.g. the current !sandbox, if set.
Parameters
name- the option's name
Returns
- the option's value, unencoded, or
nullif it isn't set
Also in the Javadoc.