Package org.labkey.remoteapi.query
Class BaseQueryCommand<ResponseType extends CommandResponse>
java.lang.Object
org.labkey.remoteapi.Command<ResponseType,org.apache.hc.client5.http.classic.methods.HttpPost>
org.labkey.remoteapi.PostCommand<ResponseType>
org.labkey.remoteapi.query.BaseQueryCommand<ResponseType>
- All Implemented Interfaces:
HasRequiredVersion
- Direct Known Subclasses:
NAbRunsCommand
,SelectRowsCommand
public abstract class BaseQueryCommand<ResponseType extends CommandResponse>
extends PostCommand<ResponseType>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.labkey.remoteapi.Command
Command.CommonParameters, Command.Response
-
Field Summary
FieldsFields inherited from class org.labkey.remoteapi.Command
CONTENT_TYPE_JSON
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addFilter
(String columnName, Object value, Filter.Operator operator) Constructs and adds a new filter to the list.void
Adds a new filter to the list.void
addSort
(String columnName, Sort.Direction direction) Constructs and adds a new sort definition to the current list.void
Adds a new sort definition to the current list.Returns the container filter set for this commandReturns the current list of filters, or null if none are defined.org.json.JSONObject
Returns the JSON object to post or null for no JSON.int
Returns the current row limit value.int
Returns the index of the first row in the resultset to return (defaults to 0).getSorts()
Returns the current list of sort definitions.boolean
boolean
boolean
void
setContainerFilter
(ContainerFilter containerFilter) Sets the container filter for the sql to be executed.void
setFilters
(List<Filter> filters) Sets the current list of filters.void
setIgnoreFilter
(boolean ignoreFilter) Pass true to ignore any filter that may be part of the chosen view.void
setIncludeMetadata
(boolean includeMetadata) Pass false to omit metadata for the selected columns.void
setIncludeTotalCount
(boolean includeTotalCount) Pass false to omit total count from the response.void
setMaxRows
(int maxRows) Sets the current row limit value.void
setOffset
(int offset) Sets the index of the first row in the resultset to return from the server.void
setQueryParameters
(Map<String, String> parameters) Map of name (string)/value pairs for the values of parameters if the SQL references underlying queries that are parameterized.void
Sets the current set of sort definitions.Methods inherited from class org.labkey.remoteapi.PostCommand
createRequest
Methods inherited from class org.labkey.remoteapi.Command
_execute, createParameterMap, createResponse, execute, getActionName, getControllerName, getHttpRequest, getParameters, getParamValueAsString, getRequiredVersion, getTimeout, setRequiredVersion, setTimeout
-
Field Details
-
_maxRows
protected int _maxRows -
_offset
protected int _offset -
_sorts
-
_filters
-
_containerFilter
-
-
Constructor Details
-
BaseQueryCommand
-
-
Method Details
-
getMaxRows
public int getMaxRows()Returns the current row limit value. Defaults to -1, meaning return all rows.- Returns:
- The current row limit value.
-
setMaxRows
public void setMaxRows(int maxRows) Sets the current row limit value. If this is set to a positive value, only the firstmaxRows
rows will be returned from the server.- Parameters:
maxRows
- The maximum number of rows to return, or -1 to get all rows (default)
-
getOffset
public int getOffset()Returns the index of the first row in the resultset to return (defaults to 0).- Returns:
- The current offset index.
-
setOffset
public void setOffset(int offset) Sets the index of the first row in the resultset to return from the server. Use this in conjunction withsetMaxRows(int)
to return pages of rows at a time from the server.- Parameters:
offset
- The current offset index.
-
getSorts
Returns the current list of sort definitions.- Returns:
- The current list of sort definitions, or null if none are defined.
-
setSorts
Sets the current set of sort definitions.- Parameters:
sorts
- The new list of sort definitions.
-
addSort
Adds a new sort definition to the current list.- Parameters:
sort
- The new sort definition.
-
addSort
Constructs and adds a new sort definition to the current list. This is equivalent to callingaddSort(new Sort(columnName, direction))
- Parameters:
columnName
- The column name.direction
- The sort direction.- See Also:
-
getFilters
Returns the current list of filters, or null if none are defined.- Returns:
- The current list of filters.
-
setFilters
Sets the current list of filters.- Parameters:
filters
- The new list of filters.
-
addFilter
Adds a new filter to the list.- Parameters:
filter
- The new filter definition.
-
addFilter
Constructs and adds a new filter to the list. This is equivalent toaddFilter(new Filter(columnName, value, operator))
- Parameters:
columnName
- The column name.value
- The filter value.operator
- The filter operator.- See Also:
-
getContainerFilter
Returns the container filter set for this command- Returns:
- the container filter (may be null)
-
setContainerFilter
Sets the container filter for the sql to be executed. This will cause the query to be executed over more than one container.- Parameters:
containerFilter
- the filter to apply to the query (may be null)
-
isIgnoreFilter
public boolean isIgnoreFilter() -
setIgnoreFilter
public void setIgnoreFilter(boolean ignoreFilter) Pass true to ignore any filter that may be part of the chosen view. Defaults to false.- Parameters:
ignoreFilter
- Set to 'true' to ignore the view filter.
-
isIncludeMetadata
public boolean isIncludeMetadata() -
setIncludeMetadata
public void setIncludeMetadata(boolean includeMetadata) Pass false to omit metadata for the selected columns. Defaults to true.- Parameters:
includeMetadata
- Set to 'false' to omit column metadata.
-
isIncludeTotalCount
public boolean isIncludeTotalCount() -
setIncludeTotalCount
public void setIncludeTotalCount(boolean includeTotalCount) Pass false to omit total count from the response. Default is true.- Parameters:
includeTotalCount
- Set to 'false' to omit total count.
-
getQueryParameters
- Returns:
- Map of name (string)/value pairs for the values of parameters if the SQL references underlying queries that are parameterized.
-
setQueryParameters
Map of name (string)/value pairs for the values of parameters if the SQL references underlying queries that are parameterized.- Parameters:
parameters
- the set of parameters
-
getJsonObject
public org.json.JSONObject getJsonObject()Description copied from class:PostCommand
Returns the JSON object to post or null for no JSON. Override this method to provide parameters as JSON.- Overrides:
getJsonObject
in classPostCommand<ResponseType extends CommandResponse>
- Returns:
- The JSON object to post.
-