Class CoreQueryDocumentPageProvider
- java.lang.Object
-
- org.nuxeo.ecm.platform.query.api.AbstractPageProvider<DocumentModel>
-
- org.nuxeo.ecm.platform.query.nxql.CoreQueryDocumentPageProvider
-
- All Implemented Interfaces:
Serializable
,PageProvider<DocumentModel>
- Direct Known Subclasses:
ElasticSearchNxqlPageProvider
public class CoreQueryDocumentPageProvider extends AbstractPageProvider<DocumentModel>
Page provider performing a query on a core session.It builds the query at each call so that it can refresh itself when the query changes.
The page provider property named
CORE_SESSION_PROPERTY
is used to pass theCoreSession
instance that will perform the query. The optional propertyCHECK_QUERY_CACHE_PROPERTY
can be set to "true" to avoid performing the query again if it did not change.Since 6.0, the page provider property named
USE_UNRESTRICTED_SESSION_PROPERTY
allows specifying whether the query should be run as unrestricted. When such a property is set to "true", the additional propertyDETACH_DOCUMENTS_PROPERTY
is used to detach documents (defaults to true when session is unrestricted).- Since:
- 5.4
- Author:
- Anahide Tchertchian
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static String
CHECK_QUERY_CACHE_PROPERTY
static String
CORE_SESSION_PROPERTY
protected List<DocumentModel>
currentPageDocuments
static String
DEFAULT_NAVIGATION_RESULTS_KEY
static String
DEFAULT_NAVIGATION_RESULTS_PROPERTY
static String
DEFAULT_NAVIGATION_RESULTS_VALUE
static String
DETACH_DOCUMENTS_PROPERTY
Boolean property stating that documents should be detached, only useful when propertyUSE_UNRESTRICTED_SESSION_PROPERTY
is set to true.static String
MAX_RESULTS_PROPERTY
protected Long
maxResults
static String
PAGE_SIZE_RESULTS_KEY
protected String
query
static String
USE_UNRESTRICTED_SESSION_PROPERTY
Boolean property stating that query should be unrestricted.-
Fields inherited from class org.nuxeo.ecm.platform.query.api.AbstractPageProvider
currentEntryIndex, currentHigherNonEmptyPageIndex, currentSelectPage, definition, error, errorMessage, highlights, maxPageSize, name, offset, PAGEPROVIDER_TRACK_PROPERTY_NAME, pageProviderChangedListener, pageSize, pageSizeOptions, parameters, properties, quickFilters, resultsCount, searchDocumentModel, selectedEntries, SKIPPED_SCHEMAS_FOR_SEARCHFIELD, sortable, sortInfos, tracking
-
Fields 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 Constructor Description CoreQueryDocumentPageProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
buildQuery(CoreSession coreSession)
protected void
checkQueryCache()
protected boolean
detachDocuments()
protected CoreSession
getCoreSession()
List<DocumentModel>
getCurrentPage()
Returns the list of current page items.String
getCurrentQuery()
PageSelections<DocumentModel>
getCurrentSelectPage()
Returns the current page of results wrapped in aPageSelection
item.protected Filter
getFilter()
Filter to use when processing results.long
getMaxResults()
Returns the maximum number of results or0
if there is no limit.long
getPageLimit()
Returns the page limit.long
getResultsCountLimit()
Limit of number of results beyond which the page provider may not be able to computePageProvider.getResultsCount()
or navigate.protected void
pageChanged()
Page change hook, to override for custom behaviorvoid
refresh()
Refresh hook, to override for custom behaviorprotected void
rewindSelectablePage()
Fetch a page that can be selected.void
setMaxResults(long maxResults)
Sets the maximum number of result elements.protected boolean
useUnrestrictedSession()
-
Methods inherited from class org.nuxeo.ecm.platform.query.api.AbstractPageProvider
addQuickFilter, addSortInfo, fireSearchEvent, firstPage, getAggregateDefinitions, getAggregates, getAvailableQuickFilters, getBooleanProperty, getCurrentEntry, getCurrentHigherNonEmptyPageIndex, getCurrentPageIndex, getCurrentPageOffset, getCurrentPageSize, getCurrentPageStatus, getDefaultMaxPageSize, getDefinition, getError, getErrorMessage, getHighlights, getMaxNumberOfEmptyPages, getMaxPageSize, getMinMaxPageSize, getName, getNumberOfPages, getPageSize, getPageSizeOptions, getParameters, getParametersChanged, getProperties, getQuickFilters, getResultsCount, getSearchDocumentModel, getSortInfo, getSortInfoIndex, getSortInfos, hasAggregateSupport, hasChangedParameters, hasError, incorporateAggregates, isLastPageAvailable, isNextEntryAvailable, isNextPageAvailable, isPreviousEntryAvailable, isPreviousPageAvailable, isSkipAggregates, isSortable, isTrackingEnabled, lastPage, nextEntry, nextPage, notifyPageChanged, notifyRefresh, previousEntry, previousPage, searchDocumentModelChanged, setCurrentEntry, setCurrentEntryIndex, setCurrentHigherNonEmptyPageIndex, setCurrentPage, setCurrentPageIndex, setCurrentPageOffset, setDefinition, setHighlights, setMaxPageSize, setName, setPageProviderChangedListener, setPageSize, setPageSizeOptions, setParameters, setProperties, setQuickFilters, setResultsCount, setSearchDocumentModel, setSelectedEntries, setSortable, setSortInfo, setSortInfo, setSortInfos, sortInfoChanged
-
-
-
-
Field Detail
-
CORE_SESSION_PROPERTY
public static final String CORE_SESSION_PROPERTY
- See Also:
- Constant Field Values
-
MAX_RESULTS_PROPERTY
public static final String MAX_RESULTS_PROPERTY
- See Also:
- Constant Field Values
-
DEFAULT_NAVIGATION_RESULTS_KEY
public static final String DEFAULT_NAVIGATION_RESULTS_KEY
- See Also:
- Constant Field Values
-
PAGE_SIZE_RESULTS_KEY
public static final String PAGE_SIZE_RESULTS_KEY
- See Also:
- Constant Field Values
-
DEFAULT_NAVIGATION_RESULTS_PROPERTY
public static final String DEFAULT_NAVIGATION_RESULTS_PROPERTY
- See Also:
- Constant Field Values
-
DEFAULT_NAVIGATION_RESULTS_VALUE
public static final String DEFAULT_NAVIGATION_RESULTS_VALUE
- See Also:
- Constant Field Values
-
CHECK_QUERY_CACHE_PROPERTY
public static final String CHECK_QUERY_CACHE_PROPERTY
- See Also:
- Constant Field Values
-
USE_UNRESTRICTED_SESSION_PROPERTY
public static final String USE_UNRESTRICTED_SESSION_PROPERTY
Boolean property stating that query should be unrestricted.- Since:
- 6.0
- See Also:
- Constant Field Values
-
DETACH_DOCUMENTS_PROPERTY
public static final String DETACH_DOCUMENTS_PROPERTY
Boolean property stating that documents should be detached, only useful when propertyUSE_UNRESTRICTED_SESSION_PROPERTY
is set to true.When an unrestricted session is used, this property defaults to true.
- Since:
- 6.0
- See Also:
- Constant Field Values
-
query
protected String query
-
currentPageDocuments
protected List<DocumentModel> currentPageDocuments
-
maxResults
protected Long maxResults
-
-
Method Detail
-
getCurrentPage
public List<DocumentModel> getCurrentPage()
Description copied from class:AbstractPageProvider
Returns the list of current page items.Custom implementation can be added here, based on the page provider properties, parameters and
WhereClauseDefinition
on 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
AbstractPageProvider.pageChanged()
andAbstractPageProvider.refresh()
.Fields
AbstractPageProvider.errorMessage
andAbstractPageProvider.error
can also be filled to provide accurate feedback in case an error occurs during the search.When items are retrieved, a call to
AbstractPageProvider.setResultsCount(long)
should be made to ensure proper pagination as implemented in this abstract class. The implementation inCoreQueryAndFetchPageProvider
is 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
AbstractPageProvider.getCurrentHigherNonEmptyPageIndex()
andAbstractPageProvider.setCurrentHigherNonEmptyPageIndex(int)
. In this case,CoreQueryDocumentPageProvider
is a good example.- Specified by:
getCurrentPage
in interfacePageProvider<DocumentModel>
- Specified by:
getCurrentPage
in classAbstractPageProvider<DocumentModel>
- Returns:
- the current page
-
buildQuery
protected void buildQuery(CoreSession coreSession)
-
checkQueryCache
protected void checkQueryCache()
-
useUnrestrictedSession
protected boolean useUnrestrictedSession()
-
detachDocuments
protected boolean detachDocuments()
-
getCoreSession
protected CoreSession getCoreSession()
-
getMaxResults
public long getMaxResults()
Returns the maximum number of results or0
if there is no limit.- Since:
- 5.6
-
getResultsCountLimit
public long getResultsCountLimit()
Description copied from interface:PageProvider
Limit 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:
getResultsCountLimit
in interfacePageProvider<DocumentModel>
- Overrides:
getResultsCountLimit
in classAbstractPageProvider<DocumentModel>
-
getPageLimit
public long getPageLimit()
Returns the page limit. The n first page we know they exist. We don't compute the number of page beyond this limit.- Specified by:
getPageLimit
in interfacePageProvider<DocumentModel>
- Overrides:
getPageLimit
in classAbstractPageProvider<DocumentModel>
- Since:
- 5.8
-
setMaxResults
public void setMaxResults(long maxResults)
Sets the maximum number of result elements.- Since:
- 5.6
-
getCurrentSelectPage
public PageSelections<DocumentModel> getCurrentSelectPage()
Description copied from interface:PageProvider
Returns the current page of results wrapped in aPageSelection
item.By default, no entry is selected, unless
PageProvider.setSelectedEntries(List)
has been called before.- Specified by:
getCurrentSelectPage
in interfacePageProvider<DocumentModel>
- Overrides:
getCurrentSelectPage
in classAbstractPageProvider<DocumentModel>
-
getCurrentQuery
public String getCurrentQuery()
-
rewindSelectablePage
protected void rewindSelectablePage()
Fetch a page that can be selected. It loads the last page if we're targeting a page beyond the last one or the first page if there are no results to show and we're targeting anything other than the first page. Fix for NXP-8564.
-
getFilter
protected Filter getFilter()
Filter to use when processing results.Defaults to null (no filter applied), method to be overridden by subclasses.
- Since:
- 6.0
-
pageChanged
protected void pageChanged()
Description copied from class:AbstractPageProvider
Page change hook, to override for custom behaviorWhen overriding it, call
super.pageChanged()
as last statement to make sure that thePageProviderChangedListener
is called with the up-to-date @{code PageProvider} state.- Overrides:
pageChanged
in classAbstractPageProvider<DocumentModel>
-
refresh
public void refresh()
Description copied from class:AbstractPageProvider
Refresh hook, to override for custom behaviorWhen overriding it, call
super.refresh()
as last statement to make sure that thePageProviderChangedListener
is called with the up-to-date @{code PageProvider} state.- Specified by:
refresh
in interfacePageProvider<DocumentModel>
- Overrides:
refresh
in classAbstractPageProvider<DocumentModel>
-
-