public final class Request extends Object
A request is executed by calling the method execute()
.
Note that this class is not synchronized.
See Setting a fetch size
on optimization with respect to the expected size of the RequestResult
and the limitations when using PostgreSQL as the underlying database.
AdaptationTable.createRequest()
Modifier and Type | Method and Description |
---|---|
Map<SchemaNode,Adaptation> |
checkForbiddenNodes()
When the execution would fail and throw a
QueryPermissionException , this method
returns the forbidden fields and the dataset in which these are forbidden. |
RequestResult |
execute()
Executes the request and returns the result.
|
int |
getFetchSize() |
Locale |
getLocale() |
RequestSortCriteria |
getSortCriteria() |
AdaptationFilter |
getSpecificFilter()
Returns the current filter, if any.
|
boolean |
isIncludeOcculting() |
boolean |
isSortedByRelevancy()
Returns whether the results of this request should be sorted by relevancy.
|
RequestPagination |
paginate()
Returns a new object to be used to paginate over the
result of this request.
|
void |
setFetchSize(int rows)
Provides a hint to the underlying database as to the number of records
to fetch at a time from the result of
executing
this request. |
void |
setIncludeOcculting(boolean includeOcculting)
If the argument is
true , this method specifies that
the request result will include records in occulting mode. |
void |
setLocale(Locale aLocale)
Sets a locale to the request.
|
void |
setOrderByPrimaryKey()
Specifies that the request result will be sorted by primary key
in ascending order.
|
void |
setSession(Session aSession)
Sets the user session on the request.
|
void |
setSortCriteria(RequestSortCriteria aSortCriteria)
Specifies that the request result will be sorted according to the
specified criteria.
|
void |
setSpecificFilter(AdaptationFilter aFilter)
Specifies that the request result will only include the records that
satisfy the filter passed as an argument.
|
void |
setXPathFilter(String aPredicateExpression)
Specifies that the request result will only include the records which
satisfy the specified XPath predicate.
|
void |
setXPathFilter(XPathFilter anXPathFilter)
Specifies that the request result will only include the records which
satisfy the specified XPath filter.
|
void |
setXPathParameter(String aParameterName,
Object aParameterValue)
For the current XPath filter, sets the value of the specified parameter.
|
void |
sortByRelevancy()
Specifies that the results of this request will be sorted according to their relevancy
regarding the search criterion (most relevant first).
|
String |
toString() |
public boolean isIncludeOcculting()
setIncludeOcculting(boolean)
public void setIncludeOcculting(boolean includeOcculting)
true
, this method specifies that
the request result will include records in occulting mode.
If the argument is false
, records in occulting mode
are not included in the result. If the property is not set, it is considered
to be false
.
public Locale getLocale()
setLocale(Locale)
public void setLocale(Locale aLocale)
osd:label(./localized_field)='A'
.setSession(Session)
public void setSession(Session aSession)
Applying the permissions checks will have the following effects:
QueryPermissionException
will be thrown on execution if at least one
forbidden node is used in the request. Currently, this does not take into account record-dependent
access rules set on fields.setLocale(Locale)
public RequestSortCriteria getSortCriteria()
setSortCriteria(RequestSortCriteria)
public void setOrderByPrimaryKey()
setSortCriteria(RequestSortCriteria)
public void setSortCriteria(RequestSortCriteria aSortCriteria)
If this method is not called, the default sort order is undefined, in which case the results will be sorted according to the order of whichever index is selected for computing the request. If no filter is specified, the result will be ordered according to the primary key fields (ascending).
IllegalArgumentException
- if the specified sort is not consistent with the table structure.setOrderByPrimaryKey()
,
sortByRelevancy()
public void sortByRelevancy()
execute()
if they have specified this sort by relevancy.
It is currently not possible to combine this special sort with additional sort criteria:
this call will replace any pre-existing sort criteria.public boolean isSortedByRelevancy()
true
.sortByRelevancy()
public AdaptationFilter getSpecificFilter()
public void setSpecificFilter(AdaptationFilter aFilter)
If not set, the value of this property is null
, and no
specific filtering will be performed.
If a filter has been specified by means of a method setXPathFilter
,
it is replaced by the specified filter.
setXPathFilter(XPathFilter)
public void setXPathFilter(String aPredicateExpression)
This method is equivalent to:
XPathFilter xpf = XPathFilter.newFilter(false, aPredicateExpression); this.setXPathFilter(xpf);
Performance considerations: If the specified predicate must
be often reused by multiple Request
objects,
it is recommended to use a cached filter.
Parameterized expressions also help reuse.
setXPathFilter(XPathFilter)
public void setXPathFilter(XPathFilter anXPathFilter)
If a filter has been specified by means of
the method
,
it is replaced by the specified XPath filter.
setSpecificFilter(AdaptationFilter)
It is recommended to use the XPath filter when the predicate must be applied more than once, with different values. It allows using parameters and avoiding parsing the same predicate expression each time it is used.
setXPathParameter(String, Object)
,
XPath supported syntaxpublic void setXPathParameter(String aParameterName, Object aParameterValue)
For example, if the current filter is the XPath predicate
./lastName=$myName
, to set the parameter myName
to 'Smith', the method must be invoked this way:
aRequest.setXPathParameter("myName", "Smith");
aParameterName
- name of the parameteraParameterValue
- value of the parameterIllegalArgumentException
- if one of the specified arguments is not defined
or if the specified parameter name has basic inconsistencies.IllegalStateException
- if no XPath filter has been specified.setXPathFilter(String)
,
Query.setParameter(int, java.lang.Object)
public int getFetchSize()
setFetchSize(int)
public void setFetchSize(int rows)
executing
this request. If the fetch size specified is '0', the underlying implementation
determines the fetch size independently.rows
- the number of rows to fetchQuery.setFetchSize(int)
,
Statement.setFetchSize(int)
public RequestResult execute() throws IncompatibleChangeError, QueryPermissionException
Once this method has been called, it is mandatory to invoke
the RequestResult.close()
method on the returned object.
Otherwise, this will fail to release some system resources.
QueryPermissionException
- if a session is provided and at least one forbidden node is used in the request.IncompatibleChangeError
public Map<SchemaNode,Adaptation> checkForbiddenNodes()
QueryPermissionException
, this method
returns the forbidden fields and the dataset in which these are forbidden. Otherwise, returns an
empty map.public RequestPagination paginate()