Class Queryable
- All Implemented Interfaces:
RestConverter
When enabled, a response that's a Collection or object array of beans, or of Maps, can be
filtered with the BeanQuery search language via the following request parameters (see BeanQueryRequest
for the per-parameter Swagger docs):
&search= Comma-separatedcolumn=expression clauses.&view= Comma-separated columns to return, in order.&sort= Comma-separated sort columns; append":desc" (or"-" ) for descending.&position= 0-based index of the first row.&limit= Maximum rows to return.&opts= Options askey=value clauses (e.g.counts=true ).
A response that isn't tabular — not a Collection or object array, or one whose first non-null element
is a plain string, number, date or other scalar — is returned unchanged; the query parameters are
ignored, exactly as they were for non-tabular results before 10.0. An empty or all-null collection is likewise
returned unchanged (there's no element to derive columns from).
Bean rows get one InMemoryBeanQueryContext per element class, built once (with any
QueryableSettings bean applied) and cached for the lifetime of this converter instance, so
QueryableSettings is read once per element class, not on every request. Map rows get one
column per key of the first non-null row (type inferred from that row's value by the same rule as bean
properties, see QueryProperty.searchTypeOf(Class): a Number → SearchType.NUMERIC, a
Boolean → SearchType.BOOLEAN, an enum → SearchType.ENUM, a
date/calendar/temporal → SearchType.TIMESTAMP, anything else (or a SearchType.TEXT); this context is built on every
request, since the key set can differ per response. Keys that appear only in later rows are not queryable.
TOTAL_HEADER / MATCHED_HEADER response headers carrying the
session's
Example:
A bad column or option (e.g. BeanQuerySyntaxException, which
RestContext.convertThrowable maps to an HTTP 400 carrying an
X-BeanQuery-Total: 42 X-BeanQuery-Matched: 7
See Also:
QueryableSettings- Per-resource limits and defaults for this converter.BeanQueryRequest- The request parameters this converter binds.InMemoryBeanQueryContext- The engine this converter drives.RestOp.converters()- Registering converters with REST resources.- Converters
- Since:
- 10.0.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvert(RestRequest req, Object o) Performs post-call conversion on the specified response object.
-
Field Details
-
TOTAL_HEADER
Response header carrying the total (unfiltered) row count.Set only when
&opts=counts=trueis requested and the session reports atotal()count.- See Also:
-
MATCHED_HEADER
Response header carrying the filtered (matched) row count.Set only when
&opts=counts=trueis requested and the session reports amatched()count.- See Also:
-
SWAGGER_PARAMS
Swagger parameters for this converter.- See Also:
-
-
Constructor Details
-
Queryable
public Queryable()
-
-
Method Details
-
convert
Description copied from interface:RestConverterPerforms post-call conversion on the specified response object.- Specified by:
convertin interfaceRestConverter- Parameters:
req- The servlet request.o- The response object set by the REST method through theRestResponse.setContent(Object)method.- Returns:
- The converted object.
-