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>
  • Field Details

    • _maxRows

      protected int _maxRows
    • _offset

      protected int _offset
    • _sorts

      protected List<Sort> _sorts
    • _filters

      protected List<Filter> _filters
    • _containerFilter

      protected ContainerFilter _containerFilter
  • Constructor Details

    • BaseQueryCommand

      public BaseQueryCommand(String controllerName, String actionName)
  • 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 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 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(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(String columnName, Sort.Direction direction)
      Constructs and adds a new sort definition to the current list. This is equivalent to calling addSort(new Sort(columnName, direction))
      Parameters:
      columnName - The column name.
      direction - The sort direction.
      See Also:
    • getFilters

      public 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(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(String columnName, Object value, Filter.Operator operator)
      Constructs and adds a new filter to the list. This is equivalent to addFilter(new Filter(columnName, value, operator))
      Parameters:
      columnName - The column name.
      value - The filter value.
      operator - The filter operator.
      See Also:
    • 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)
    • 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

      public Map<String,String> getQueryParameters()
      Returns:
      Map of name (string)/value pairs for the values of parameters if the SQL references underlying queries that are parameterized.
    • setQueryParameters

      public 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.
      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 class PostCommand<ResponseType extends CommandResponse>
      Returns:
      The JSON object to post.