Class AbstractPageProvider<T>
- All Implemented Interfaces:
Serializable,PageProvider<T>
- Direct Known Subclasses:
AbstractGroupMemberPageProvider,AbstractGroupsPageProvider,AbstractUsersPageProvider,AuditPageProvider,CoreQueryAndFetchPageProvider,CoreQueryDocumentPageProvider,DirectoryEntryPageProvider,DocumentModelListPageProvider,EmptyPageProvider,LatestCreatedUsersOrGroupsPageProvider,MongoDBAuditPageProvider,OpenSearchAuditPageProvider,RoutingTaskPageProvider,SQLAuditPageProvider,UserTaskPageProvider,VFolderPageProvider
PageProvider.
Provides next/prev standard logics, and helper methods for retrieval of items and first/next/prev/last buttons display as well as other display information (number of pages for instance).
Also handles selection by providing a default implementation of getCurrentSelectPage() working in
conjunction with setSelectedEntries(List).
- Author:
- Anahide Tchertchian
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intInteger keeping track of the higher page index giving results.protected PageSelections<T> protected PageProviderDefinitionprotected Throwableprotected Stringprotected longprotected Stringprotected longstatic final Stringproperty used to enable globally tracking : property should contains the list of pageproviders to be trackedprotected PageProviderChangedListenerprotected longprotected Object[]protected Map<String, Serializable> protected List<QuickFilter> protected longprotected DocumentModellists schemas prefixes that should be skipped when extracting "search fields" (tracking) from searchDocumentModelprotected booleanprotected BooleanFields inherited from interface org.nuxeo.ecm.platform.query.api.PageProvider
DEFAULT_MAX_PAGE_SIZE, DEFAULT_MAX_PAGE_SIZE_RUNTIME_PROP, HIGHLIGHT_CTX_DATA, PAGE_LIMIT_UNKNOWN, SKIP_AGGREGATES_PROP, UNKNOWN_SIZE, UNKNOWN_SIZE_AFTER_QUERY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddQuickFilter(QuickFilter quickFilter) voidaddSortInfo(String sortColumn, boolean sortAscending) Add the given sort info to the list of sorting infos.protected voidfireSearchEvent(NuxeoPrincipal principal, String query, List<T> entries, Long executionTimeMs) Send a search event so that PageProvider calls can be tracked by Audit or other statistic gathering processvoidGo to the first pageprotected booleangetBooleanProperty(String propName, boolean defaultValue) Returns the current entry.intReturns an integer keeping track of the higher page index giving results.Returns the list of current page items.longReturns the current page index as a zero-based integer.longReturns the offset (starting from 0) of the first element in the current page orUNKNOWN_SIZE.longReturns the number of elements in current page.Returns a simple formatted string for current pagination status.Returns the current page of results wrapped in aPageSelectionitem.protected longgetError()intReturns the maximum number of empty pages that can be fetched empty (defaults to 1).longReturns the max number of results per page. 0 means no pagination.longReturns the minimal value for the max page size, taking the lower value between the requested page size and the maximum accepted page size.getName()Returns the provider identifierlongReturns the total number of pages or 0 if number of pages is unknown.longReturns the page limit.longReturns the number of results per page. 0 means no pagination unlessPageProvider.getMaxPageSize()is greater than this value, it will be taken into account instead.Returns a list of available page size options to display in the page size selector.Object[]protected booleangetParametersChanged(Object[] oldParams, Object[] newParams) Gets properties set on the provider.longReturns the number of result elements if available or a negative value if it is unknown:UNKNOWN_SIZEif it is unknown as query was not done, and since 5.5,UNKNOWN_SIZE_AFTER_QUERYif it is still unknown after query was done.longLimit of number of results beyond which the page provider may not be able to computePageProvider.getResultsCount()or navigate.Returns the first sorting info for this providerintgetSortInfoIndex(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.Returns the complete list of sorting info for this providerbooleanbooleanhasChangedParameters(Object[] parameters) Test if provider parameters have changedbooleanhasError()protected voidincorporateAggregates(Map<String, Serializable> eventProps) Default (dummy) implementation that should be overridden by PageProvider actually dealing with AggregatesbooleanReturns a boolean expressing if the last page can be displayed.booleanReturns true if there is a next entry.booleanReturns a boolean expressing if there are further pages.booleanReturns true if there is a previous entry.booleanReturns a boolean expressing if there is a previous page.booleanbooleanReturns if this provider is sortableprotected booleanvoidlastPage()Go to the last page.voidMove the current entry to the next one, if applicable.voidnextPage()Go to the next pageprotected voidCall the registeredPageProviderChangedListener, if any, to notify that the page provider current page has changed.protected voidCall the registeredPageProviderChangedListener, if any, to notify that the page provider has refreshed.protected voidPage change hook, to override for custom behaviorvoidMove the current entry to the previous one, if applicable.voidGo to the previous pagevoidrefresh()Refresh hook, to override for custom behaviorprotected booleansearchDocumentModelChanged(DocumentModel oldDoc, DocumentModel newDoc) voidsetCurrentEntry(T entry) Sets the current entry.voidsetCurrentEntryIndex(long index) Sets the current entry index.voidsetCurrentHigherNonEmptyPageIndex(int higherFilledPageIndex) setCurrentPage(long page) Sets the current page of results to the required one and return it.voidsetCurrentPageIndex(long currentPageIndex) Sets the current page of results to the required one.voidsetCurrentPageOffset(long offset) Sets the current page offset.voidsetDefinition(PageProviderDefinition providerDefinition) voidsetHighlights(List<String> highlights) voidsetMaxPageSize(long maxPageSize) Sets the max number of results per page. 0 means no pagination.voidSets the provider identifiervoidSets thePageProviderChangedListenerfor thisPageProvider.voidsetPageSize(long pageSize) Sets the number of results per page. 0 means no pagination unlessPageProvider.getMaxPageSize()is greater than this value, it will be taken into account instead.voidsetPageSizeOptions(List<Long> options) Sets the page size options.voidsetParameters(Object[] parameters) voidsetProperties(Map<String, Serializable> properties) Sets properties set on the provider.voidsetQuickFilters(List<QuickFilter> quickFilters) voidsetResultsCount(long resultsCount) Sets the results count.voidsetSearchDocumentModel(DocumentModel searchDocumentModel) voidsetSelectedEntries(List<T> entries) Sets the list of selected entries to take into account inPageProvider.getCurrentSelectPage().voidsetSortable(boolean sortable) voidsetSortInfo(String sortColumn, boolean sortAscending, boolean removeOtherSortInfos) Sets the first and only sorting info for this provider if parameter removeOtherSortInfos is true.voidsetSortInfo(SortInfo sortInfo) Sets the first and only sorting info for this provider.voidsetSortInfos(List<SortInfo> sortInfo) Sets the complete list of sorting info for this providerprotected booleansortInfoChanged(List<SortInfo> oldSortInfos, List<SortInfo> newSortInfos) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.platform.query.api.PageProvider
getScroller
-
Field Details
-
PAGEPROVIDER_TRACK_PROPERTY_NAME
property used to enable globally tracking : property should contains the list of pageproviders to be tracked- Since:
- 7.4
- See Also:
-
SKIPPED_SCHEMAS_FOR_SEARCHFIELD
lists schemas prefixes that should be skipped when extracting "search fields" (tracking) from searchDocumentModel- Since:
- 7.4
-
name
-
offset
protected long offset -
pageSize
protected long pageSize -
pageSizeOptions
-
maxPageSize
protected long maxPageSize -
resultsCount
protected long resultsCount -
currentEntryIndex
protected int currentEntryIndex -
currentHigherNonEmptyPageIndex
protected int currentHigherNonEmptyPageIndexInteger keeping track of the higher page index giving results. Useful for enabling or disabling the nextPage action when number of results cannot be known.- Since:
- 5.5
-
sortInfos
-
sortable
protected boolean sortable -
selectedEntries
-
currentSelectPage
-
properties
-
parameters
-
searchDocumentModel
-
quickFilters
- Since:
- 8.4
-
highlights
-
errorMessage
-
error
-
definition
-
pageProviderChangedListener
-
tracking
-
-
Constructor Details
-
AbstractPageProvider
public AbstractPageProvider()
-
-
Method Details
-
getCurrentPage
Returns the list of current page items.Custom implementation can be added here, based on the page provider properties, parameters and
WhereClauseDefinitionon thePageProviderDefinition, as well as search document, sort information, etc...Implementation of this method usually consists in setting a non-null value to a field caching current items, and nullifying this field by overriding
pageChanged()andrefresh().Fields
errorMessageanderrorcan also be filled to provide accurate feedback in case an error occurs during the search.When items are retrieved, a call to
setResultsCount(long)should be made to ensure proper pagination as implemented in this abstract class. The implementation inCoreQueryAndFetchPageProvideris a good example when the total results count is known.If for performance reasons, for instance, the number of results cannot be known, a fall-back strategy can be applied to provide the "next" button but not the "last" one, by calling
getCurrentHigherNonEmptyPageIndex()andsetCurrentHigherNonEmptyPageIndex(int). In this case,CoreQueryDocumentPageProvideris a good example.- Specified by:
getCurrentPagein interfacePageProvider<T>- Returns:
- the current page
-
pageChanged
protected void pageChanged()Page change hook, to override for custom behaviorWhen overriding it, call
super.pageChanged()as last statement to make sure that thePageProviderChangedListeneris called with the up-to-date @{code PageProvider} state. -
firstPage
public void firstPage()Description copied from interface:PageProviderGo to the first page- Specified by:
firstPagein interfacePageProvider<T>
-
getCurrentPageIndex
public long getCurrentPageIndex()Description copied from interface:PageProviderReturns the current page index as a zero-based integer.- Specified by:
getCurrentPageIndexin interfacePageProvider<T>
-
getCurrentPageOffset
public long getCurrentPageOffset()Description copied from interface:PageProviderReturns the offset (starting from 0) of the first element in the current page orUNKNOWN_SIZE.- Specified by:
getCurrentPageOffsetin interfacePageProvider<T>
-
setCurrentPageOffset
public void setCurrentPageOffset(long offset) Description copied from interface:PageProviderSets the current page offset.If the provider keeps information linked to the current page, they should be reset after calling this method.
- Specified by:
setCurrentPageOffsetin interfacePageProvider<T>
-
getCurrentPageSize
public long getCurrentPageSize()Description copied from interface:PageProviderReturns the number of elements in current page.- Specified by:
getCurrentPageSizein interfacePageProvider<T>
-
getName
Description copied from interface:PageProviderReturns the provider identifier- Specified by:
getNamein interfacePageProvider<T>
-
getNumberOfPages
public long getNumberOfPages()Description copied from interface:PageProviderReturns the total number of pages or 0 if number of pages is unknown.- Specified by:
getNumberOfPagesin interfacePageProvider<T>
-
setCurrentPageIndex
public void setCurrentPageIndex(long currentPageIndex) Description copied from interface:PageProviderSets the current page of results to the required one.- Specified by:
setCurrentPageIndexin interfacePageProvider<T>- Parameters:
currentPageIndex- the page index, starting from 0
-
setCurrentPage
Description copied from interface:PageProviderSets the current page of results to the required one and return it.- Specified by:
setCurrentPagein interfacePageProvider<T>- Parameters:
page- the page index, starting from 0
-
getPageSize
public long getPageSize()Description copied from interface:PageProviderReturns the number of results per page. 0 means no pagination unlessPageProvider.getMaxPageSize()is greater than this value, it will be taken into account instead.- Specified by:
getPageSizein interfacePageProvider<T>
-
setPageSize
public void setPageSize(long pageSize) Description copied from interface:PageProviderSets the number of results per page. 0 means no pagination unlessPageProvider.getMaxPageSize()is greater than this value, it will be taken into account instead.- Specified by:
setPageSizein interfacePageProvider<T>
-
getPageSizeOptions
Description copied from interface:PageProviderReturns a list of available page size options to display in the page size selector.Uses an hardcoded list of values, and adds up the page provider initial and current page sizes.
- Specified by:
getPageSizeOptionsin interfacePageProvider<T>
-
setPageSizeOptions
Description copied from interface:PageProviderSets the page size options.- Specified by:
setPageSizeOptionsin interfacePageProvider<T>
-
getSortInfos
Description copied from interface:PageProviderReturns the complete list of sorting info for this provider- Specified by:
getSortInfosin interfacePageProvider<T>
-
getSortInfo
Description copied from interface:PageProviderReturns the first sorting info for this providerAlso kept for compatibility with existing code.
- Specified by:
getSortInfoin interfacePageProvider<T>
-
sortInfoChanged
-
setQuickFilters
- Specified by:
setQuickFiltersin interfacePageProvider<T>
-
getQuickFilters
- Specified by:
getQuickFiltersin interfacePageProvider<T>
-
getAvailableQuickFilters
- Specified by:
getAvailableQuickFiltersin interfacePageProvider<T>
-
addQuickFilter
- Specified by:
addQuickFilterin interfacePageProvider<T>
-
setSortInfos
Description copied from interface:PageProviderSets the complete list of sorting info for this provider- Specified by:
setSortInfosin interfacePageProvider<T>
-
setSortInfo
Description copied from interface:PageProviderSets the first and only sorting info for this provider.Also kept for compatibility with existing code.
- Specified by:
setSortInfoin interfacePageProvider<T>
-
setSortInfo
Description copied from interface:PageProviderSets 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:
setSortInfoin interfacePageProvider<T>
-
addSortInfo
Description copied from interface:PageProviderAdd the given sort info to the list of sorting infos.- Specified by:
addSortInfoin interfacePageProvider<T>
-
getSortInfoIndex
Description copied from interface:PageProviderReturns 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:
getSortInfoIndexin interfacePageProvider<T>
-
getHighlights
- Specified by:
getHighlightsin interfacePageProvider<T>
-
setHighlights
- Specified by:
setHighlightsin interfacePageProvider<T>
-
isNextPageAvailable
public boolean isNextPageAvailable()Description copied from interface:PageProviderReturns a boolean expressing if there are further pages.- Specified by:
isNextPageAvailablein interfacePageProvider<T>
-
isLastPageAvailable
public boolean isLastPageAvailable()Description copied from interface:PageProviderReturns a boolean expressing if the last page can be displayed.- Specified by:
isLastPageAvailablein interfacePageProvider<T>
-
isPreviousPageAvailable
public boolean isPreviousPageAvailable()Description copied from interface:PageProviderReturns a boolean expressing if there is a previous page.- Specified by:
isPreviousPageAvailablein interfacePageProvider<T>
-
lastPage
public void lastPage()Description copied from interface:PageProviderGo to the last page. Does not do anything if there is only one page displayed, or if the number of results is unknown.- Specified by:
lastPagein interfacePageProvider<T>
-
nextPage
public void nextPage()Description copied from interface:PageProviderGo to the next page- Specified by:
nextPagein interfacePageProvider<T>
-
previousPage
public void previousPage()Description copied from interface:PageProviderGo to the previous page- Specified by:
previousPagein interfacePageProvider<T>
-
refresh
public void refresh()Refresh hook, to override for custom behaviorWhen overriding it, call
super.refresh()as last statement to make sure that thePageProviderChangedListeneris called with the up-to-date @{code PageProvider} state.- Specified by:
refreshin interfacePageProvider<T>
-
setName
Description copied from interface:PageProviderSets the provider identifier- Specified by:
setNamein interfacePageProvider<T>
-
getCurrentPageStatus
Description copied from interface:PageProviderReturns a simple formatted string for current pagination status.- Specified by:
getCurrentPageStatusin interfacePageProvider<T>
-
isNextEntryAvailable
public boolean isNextEntryAvailable()Description copied from interface:PageProviderReturns true if there is a next entry.The next entry might be in next page, except if results count is unknown.
- Specified by:
isNextEntryAvailablein interfacePageProvider<T>
-
isPreviousEntryAvailable
public boolean isPreviousEntryAvailable()Description copied from interface:PageProviderReturns true if there is a previous entry.The previous entry might be in previous page.
- Specified by:
isPreviousEntryAvailablein interfacePageProvider<T>
-
nextEntry
public void nextEntry()Description copied from interface:PageProviderMove 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:
nextEntryin interfacePageProvider<T>
-
previousEntry
public void previousEntry()Description copied from interface:PageProviderMove 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:
previousEntryin interfacePageProvider<T>
-
getCurrentEntry
Description copied from interface:PageProviderReturns the current entry.- Specified by:
getCurrentEntryin interfacePageProvider<T>
-
setCurrentEntry
Description copied from interface:PageProviderSets the current entry.- Specified by:
setCurrentEntryin interfacePageProvider<T>
-
setCurrentEntryIndex
public void setCurrentEntryIndex(long index) Description copied from interface:PageProviderSets the current entry index.- Specified by:
setCurrentEntryIndexin interfacePageProvider<T>
-
getResultsCount
public long getResultsCount()Description copied from interface:PageProviderReturns the number of result elements if available or a negative value if it is unknown:UNKNOWN_SIZEif it is unknown as query was not done, and since 5.5,UNKNOWN_SIZE_AFTER_QUERYif it is still unknown after query was done.- Specified by:
getResultsCountin interfacePageProvider<T>
-
getProperties
Description copied from interface:PageProviderGets 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:
getPropertiesin interfacePageProvider<T>
-
setProperties
Description copied from interface:PageProviderSets 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:
setPropertiesin interfacePageProvider<T>
-
getBooleanProperty
- Since:
- 6.0
-
setResultsCount
public void setResultsCount(long resultsCount) Description copied from interface:PageProviderSets the results count.- Specified by:
setResultsCountin interfacePageProvider<T>
-
setSortable
public void setSortable(boolean sortable) - Specified by:
setSortablein interfacePageProvider<T>
-
isSortable
public boolean isSortable()Description copied from interface:PageProviderReturns if this provider is sortable- Specified by:
isSortablein interfacePageProvider<T>
-
getCurrentSelectPage
Description copied from interface:PageProviderReturns the current page of results wrapped in aPageSelectionitem.By default, no entry is selected, unless
PageProvider.setSelectedEntries(List)has been called before.- Specified by:
getCurrentSelectPagein interfacePageProvider<T>
-
setSelectedEntries
Description copied from interface:PageProviderSets the list of selected entries to take into account inPageProvider.getCurrentSelectPage().- Specified by:
setSelectedEntriesin interfacePageProvider<T>
-
getParameters
- Specified by:
getParametersin interfacePageProvider<T>
-
setParameters
- Specified by:
setParametersin interfacePageProvider<T>
-
getSearchDocumentModel
- Specified by:
getSearchDocumentModelin interfacePageProvider<T>
-
searchDocumentModelChanged
-
setSearchDocumentModel
- Specified by:
setSearchDocumentModelin interfacePageProvider<T>
-
getErrorMessage
- Specified by:
getErrorMessagein interfacePageProvider<T>
-
getError
- Specified by:
getErrorin interfacePageProvider<T>
-
hasError
public boolean hasError()- Specified by:
hasErrorin interfacePageProvider<T>
-
getDefinition
- Specified by:
getDefinitionin interfacePageProvider<T>
-
setDefinition
- Specified by:
setDefinitionin interfacePageProvider<T>
-
getMaxPageSize
public long getMaxPageSize()Description copied from interface:PageProviderReturns the max number of results per page. 0 means no pagination.If page size is greater than this maximum value, it will be taken into account instead.
- Specified by:
getMaxPageSizein interfacePageProvider<T>
-
setMaxPageSize
public void setMaxPageSize(long maxPageSize) Description copied from interface:PageProviderSets the max number of results per page. 0 means no pagination.If page size is greater than this maximum value, it will be taken into account instead.
- Specified by:
setMaxPageSizein interfacePageProvider<T>
-
getMinMaxPageSize
public long getMinMaxPageSize()Returns the minimal value for the max page size, taking the lower value between the requested page size and the maximum accepted page size.- Since:
- 5.4.2
-
getCurrentHigherNonEmptyPageIndex
public int getCurrentHigherNonEmptyPageIndex()Returns an integer keeping track of the higher page index giving results. Useful for enabling or disabling the nextPage action when number of results cannot be known.- Since:
- 5.5
-
getPageLimit
public long getPageLimit()Returns the page limit. The n first page we know they exist.- Specified by:
getPageLimitin interfacePageProvider<T>- Since:
- 5.8
-
setCurrentHigherNonEmptyPageIndex
public void setCurrentHigherNonEmptyPageIndex(int higherFilledPageIndex) -
getMaxNumberOfEmptyPages
public int getMaxNumberOfEmptyPages()Returns the maximum number of empty pages that can be fetched empty (defaults to 1). Can be useful for displaying pages of a provider without results count.- Since:
- 5.5
-
getDefaultMaxPageSize
protected long getDefaultMaxPageSize() -
setPageProviderChangedListener
Description copied from interface:PageProviderSets thePageProviderChangedListenerfor thisPageProvider.- Specified by:
setPageProviderChangedListenerin interfacePageProvider<T>
-
notifyPageChanged
protected void notifyPageChanged()Call the registeredPageProviderChangedListener, if any, to notify that the page provider current page has changed.- Since:
- 5.7
-
notifyRefresh
protected void notifyRefresh()Call the registeredPageProviderChangedListener, if any, to notify that the page provider has refreshed.- Since:
- 5.7
-
hasChangedParameters
Description copied from interface:PageProviderTest if provider parameters have changed- Specified by:
hasChangedParametersin interfacePageProvider<T>
-
getParametersChanged
-
getAggregateDefinitions
- Specified by:
getAggregateDefinitionsin interfacePageProvider<T>
-
getAggregates
- Specified by:
getAggregatesin interfacePageProvider<T>
-
hasAggregateSupport
public boolean hasAggregateSupport()- Specified by:
hasAggregateSupportin interfacePageProvider<T>
-
isTrackingEnabled
protected boolean isTrackingEnabled()- Since:
- 7.4
-
fireSearchEvent
protected void fireSearchEvent(NuxeoPrincipal principal, String query, List<T> entries, Long executionTimeMs) Send a search event so that PageProvider calls can be tracked by Audit or other statistic gathering process- Since:
- 7.4
-
incorporateAggregates
Default (dummy) implementation that should be overridden by PageProvider actually dealing with Aggregates- Since:
- 7.4
-
getResultsCountLimit
public long getResultsCountLimit()Description copied from interface:PageProviderLimit of number of results beyond which the page provider may not be able to computePageProvider.getResultsCount()or navigate.Requesting results beyond this limit may result in error. When
PageProvider.getResultsCount()is negative, it means there may be more results than this limit.0 means there is no limit.
- Specified by:
getResultsCountLimitin interfacePageProvider<T>
-
isSkipAggregates
public boolean isSkipAggregates()- Specified by:
isSkipAggregatesin interfacePageProvider<T>
-