org.labkey.remoteapi.query
Class BaseQueryCommand<ResponseType extends CommandResponse>

java.lang.Object
  extended by org.labkey.remoteapi.Command<ResponseType>
      extended by org.labkey.remoteapi.query.BaseQueryCommand<ResponseType>
Direct Known Subclasses:
NAbRunsCommand, SelectRowsCommand

public abstract class BaseQueryCommand<ResponseType extends CommandResponse>
extends Command<ResponseType>

Created by IntelliJ IDEA. User: brittp Date: Jun 24, 2009 Time: 10:11:39 PM


Nested Class Summary
 
Nested classes/interfaces inherited from class org.labkey.remoteapi.Command
Command.CommonParameters
 
Field Summary
protected  ContainerFilter _containerFilter
           
protected  java.util.List<Filter> _filters
           
protected  int _maxRows
           
protected  int _offset
           
protected  java.util.List<Sort> _sorts
           
 
Fields inherited from class org.labkey.remoteapi.Command
CONTENT_TYPE_JSON
 
Constructor Summary
BaseQueryCommand(BaseQueryCommand<ResponseType> source)
           
BaseQueryCommand(java.lang.String controllerName, java.lang.String actionName)
           
 
Method Summary
 void addFilter(Filter filter)
          Adds a new filter to the list.
 void addFilter(java.lang.String columnName, java.lang.Object value, Filter.Operator operator)
          Constructs and adds a new filter to the list.
 void addSort(Sort sort)
          Adds a new sort definition to the current list.
 void addSort(java.lang.String columnName, Sort.Direction direction)
          Constructs and adds a new sort definition to the current list.
 ContainerFilter getContainerFilter()
          Returns the container filter set for this command
 java.util.List<Filter> getFilters()
          Returns the current list of filters, or null if none are defined.
 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.
protected  java.lang.String getSortQueryStringParam()
          Constructs the sort query string parameter from the current list of sort definitions.
 java.util.List<Sort> getSorts()
          Returns the current list of sort definitions.
 void setContainerFilter(ContainerFilter containerFilter)
          Sets the container filter for the sql to be executed.
 void setFilters(java.util.List<Filter> filters)
          Sets the current list of filters.
 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 setSorts(java.util.List<Sort> sorts)
          Sets the current set of sort definitions.
 
Methods inherited from class org.labkey.remoteapi.Command
copy, createMethod, createResponse, execute, getActionName, getActionUrl, getControllerName, getHttpMethod, getParamValueAsString, getQueryString, getRequiredVersion, getTimeout, setParameters, setRequiredVersion, setTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_maxRows

protected int _maxRows

_offset

protected int _offset

_sorts

protected java.util.List<Sort> _sorts

_filters

protected java.util.List<Filter> _filters

_containerFilter

protected ContainerFilter _containerFilter
Constructor Detail

BaseQueryCommand

public BaseQueryCommand(BaseQueryCommand<ResponseType> source)

BaseQueryCommand

public BaseQueryCommand(java.lang.String controllerName,
                        java.lang.String actionName)
Method Detail

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 first maxRows 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 with setMaxRows(int) to return pages of rows at a time from the server.

Parameters:
offset - The current offset index.

getSorts

public java.util.List<Sort> getSorts()
Returns the current list of sort definitions.

Returns:
The current list of sort definitions, or null if none are defined.

setSorts

public void setSorts(java.util.List<Sort> sorts)
Sets the current set of sort definitions.

Parameters:
sorts - The new list of sort definitions.

addSort

public void addSort(Sort sort)
Adds a new sort definition to the current list.

Parameters:
sort - The new sort definition.

addSort

public void addSort(java.lang.String columnName,
                    Sort.Direction direction)
Constructs and adds a new sort definition to the current list. This is equivallent to calling addSort(new Sort(columnName, direction))

Parameters:
columnName - The column name.
direction - The sort direction.
See Also:
Sort

getFilters

public java.util.List<Filter> getFilters()
Returns the current list of filters, or null if none are defined.

Returns:
The current list of filters.

setFilters

public void setFilters(java.util.List<Filter> filters)
Sets the current list of filters.

Parameters:
filters - The new list of filters.

addFilter

public void addFilter(Filter filter)
Adds a new filter to the list.

Parameters:
filter - The new filter definition.

addFilter

public void addFilter(java.lang.String columnName,
                      java.lang.Object value,
                      Filter.Operator operator)
Constructs and adds a new filter to the list. This is equivallent to addFilter(new Filter(columnName, value, operator))

Parameters:
columnName - The column name.
value - The filter value.
operator - The filter operator.
See Also:
Filter

getContainerFilter

public ContainerFilter getContainerFilter()
Returns the container filter set for this command

Returns:
the container filter (may be null)

setContainerFilter

public void setContainerFilter(ContainerFilter containerFilter)
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)

getSortQueryStringParam

protected java.lang.String getSortQueryStringParam()
Constructs the sort query string parameter from the current list of sort definitions. The sort query string parameter is in the form of [-]column,[-]column,... where the optional - is used for a descending sort direction.

Returns:
The sort query string parameter.

getParameters

public java.util.Map<java.lang.String,java.lang.Object> getParameters()
Description copied from class: Command
Returns the current parameter map, or null if a map has not yet been set. Derived classes will typically override this method to provide a parameter map based on data members set by specialized setter methods.

Overrides:
getParameters in class Command<ResponseType extends CommandResponse>
Returns:
The current parameter map.