edu.internet2.middleware.grouper.internal.dao
Class QueryOptions

java.lang.Object
  extended by 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 Summary
QueryOptions()
           
 
Method Summary
static QueryOptions create(String sortString, Boolean ascending, Integer pageNumber, Integer pageSize)
           
 Long getCount()
          count of the query if it is being calculated.
 QueryPaging getQueryPaging()
          If this is a paged query, and what are specs
 QuerySort getQuerySort()
          if this query is sorted (by options), and what the col(s) are
 Boolean getSecondLevelCache()
           
 String getSecondLevelCacheRegion()
           
static void initTotalCount(QueryOptions queryOptions)
           
 boolean isRetrieveCount()
          If the count of the query should be retrieved (sometimes paging will get the count) default to false
 boolean isRetrieveResults()
          If the results should be retrieved (generally only false for size queries).
 QueryOptions paging(int pageSize, int pageNumber, boolean doTotalCount)
          factory for query paging
 QueryOptions paging(QueryPaging queryPaging1)
          If this is a paged query, and what are specs
 QueryOptions retrieveCount(boolean retrieveCount1)
          If the count of the query should be retrieved (sometimes paging will get the count) default to false
 QueryOptions retrieveResults(boolean retrieveResults1)
          If the results should be retrieved (generally only false for size queries).
 QueryOptions secondLevelCache(boolean secondLevelCache1)
           
 QueryOptions secondLevelCacheRegion(String secondLevelCacheRegion1)
           
 void setCount(Long count1)
          count of the query if it is being calculated.
 QueryOptions sort(QuerySort querySort1)
          if this query is sorted (by options), and what the col(s) are
 QueryOptions sortAsc(String field)
          sort ascending on this field
 QueryOptions sortDesc(String field)
          sort ascending on this field
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryOptions

public QueryOptions()
Method Detail

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:
Object.toString()

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

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 -