Class QueryOptions

java.lang.Object
edu.internet2.middleware.grouper.internal.dao.QueryOptions

public class QueryOptions extends Object
 options on a query (e.g. sorting, paging, total result size, etc)
 
 Sorting example:
    queryOptions = new QueryOptions().sortAsc("m.subjectIdDb");

    Set<Member> members = group.getImmediateMembers(field, queryOptions);

 Paging example:
    QueryPaging queryPaging = new QueryPaging();
    queryPaging.setPageSize(pageSize);
    queryPaging.setPageNumber(pageNumberOneIndexed);
    -or- queryPaging.setFirstIndexOnPage(startZeroIndexed);
    queryOptions = new QueryOptions().paging(queryPaging);

    Set<Member> members = group.getImmediateMembers(field, queryOptions);

 Query count example:
 
    QueryOptions queryOptions = new QueryOptions().retrieveCount(true).retrieveResults(false);
    group.getImmediateMembers(field, queryOptions);
    int totalSize = queryOptions.getCount().intValue();
 
 
  • Constructor Details

    • QueryOptions

      public QueryOptions()
  • Method Details

    • needsCountQuery

      public static boolean needsCountQuery(QueryOptions queryOptions, int maxResults)
      see if paging is constraining the query so we dont need a separate count query
      Parameters:
      queryOptions -
      maxResults -
      Returns:
      true if needs extra count query
    • initTotalCount

      public static void initTotalCount(QueryOptions queryOptions)
      Parameters:
      queryOptions -
    • create

      public static QueryOptions create(String sortString, Boolean ascending, Integer pageNumber, Integer pageSize)
      Parameters:
      sortString -
      ascending -
      pageNumber - 1 indexed page number
      pageSize -
      Returns:
      the query options if needed
    • secondLevelCache

      public QueryOptions secondLevelCache(boolean secondLevelCache1)
      Parameters:
      secondLevelCache1 -
      Returns:
      this for chaining
    • getSecondLevelCache

      public Boolean getSecondLevelCache()
      Returns:
      if second level cache
    • secondLevelCacheRegion

      public QueryOptions secondLevelCacheRegion(String secondLevelCacheRegion1)
      Parameters:
      secondLevelCacheRegion1 -
      Returns:
      this for chaining
    • getSecondLevelCacheRegion

      public String getSecondLevelCacheRegion()
      Returns:
      if second level cache
    • toString

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • getQuerySort

      public QuerySort getQuerySort()
      if this query is sorted (by options), and what the col(s) are
      Returns:
      sort
    • sort

      public QueryOptions sort(QuerySort querySort1)
      if this query is sorted (by options), and what the col(s) are
      Parameters:
      querySort1 -
      Returns:
      this for chaining
    • getQueryPaging

      public QueryPaging getQueryPaging()
      If this is a paged query, and what are specs
      Returns:
      paging
    • sortAsc

      public QueryOptions sortAsc(String field)
      sort ascending on this field
      Parameters:
      field -
      Returns:
      this for chaining
    • paging

      public QueryOptions paging(int pageSize, int pageNumber, boolean doTotalCount)
      factory for query paging
      Parameters:
      pageSize -
      pageNumber - 1 indexed page number
      doTotalCount - true to do total count, false to not
      Returns:
      this for chaining
    • pagingCursor

      public QueryOptions pagingCursor(int pageSize, Object lastCursorField, boolean cursorFieldIncludesLastRetrieved, boolean doTotalCount)
      factory for query paging
      Parameters:
      pageSize -
      lastCursorField -
      cursorFieldIncludesLastRetrieved -
      doTotalCount - true to do total count, false to not
      Returns:
      this for chaining
    • sortDesc

      public QueryOptions sortDesc(String field)
      sort ascending on this field
      Parameters:
      field -
      Returns:
      this for chaining
    • paging

      public QueryOptions paging(QueryPaging queryPaging1)
      If this is a paged query, and what are specs
      Parameters:
      queryPaging1 -
      Returns:
      this for chaining
    • isRetrieveResults

      public boolean isRetrieveResults()
      If the results should be retrieved (generally only false for size queries). default to true
      Returns:
      retrieve results
    • retrieveResults

      public QueryOptions retrieveResults(boolean retrieveResults1)
      If the results should be retrieved (generally only false for size queries). default to true
      Parameters:
      retrieveResults1 -
      Returns:
      this for chaining
    • isRetrieveCount

      public boolean isRetrieveCount()
      If the count of the query should be retrieved (sometimes paging will get the count) default to false
      Returns:
      retrieve count
    • retrieveCount

      public QueryOptions retrieveCount(boolean retrieveCount1)
      If the count of the query should be retrieved (sometimes paging will get the count) default to false
      Parameters:
      retrieveCount1 -
      Returns:
      this for chaining
    • getCount

      public Long getCount()
      count of the query if it is being calculated. Note the hibernateSession API is what sets this
      Returns:
      the count or null if not set
    • setCount

      public void setCount(Long count1)
      count of the query if it is being calculated. Note the hibernateSession API is what sets this
      Parameters:
      count1 -