public class ExecuteSqlCommand extends PostCommand<SelectRowsResponse> implements BaseSelect
LabKey SQL is variant of standard SQL that supports most of the SELECT-related operations. For more information on LabKey SQL, see the following page:
https://www.labkey.org/Documentation/wiki-page.view?name=labkeySql
The response of this command is exactly the same as the
SelectRowsCommand
, so the response object
will be of type SelectRowsResponse
.
Command.CommonParameters, Command.Response
CONTENT_TYPE_JSON
Constructor and Description |
---|
ExecuteSqlCommand(ExecuteSqlCommand source) |
ExecuteSqlCommand(java.lang.String schemaName)
Constructs an ExecuteSqlCommand, initialized with a schema name.
|
ExecuteSqlCommand(java.lang.String schemaName,
java.lang.String sql)
Constructs an ExecuteSqlCommand, initialized with a schema name and SQL query.
|
Modifier and Type | Method and Description |
---|---|
ExecuteSqlCommand |
copy()
Returns a copy of this object.
|
protected SelectRowsResponse |
createResponse(java.lang.String text,
int status,
java.lang.String contentType,
org.json.simple.JSONObject json)
Creates an instance of the response class, initialized with
the response text, the HTTP status code, and parsed JSONObject.
|
ContainerFilter |
getContainerFilter()
Returns the container filter set for this command
|
org.json.simple.JSONObject |
getJsonObject()
Returns the JSON object to post, or null if the JSON object
has not yet been set.
|
int |
getMaxRows()
Returns the current row limit value.
|
int |
getOffset()
Returns the index of the first row in the resultset to return (defaults to 0).
|
java.util.Map<java.lang.String,java.lang.Object> |
getParameters()
Returns the current parameter map, or null if a map has not yet been set.
|
java.util.Map<java.lang.String,java.lang.String> |
getQueryParameters()
Map of name (string)/value pairs for the values of parameters if the SQL references underlying queries
that are parameterized.
|
java.lang.String |
getSchemaName()
Returns the current schema name.
|
java.util.List<Sort> |
getSorts()
A sort specification to apply over the rows returned by the SQL.
|
java.lang.String |
getSql()
Returns the current SQL query.
|
boolean |
isExtendedFormat()
Returns whether the extended format will be requested.
|
boolean |
isIncludeDetailsColumn()
Include the Details link column in the set of columns (defaults to false).
|
boolean |
isIncludeTotalCount()
Include the total number of rows available (defaults to true).
|
boolean |
isSaveInSession()
Whether or not the definition of this query should be stored for reuse during the current session.
|
void |
setContainerFilter(ContainerFilter containerFilter)
Sets the container filter for the sql to be executed.
|
void |
setExtendedFormat(boolean extendedFormat)
Set to true to request the extended response format, which includes URLs, Missing-Value indicators and
display values in addition to the raw values.
|
void |
setIncludeDetailsColumn(boolean includeDetailsColumn)
Include the Details link column in the set of columns (defaults to false).
|
void |
setIncludeTotalCount(boolean includeTotalCount)
Include the total number of rows available (defaults to true).
|
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(java.util.Map<java.lang.String,java.lang.String> parameters)
Map of name (string)/value pairs for the values of parameters if the SQL references underlying queries
that are parameterized.
|
void |
setSaveInSession(boolean saveInSession)
Whether or not the definition of this query should be stored for reuse during the current session.
|
void |
setSchemaName(java.lang.String schemaName)
Sets the current schema name.
|
void |
setSort(java.util.List<Sort> sorts)
A sort specification to apply over the rows returned by the SQL.
|
void |
setSql(java.lang.String sql)
Sets the SQL query to execute.
|
createRequest, setJsonObject
_execute, checkThrowError, execute, getActionName, getActionUrl, getControllerName, getHttpRequest, getParamValueAsString, getQueryString, getRequiredVersion, getTimeout, setParameters, setRequiredVersion, setTimeout
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
execute, getRequiredVersion, setRequiredVersion
public ExecuteSqlCommand(java.lang.String schemaName)
When using this constructor, you must call the setSql(String)
method before executing the command.
schemaName
- The schema name to query.public ExecuteSqlCommand(ExecuteSqlCommand source)
public ExecuteSqlCommand(java.lang.String schemaName, java.lang.String sql)
schemaName
- The schema name ot query.sql
- The SQL query.public void setExtendedFormat(boolean extendedFormat)
extendedFormat
- True to get the extended format.public boolean isExtendedFormat()
public java.lang.String getSchemaName()
public void setSchemaName(java.lang.String schemaName)
schemaName
- The new schema name to query.public java.lang.String getSql()
public void setSql(java.lang.String sql)
sql
- The new SQL query.public int getMaxRows()
getMaxRows
in interface BaseSelect
public void setMaxRows(int maxRows)
maxRows
rows will be returned from the server.setMaxRows
in interface BaseSelect
maxRows
- The maximim number of rows to return, or -1 to get all rows (default).public int getOffset()
getOffset
in interface BaseSelect
public void setOffset(int offset)
setMaxRows(int)
to return pages of
rows at a time from the server.setOffset
in interface BaseSelect
offset
- The current offset index.public boolean isIncludeTotalCount()
public void setIncludeTotalCount(boolean includeTotalCount)
includeTotalCount
- setting for whether to include the total countpublic java.util.List<Sort> getSorts()
public void setSort(java.util.List<Sort> sorts)
sorts
- the sort specifications to apply to the querypublic boolean isSaveInSession()
public void setSaveInSession(boolean saveInSession)
saveInSession
- indication of whether to save in session or notpublic boolean isIncludeDetailsColumn()
public void setIncludeDetailsColumn(boolean includeDetailsColumn)
includeDetailsColumn
- indication of whether to include the details column or notpublic java.util.Map<java.lang.String,java.lang.String> getQueryParameters()
public void setQueryParameters(java.util.Map<java.lang.String,java.lang.String> parameters)
parameters
- a map of the named parameters to use in the underlying parameterized queriespublic ContainerFilter getContainerFilter()
getContainerFilter
in interface BaseSelect
public void setContainerFilter(ContainerFilter containerFilter)
setContainerFilter
in interface BaseSelect
containerFilter
- the filter to apply to the query (may be null)protected SelectRowsResponse createResponse(java.lang.String text, int status, java.lang.String contentType, org.json.simple.JSONObject json)
Command
Override this method to create an instance of a different class that extends CommandResponse
createResponse
in class Command<SelectRowsResponse>
text
- The response text from the server.status
- The HTTP status code.contentType
- The Content-Type header value.json
- The parsed JSONObject (or null if no JSON was returned).public org.json.simple.JSONObject getJsonObject()
PostCommand
getJsonObject
in class PostCommand<SelectRowsResponse>
public ExecuteSqlCommand copy()
Command
copy
in class PostCommand<SelectRowsResponse>
public java.util.Map<java.lang.String,java.lang.Object> getParameters()
Command
getParameters
in class Command<SelectRowsResponse>