Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.platform.query.api
Class AbstractPageProvider<T>

java.lang.Object
  extended by org.nuxeo.ecm.platform.query.api.AbstractPageProvider<T>
All Implemented Interfaces:
java.io.Serializable, PageProvider<T>
Direct Known Subclasses:
CoreQueryAndFetchPageProvider, CoreQueryDocumentPageProvider, EmptyPageProvider

public abstract class AbstractPageProvider<T>
extends java.lang.Object
implements PageProvider<T>

Basic implementation for a PageProvider

Author:
Anahide Tchertchian
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.nuxeo.ecm.platform.query.api.PageProvider
UNKNOWN_SIZE
 
Constructor Summary
AbstractPageProvider()
           
 
Method Summary
 void addSortInfo(java.lang.String sortColumn, boolean sortAscending)
          Add the given sort info to the list of sorting infos.
 void firstPage()
          Go to the first page
 T getCurrentEntry()
          Returns the current entry.
abstract  java.util.List<T> getCurrentPage()
          Returns the current page of results.
 long getCurrentPageIndex()
          Returns the current page index as a zero-based integer.
 long getCurrentPageOffset()
          Returns the offset (starting from 0) of the first element in the current page or UNKNOWN_SIZE.
 long getCurrentPageSize()
          Returns the number of elements in current page.
 java.lang.String getCurrentPageStatus()
          Returns a simple formatted string for current pagination status.
 PageSelections<T> getCurrentSelectPage()
          Returns the current page of results wrapped in a PageSelection item.
 PageProviderDefinition getDefinition()
           
 java.lang.Throwable getError()
           
 java.lang.String getErrorMessage()
           
 java.lang.String getName()
          Returns the provider identifier
 long getNumberOfPages()
          Returns the total number of pages
 long getPageSize()
          Returns the number of results per page. 0 means no pagination.
 java.lang.Object[] getParameters()
           
 java.util.Map<java.lang.String,java.io.Serializable> getProperties()
          Gets properties set on the provider.
 long getResultsCount()
          Returns the number of result elements if available or UNKNOWN_SIZE if it is unknown.
 DocumentModel getSearchDocumentModel()
           
 SortInfo getSortInfo()
          Returns the first sorting info for this provider Also kept for compatibility with existing code.
 int getSortInfoIndex(java.lang.String sortColumn, boolean sortAscending)
          Returns a positive 0-based integer if given sort information is found on the set sort infos, indicating the sort index, or -1 if this sort information is not found.
 java.util.List<SortInfo> getSortInfos()
          Returns the complete list of sorting info for this provider
 boolean hasError()
           
 boolean isNextEntryAvailable()
          Tells if there is a next entry.
 boolean isNextPageAvailable()
          Returns a boolean expressing if there are further pages.
 boolean isPreviousEntryAvailable()
          Tells if there is a previous entry.
 boolean isPreviousPageAvailable()
          Returns a boolean expressing if there is a previous page.
 boolean isSortable()
          Returns if this provider is sortable
 void last()
           
 void lastPage()
          Go to the last page
 void next()
           
 void nextEntry()
          Move the current entry to the next one, if applicable If needed and possible, the provider will forward to next page.
 void nextPage()
          Go to the next page
 void previous()
           
 void previousEntry()
          Move the current entry to the previous one, if applicable No exception: this method is intended to be plugged directly at the UI layer.
 void previousPage()
          Go to the previous page
 void refresh()
          Forces refresh of the current page.
 void rewind()
           
 void setCurrentEntry(T entry)
          Sets the current entry.
 void setCurrentEntryIndex(long index)
          Sets the current entry index.
 java.util.List<T> setCurrentPage(long page)
          Sets the current page of results to the required one and return it.
 void setDefinition(PageProviderDefinition providerDefinition)
           
 void setName(java.lang.String name)
          Sets the provider identifier
 void setPageSize(long pageSize)
          Sets the number results per page. 0 means no pagination.
 void setParameters(java.lang.Object[] parameters)
           
 void setProperties(java.util.Map<java.lang.String,java.io.Serializable> properties)
          Sets properties set on the provider.
 void setResultsCount(long resultsCount)
           
 void setSearchDocumentModel(DocumentModel searchDocumentModel)
           
 void setSelectedEntries(java.util.List<T> entries)
          Sets the list of selected entries to take into account in PageProvider.getCurrentSelectPage().
 void setSortable(boolean sortable)
           
 void setSortInfo(SortInfo sortInfo)
          Sets the first and only sorting info for this provider.
 void setSortInfo(java.lang.String sortColumn, boolean sortAscending, boolean removeOtherSortInfos)
          Sets the first and only sorting info for this provider if parameter removeOtherSortInfos is true.
 void setSortInfos(java.util.List<SortInfo> sortInfo)
          Sets the complete list of sorting info for this provider
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPageProvider

public AbstractPageProvider()
Method Detail

getCurrentPage

public abstract java.util.List<T> getCurrentPage()
Description copied from interface: PageProvider
Returns the current page of results.

This method is designed to be called from higher levels. It therefore ensures cheapness of repeated calls, rather than data consistency. There is a refresh() method for that.

Specified by:
getCurrentPage in interface PageProvider<T>
Returns:
the current page

firstPage

public void firstPage()
Description copied from interface: PageProvider
Go to the first page

Specified by:
firstPage in interface PageProvider<T>

rewind

public void rewind()

getCurrentPageIndex

public long getCurrentPageIndex()
Description copied from interface: PageProvider
Returns the current page index as a zero-based integer.

Specified by:
getCurrentPageIndex in interface PageProvider<T>

getCurrentPageOffset

public long getCurrentPageOffset()
Description copied from interface: PageProvider
Returns the offset (starting from 0) of the first element in the current page or UNKNOWN_SIZE.

Specified by:
getCurrentPageOffset in interface PageProvider<T>

getCurrentPageSize

public long getCurrentPageSize()
Description copied from interface: PageProvider
Returns the number of elements in current page.

Specified by:
getCurrentPageSize in interface PageProvider<T>

getName

public java.lang.String getName()
Description copied from interface: PageProvider
Returns the provider identifier

Specified by:
getName in interface PageProvider<T>

getNumberOfPages

public long getNumberOfPages()
Description copied from interface: PageProvider
Returns the total number of pages

Specified by:
getNumberOfPages in interface PageProvider<T>

setCurrentPage

public java.util.List<T> setCurrentPage(long page)
Description copied from interface: PageProvider
Sets the current page of results to the required one and return it.

Specified by:
setCurrentPage in interface PageProvider<T>
Parameters:
page - the page index, starting from 0

getPageSize

public long getPageSize()
Description copied from interface: PageProvider
Returns the number of results per page. 0 means no pagination.

Specified by:
getPageSize in interface PageProvider<T>

setPageSize

public void setPageSize(long pageSize)
Description copied from interface: PageProvider
Sets the number results per page. 0 means no pagination.

Specified by:
setPageSize in interface PageProvider<T>

getSortInfos

public java.util.List<SortInfo> getSortInfos()
Description copied from interface: PageProvider
Returns the complete list of sorting info for this provider

Specified by:
getSortInfos in interface PageProvider<T>

getSortInfo

public SortInfo getSortInfo()
Description copied from interface: PageProvider
Returns the first sorting info for this provider

Also kept for compatibility with existing code.

Specified by:
getSortInfo in interface PageProvider<T>

setSortInfos

public void setSortInfos(java.util.List<SortInfo> sortInfo)
Description copied from interface: PageProvider
Sets the complete list of sorting info for this provider

Specified by:
setSortInfos in interface PageProvider<T>

setSortInfo

public void setSortInfo(SortInfo sortInfo)
Description copied from interface: PageProvider
Sets the first and only sorting info for this provider.

Also kept for compatibility with existing code.

Specified by:
setSortInfo in interface PageProvider<T>

setSortInfo

public void setSortInfo(java.lang.String sortColumn,
                        boolean sortAscending,
                        boolean removeOtherSortInfos)
Description copied from interface: PageProvider
Sets the first and only sorting info for this provider if parameter removeOtherSortInfos is true. Otherwise, adds or changes the sortAscending information according to given direction.

Specified by:
setSortInfo in interface PageProvider<T>

addSortInfo

public void addSortInfo(java.lang.String sortColumn,
                        boolean sortAscending)
Description copied from interface: PageProvider
Add the given sort info to the list of sorting infos.

Specified by:
addSortInfo in interface PageProvider<T>

getSortInfoIndex

public int getSortInfoIndex(java.lang.String sortColumn,
                            boolean sortAscending)
Description copied from interface: PageProvider
Returns a positive 0-based integer if given sort information is found on the set sort infos, indicating the sort index, or -1 if this sort information is not found.

Specified by:
getSortInfoIndex in interface PageProvider<T>

isNextPageAvailable

public boolean isNextPageAvailable()
Description copied from interface: PageProvider
Returns a boolean expressing if there are further pages.

Specified by:
isNextPageAvailable in interface PageProvider<T>

isPreviousPageAvailable

public boolean isPreviousPageAvailable()
Description copied from interface: PageProvider
Returns a boolean expressing if there is a previous page.

Specified by:
isPreviousPageAvailable in interface PageProvider<T>

lastPage

public void lastPage()
Description copied from interface: PageProvider
Go to the last page

Specified by:
lastPage in interface PageProvider<T>

last

public void last()

nextPage

public void nextPage()
Description copied from interface: PageProvider
Go to the next page

Specified by:
nextPage in interface PageProvider<T>

next

public void next()

previousPage

public void previousPage()
Description copied from interface: PageProvider
Go to the previous page

Specified by:
previousPage in interface PageProvider<T>

previous

public void previous()

refresh

public void refresh()
Description copied from interface: PageProvider
Forces refresh of the current page.

Specified by:
refresh in interface PageProvider<T>

setName

public void setName(java.lang.String name)
Description copied from interface: PageProvider
Sets the provider identifier

Specified by:
setName in interface PageProvider<T>

getCurrentPageStatus

public java.lang.String getCurrentPageStatus()
Description copied from interface: PageProvider
Returns a simple formatted string for current pagination status.

Specified by:
getCurrentPageStatus in interface PageProvider<T>

isNextEntryAvailable

public boolean isNextEntryAvailable()
Description copied from interface: PageProvider
Tells if there is a next entry.

The next entry might be in next page. If no current entry is set, this returns false.

Specified by:
isNextEntryAvailable in interface PageProvider<T>

isPreviousEntryAvailable

public boolean isPreviousEntryAvailable()
Description copied from interface: PageProvider
Tells if there is a previous entry.

The next entry might be in next page. If no current entry is set, this returns false.

Specified by:
isPreviousEntryAvailable in interface PageProvider<T>

nextEntry

public void nextEntry()
Description copied from interface: PageProvider
Move the current entry to the next one, if applicable

If needed and possible, the provider will forward to next page. No special exceptions: this method is intended to be plugged directly at the UI layer. In case there's no next entry, nothing happens.

Specified by:
nextEntry in interface PageProvider<T>

previousEntry

public void previousEntry()
Description copied from interface: PageProvider
Move the current entry to the previous one, if applicable

No exception: this method is intended to be plugged directly at the UI layer. In case there's no previous entry, nothing will happen.

Specified by:
previousEntry in interface PageProvider<T>

getCurrentEntry

public T getCurrentEntry()
Description copied from interface: PageProvider
Returns the current entry.

Specified by:
getCurrentEntry in interface PageProvider<T>

setCurrentEntry

public void setCurrentEntry(T entry)
                     throws ClientException
Description copied from interface: PageProvider
Sets the current entry.

Specified by:
setCurrentEntry in interface PageProvider<T>
Throws:
ClientException - if entry is not found within current page.

setCurrentEntryIndex

public void setCurrentEntryIndex(long index)
                          throws ClientException
Description copied from interface: PageProvider
Sets the current entry index.

Specified by:
setCurrentEntryIndex in interface PageProvider<T>
Throws:
ClientException - if index is not found within current page.

getResultsCount

public long getResultsCount()
Description copied from interface: PageProvider
Returns the number of result elements if available or UNKNOWN_SIZE if it is unknown.

Specified by:
getResultsCount in interface PageProvider<T>

getProperties

public java.util.Map<java.lang.String,java.io.Serializable> getProperties()
Description copied from interface: PageProvider
Gets properties set on the provider.

Useful to retrieve a provider specific field attributes after instantiation. Other contextual parameters can be passed through API constructing the result provider.

Specified by:
getProperties in interface PageProvider<T>

setProperties

public void setProperties(java.util.Map<java.lang.String,java.io.Serializable> properties)
Description copied from interface: PageProvider
Sets properties set on the provider.

Useful to initialize a provider specific field attributes after instantiation. Other contextual parameters can be passed through API constructing the result provider.

Specified by:
setProperties in interface PageProvider<T>

setResultsCount

public void setResultsCount(long resultsCount)
Specified by:
setResultsCount in interface PageProvider<T>

setSortable

public void setSortable(boolean sortable)
Specified by:
setSortable in interface PageProvider<T>

isSortable

public boolean isSortable()
Description copied from interface: PageProvider
Returns if this provider is sortable

Specified by:
isSortable in interface PageProvider<T>

getCurrentSelectPage

public PageSelections<T> getCurrentSelectPage()
Description copied from interface: PageProvider
Returns the current page of results wrapped in a PageSelection item.

By default, no entry is selected, unless PageProvider.setSelectedEntries(List) has been called before.

Specified by:
getCurrentSelectPage in interface PageProvider<T>

setSelectedEntries

public void setSelectedEntries(java.util.List<T> entries)
Description copied from interface: PageProvider
Sets the list of selected entries to take into account in PageProvider.getCurrentSelectPage().

Specified by:
setSelectedEntries in interface PageProvider<T>

getParameters

public java.lang.Object[] getParameters()
Specified by:
getParameters in interface PageProvider<T>

setParameters

public void setParameters(java.lang.Object[] parameters)
Specified by:
setParameters in interface PageProvider<T>

getSearchDocumentModel

public DocumentModel getSearchDocumentModel()
Specified by:
getSearchDocumentModel in interface PageProvider<T>

setSearchDocumentModel

public void setSearchDocumentModel(DocumentModel searchDocumentModel)
Specified by:
setSearchDocumentModel in interface PageProvider<T>

getErrorMessage

public java.lang.String getErrorMessage()
Specified by:
getErrorMessage in interface PageProvider<T>

getError

public java.lang.Throwable getError()
Specified by:
getError in interface PageProvider<T>

hasError

public boolean hasError()
Specified by:
hasError in interface PageProvider<T>

getDefinition

public PageProviderDefinition getDefinition()
Specified by:
getDefinition in interface PageProvider<T>

setDefinition

public void setDefinition(PageProviderDefinition providerDefinition)
Specified by:
setDefinition in interface PageProvider<T>

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.