001/* 002 * (C) Copyright 2010 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Anahide Tchertchian 016 */ 017package org.nuxeo.ecm.platform.query.api; 018 019import java.io.Serializable; 020import java.util.List; 021import java.util.Map; 022import java.util.Set; 023 024import org.nuxeo.ecm.core.api.DocumentModel; 025import org.nuxeo.ecm.core.api.SortInfo; 026 027/** 028 * @author Anahide Tchertchian 029 * @since 5.4 030 */ 031public interface PageProviderService extends Serializable { 032 033 /** 034 * Name of the search document model context map property holding named parameters. 035 * 036 * @since 7.1 037 */ 038 public static final String NAMED_PARAMETERS = "namedParameters"; 039 040 /** 041 * Returns a named page provider definition. 042 * <p> 043 * Useful to share the definition between the page provider service, and the content view service (as content views 044 * can reference a named page provider that is already registered instead of redefining it). 045 * 046 * @since 5.4 047 * @param name the page provider name 048 * @return the page provider definition or null, if no page provider with this name was found. 049 */ 050 PageProviderDefinition getPageProviderDefinition(String name); 051 052 /** 053 * Returns an instance of a page provider with given name and definition. 054 * 055 * @since 5.4 056 * @deprecated since 5.7: use 057 * {@link #getPageProvider(String, PageProviderDefinition, DocumentModel, List, Long, Long, Map, Object...)} 058 * with search document model as additional parameter 059 */ 060 @Deprecated 061 PageProvider<?> getPageProvider(String name, PageProviderDefinition desc, List<SortInfo> sortInfos, Long pageSize, 062 Long currentPage, Map<String, Serializable> properties, Object... parameters); 063 064 /** 065 * Returns an instance of page provider with given name and definition. 066 * <p> 067 * Useful to share the definition between the page provider service, and the content view service (as content views 068 * can reference a named page provider that is already registered instead of redefining it). 069 * <p> 070 * If not null, parameters sortInfos and pageSize will override information computed in the XML file. If not null, 071 * currentPage will override default current page (0). 072 * 073 * @param name the name that will be set on the provider. 074 * @param desc the definition used to build the provider instance. 075 * @param searchDocument the search document to be used by the provider. 076 * @param sortInfos sort information to set on the provider instance. 077 * @param pageSize the provider page size. 078 * @param currentPage the provider current page index. 079 * @param properties the provider properties 080 * @param parameters the provider parameters. 081 * @return the page provider instance. 082 * @since 5.7 083 */ 084 PageProvider<?> getPageProvider(String name, PageProviderDefinition desc, DocumentModel searchDocument, 085 List<SortInfo> sortInfos, Long pageSize, Long currentPage, Map<String, Serializable> properties, 086 Object... parameters); 087 088 /** 089 * Returns an instance of page provider with given name. 090 * 091 * @param name the page provider name 092 * @param sortInfos sort information to set on the provider instance. 093 * @param pageSize the provider page size. 094 * @param currentPage the provider current page index. 095 * @param properties the provider properties 096 * @param parameters the provider parameters. 097 * @return the page provider instance. 098 * @since 5.4 099 */ 100 PageProvider<?> getPageProvider(String name, List<SortInfo> sortInfos, Long pageSize, Long currentPage, 101 Map<String, Serializable> properties, Object... parameters); 102 103 /** 104 * Returns an instance of page provider with given name. 105 * 106 * @see #getPageProvider(String, PageProviderDefinition, DocumentModel, List, Long, Long, Map, Object...) 107 * @since 5.7 108 */ 109 PageProvider<?> getPageProvider(String name, DocumentModel searchDocument, List<SortInfo> sortInfos, Long pageSize, 110 Long currentPage, Map<String, Serializable> properties, Object... parameters); 111 112 /** 113 * @since 6.0 114 */ 115 void registerPageProviderDefinition(PageProviderDefinition desc); 116 117 /** 118 * @since 6.0 119 */ 120 void unregisterPageProviderDefinition(PageProviderDefinition desc); 121 122 /** 123 * Returns all the registered page provider names, or an empty set if no page provider is registered. 124 * 125 * @since 6.0 126 */ 127 Set<String> getPageProviderDefinitionNames(); 128 129}