Class AbstractPageProvider<T>

    • Field Detail

      • log

        public static final Log log
      • PAGEPROVIDER_TRACK_PROPERTY_NAME

        public static final String 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:
        Constant Field Values
      • SKIPPED_SCHEMAS_FOR_SEARCHFIELD

        protected static final List<String> SKIPPED_SCHEMAS_FOR_SEARCHFIELD
        lists schemas prefixes that should be skipped when extracting "search fields" (tracking) from searchDocumentModel
        Since:
        7.4
      • offset

        protected long offset
      • pageSize

        protected long pageSize
      • pageSizeOptions

        protected List<Long> pageSizeOptions
      • maxPageSize

        protected long maxPageSize
      • resultsCount

        protected long resultsCount
      • currentEntryIndex

        protected int currentEntryIndex
      • currentHigherNonEmptyPageIndex

        protected int currentHigherNonEmptyPageIndex
        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
      • sortable

        protected boolean sortable
      • selectedEntries

        protected List<T> selectedEntries
      • parameters

        protected Object[] parameters
      • searchDocumentModel

        protected DocumentModel searchDocumentModel
      • errorMessage

        protected String errorMessage
      • tracking

        protected Boolean tracking
    • Constructor Detail

      • AbstractPageProvider

        public AbstractPageProvider()
    • Method Detail

      • pageChanged

        protected void pageChanged()
        Page change hook, to override for custom behavior

        When overriding it, call super.pageChanged() as last statement to make sure that the PageProviderChangedListener is called with the up-to-date @{code PageProvider} state.

      • 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>
      • setCurrentPageOffset

        public void setCurrentPageOffset​(long offset)
        Description copied from interface: PageProvider
        Sets the current page offset.

        If the provider keeps information linked to the current page, they should be reset after calling this method.

        Specified by:
        setCurrentPageOffset 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>
      • getNumberOfPages

        public long getNumberOfPages()
        Description copied from interface: PageProvider
        Returns the total number of pages or 0 if number of pages is unknown.
        Specified by:
        getNumberOfPages in interface PageProvider<T>
      • setCurrentPageIndex

        public void setCurrentPageIndex​(long currentPageIndex)
        Description copied from interface: PageProvider
        Sets the current page of results to the required one.
        Specified by:
        setCurrentPageIndex in interface PageProvider<T>
        Parameters:
        currentPageIndex - the page index, starting from 0
      • setCurrentPage

        public 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
      • setPageSize

        public void setPageSize​(long pageSize)
        Description copied from interface: PageProvider
        Sets the number of results per page. 0 means no pagination unless PageProvider.getMaxPageSize() is greater than this value, it will be taken into account instead.
        Specified by:
        setPageSize in interface PageProvider<T>
      • getPageSizeOptions

        public List<Long> getPageSizeOptions()
        Description copied from interface: PageProvider
        Returns 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:
        getPageSizeOptions 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>
      • 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​(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​(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​(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>
      • isLastPageAvailable

        public boolean isLastPageAvailable()
        Description copied from interface: PageProvider
        Returns a boolean expressing if the last page can be displayed.
        Specified by:
        isLastPageAvailable 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. Does not do anything if there is only one page displayed, or if the number of results is unknown.
        Specified by:
        lastPage in interface PageProvider<T>
      • refresh

        public void refresh()
        Refresh hook, to override for custom behavior

        When overriding it, call super.refresh() as last statement to make sure that the PageProviderChangedListener is called with the up-to-date @{code PageProvider} state.

        Specified by:
        refresh in interface PageProvider<T>
      • isNextEntryAvailable

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

        The next entry might be in next page, except if results count is unknown.

        Specified by:
        isNextEntryAvailable in interface PageProvider<T>
      • isPreviousEntryAvailable

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

        The previous entry might be in previous page.

        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>
      • getResultsCount

        public long getResultsCount()
        Description copied from interface: PageProvider
        Returns the number of result elements if available or a negative value if it is unknown: UNKNOWN_SIZE if it is unknown as query was not done, and since 5.5, UNKNOWN_SIZE_AFTER_QUERY if it is still unknown after query was done.
        Specified by:
        getResultsCount in interface PageProvider<T>
      • getProperties

        public Map<String,​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​(Map<String,​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>
      • getBooleanProperty

        protected boolean getBooleanProperty​(String propName,
                                             boolean defaultValue)
        Since:
        6.0
      • setResultsCount

        public void setResultsCount​(long resultsCount)
        Description copied from interface: PageProvider
        Sets the results count.
        Specified by:
        setResultsCount 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>
      • getMaxPageSize

        public long getMaxPageSize()
        Description copied from interface: PageProvider
        Returns 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:
        getMaxPageSize in interface PageProvider<T>
      • setMaxPageSize

        public void setMaxPageSize​(long maxPageSize)
        Description copied from interface: PageProvider
        Sets 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:
        setMaxPageSize in interface PageProvider<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:
        getPageLimit in interface PageProvider<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()
      • notifyPageChanged

        protected void notifyPageChanged()
        Call the registered PageProviderChangedListener, if any, to notify that the page provider current page has changed.
        Since:
        5.7
      • notifyRefresh

        protected void notifyRefresh()
        Call the registered PageProviderChangedListener, if any, to notify that the page provider has refreshed.
        Since:
        5.7
      • getParametersChanged

        protected boolean getParametersChanged​(Object[] oldParams,
                                               Object[] newParams)
      • 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

        protected void incorporateAggregates​(Map<String,​Serializable> eventProps)
        Default (dummy) implementation that should be overridden by PageProvider actually dealing with Aggregates
        Since:
        7.4