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

java.lang.Object
  extended by edu.internet2.middleware.grouper.internal.dao.QueryPaging

public class QueryPaging
extends Object


Constructor Summary
QueryPaging()
           
QueryPaging(int pageSize1, int pageNumber1, boolean doTotalCount1)
          constructor.
 
Method Summary
 void assertInitted()
          throw exception if this bean is not initted
 void calculateIndexes()
          Based on the pageNumber, pageSize, and totalRecordCount, figure out the rest.
 List<Integer> getAllPages()
          This can be used to provide a drop down box of possible pages to skip to.
 int getFirstIndexOnPage()
          return the first index on page (0 indexed), from 0 to the number of results
 int getLastIndexOnPage()
          return the last index on page (0 indexed)
 int getNumberOfPages()
          getter for numberOfPages: number of pages total
 int getNumberOfResultsOnPage()
          Get the number of results on the current page
 int getPageEndIndex()
          getter for pageEndIndex: index (1 indexed) of the last record on the page
 int getPageNumber()
          getter for pageNumber: page number indexed by 1 (friendly)
 int getPageSize()
          getter for pageSize: the number of records per page
 int getPageStartIndex()
          getter for pageStartIndex: index of the first record on the first page, this was documented as 1 indexed, but it seems to be 0 indexed
 int getTotalOnLastPage()
          calculate the total record count on last page
 int getTotalRecordCount()
          getter for totalRecordCount: total number of records in the set (you must set this before the tag is called)
 boolean initted()
          see if this bean has been calculated
 boolean isCacheTotalCount()
          if we should cache the total count and not run again if already run
 boolean isDoTotalCount()
          if we should do the total count when we do that actual query (note, this might not always be possible in all cases, will throw an exception if not possible)
 boolean isFirstPage()
          see if the paging is on first page
 boolean isLastPage()
          see if the paging is on last page
 int nextPageNeeded(int currentPageNumber)
          based on a paging bean, and a current page, return the next page needed to display (ellipses, button, or label)
static QueryPaging page(int pageSize, int pageNumber, boolean doTotalCount)
          factory for query paging
 void setCacheTotalCount(boolean cacheTotalCount1)
          if we should cache the total count and not run again if already run
 void setDoTotalCount(boolean doTotalCount1)
          if we should do the total count when we do that actual query (note, this might not always be possible in all cases, will throw an exception if not possible)
 void setFirstIndexOnPage(int startIndex)
           set the first index on the page, 0 indexed 0 -> 1, pageSize -> 2, 2*pageSize -> 3
 void setNumberOfPages(int _numberOfPages)
          setter for numberOfPages: number of pages total
 void setPageEndIndex(int _pageEndIndex)
          setter for pageEndIndex: index (1 indexed) of the last record on the page
 void setPageNumber(int _pageNumber)
          pageNumber: page number indexed by 1 (friendly)
 void setPageSize(int _pageSize)
          setter for pageSize: the number of records per page
 void setPageStartIndex(int _pageStartIndex)
          setter for pageStartIndex: index of the first record on the first page, this was documented as 1 indexed, but it seems to be 0 indexed
 void setPageStartIndexQueryByIndex(int startIndex)
           set the first index on the page, 0 indexed, dont use pages to query...
 void setTotalRecordCount(int _totalRecordCount)
          setter for totalRecordCount: total number of records in the set (you must set this before the tag is called)
 boolean shouldPage()
          if we should page
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

QueryPaging

public QueryPaging()

QueryPaging

public QueryPaging(int pageSize1,
                   int pageNumber1,
                   boolean doTotalCount1)
constructor. NOTE, THIS IS 1 INDEXED ON PAGE NUMBER

Parameters:
pageSize1 - number of records per page
pageNumber1 - 1 indexed page number to show
doTotalCount1 - if hibernate session should do a total count and calculate indexes when doing the query
Method Detail

getNumberOfPages

public int getNumberOfPages()
getter for numberOfPages: number of pages total

Returns:
the value of the field

getPageEndIndex

public int getPageEndIndex()
getter for pageEndIndex: index (1 indexed) of the last record on the page

Returns:
the value of the field

getPageNumber

public int getPageNumber()
getter for pageNumber: page number indexed by 1 (friendly)

Returns:
the value of the field

getPageSize

public int getPageSize()
getter for pageSize: the number of records per page

Returns:
the value of the field

getPageStartIndex

public int getPageStartIndex()
getter for pageStartIndex: index of the first record on the first page, this was documented as 1 indexed, but it seems to be 0 indexed

Returns:
the value of the field

getTotalRecordCount

public int getTotalRecordCount()
getter for totalRecordCount: total number of records in the set (you must set this before the tag is called)

Returns:
the value of the field

setNumberOfPages

public void setNumberOfPages(int _numberOfPages)
setter for numberOfPages: number of pages total

Parameters:
_numberOfPages - is the data to set

setPageEndIndex

public void setPageEndIndex(int _pageEndIndex)
setter for pageEndIndex: index (1 indexed) of the last record on the page

Parameters:
_pageEndIndex - is the data to set

setPageSize

public void setPageSize(int _pageSize)
setter for pageSize: the number of records per page

Parameters:
_pageSize - is the data to set

setPageStartIndex

public void setPageStartIndex(int _pageStartIndex)
setter for pageStartIndex: index of the first record on the first page, this was documented as 1 indexed, but it seems to be 0 indexed

Parameters:
_pageStartIndex - is the data to set

setPageStartIndexQueryByIndex

public void setPageStartIndexQueryByIndex(int startIndex)
 set the first index on the page, 0 indexed, dont use pages to query...
 

Parameters:
startIndex -

setTotalRecordCount

public void setTotalRecordCount(int _totalRecordCount)
setter for totalRecordCount: total number of records in the set (you must set this before the tag is called)

Parameters:
_totalRecordCount - is the data to set

assertInitted

public void assertInitted()
throw exception if this bean is not initted


calculateIndexes

public void calculateIndexes()
Based on the pageNumber, pageSize, and totalRecordCount, figure out the rest. Pretty much everything is friendly / oracle indexed (by 1)


getAllPages

public List<Integer> getAllPages()
This can be used to provide a drop down box of possible pages to skip to. This is helpful for example if there are 30 pages and you want page 15, normally this would require numerous clicks before page 15 is displayed as a choice.

Returns:
a list of all the valid page numbers that could be referred to

getFirstIndexOnPage

public int getFirstIndexOnPage()
return the first index on page (0 indexed), from 0 to the number of results

Returns:
the first index on page 0 indexed

setFirstIndexOnPage

public void setFirstIndexOnPage(int startIndex)
 set the first index on the page, 0 indexed
 0 -> 1, pageSize -> 2, 2*pageSize -> 3
 

Parameters:
startIndex -

getLastIndexOnPage

public int getLastIndexOnPage()
return the last index on page (0 indexed)

Returns:
the last index on page 0 indexed

getNumberOfResultsOnPage

public int getNumberOfResultsOnPage()
Get the number of results on the current page

Returns:
number of results on current page

getTotalOnLastPage

public int getTotalOnLastPage()
calculate the total record count on last page

Returns:
total records on last page

initted

public boolean initted()
see if this bean has been calculated

Returns:
true if initted

isFirstPage

public boolean isFirstPage()
see if the paging is on first page

Returns:
true if first page

isLastPage

public boolean isLastPage()
see if the paging is on last page

Returns:
true if last page

nextPageNeeded

public int nextPageNeeded(int currentPageNumber)
based on a paging bean, and a current page, return the next page needed to display (ellipses, button, or label)

Parameters:
currentPageNumber -
Returns:
the next page number which is relevant

setPageNumber

public void setPageNumber(int _pageNumber)
pageNumber: page number indexed by 1 (friendly)

Parameters:
_pageNumber -

shouldPage

public boolean shouldPage()
if we should page

Returns:
if should page

page

public static QueryPaging page(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:
the query paging

toString

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

isDoTotalCount

public boolean isDoTotalCount()
if we should do the total count when we do that actual query (note, this might not always be possible in all cases, will throw an exception if not possible)

Returns:
true if we should do a total count

setDoTotalCount

public void setDoTotalCount(boolean doTotalCount1)
if we should do the total count when we do that actual query (note, this might not always be possible in all cases, will throw an exception if not possible)

Parameters:
doTotalCount1 -

isCacheTotalCount

public boolean isCacheTotalCount()
if we should cache the total count and not run again if already run

Returns:
if we should cache the total count

setCacheTotalCount

public void setCacheTotalCount(boolean cacheTotalCount1)
if we should cache the total count and not run again if already run

Parameters:
cacheTotalCount1 -