001/*
002 * (C) Copyright 2010-2016 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Anahide Tchertchian
018 */
019package org.nuxeo.ecm.platform.query.api;
020
021import java.io.Serializable;
022import java.util.List;
023import java.util.Map;
024import java.util.Set;
025
026import org.nuxeo.ecm.core.api.DocumentModel;
027import org.nuxeo.ecm.core.api.SortInfo;
028
029/**
030 * @author Anahide Tchertchian
031 * @since 5.4
032 */
033public interface PageProviderService extends Serializable {
034
035    /**
036     * Name of the search document model context map property holding named parameters.
037     *
038     * @since 7.1
039     */
040    String NAMED_PARAMETERS = "namedParameters";
041
042    /**
043     * Returns a named page provider definition.
044     * <p>
045     * Useful to share the definition between the page provider service, and the content view service (as content views
046     * can reference a named page provider that is already registered instead of redefining it).
047     *
048     * @since 5.4
049     * @param name the page provider name
050     * @return the page provider definition or null, if no page provider with this name was found.
051     */
052    PageProviderDefinition getPageProviderDefinition(String name);
053
054    /**
055     * Returns an instance of page provider with given name and definition.
056     * <p>
057     * Useful to share the definition between the page provider service, and the content view service (as content views
058     * can reference a named page provider that is already registered instead of redefining it).
059     * <p>
060     * If not null, parameters sortInfos and pageSize will override information computed in the XML file. If not null,
061     * currentPage will override default current page (0).
062     *
063     * @param name the name that will be set on the provider.
064     * @param desc the definition used to build the provider instance.
065     * @param searchDocument the search document to be used by the provider.
066     * @param sortInfos sort information to set on the provider instance.
067     * @param pageSize the provider page size.
068     * @param currentPage the provider current page index.
069     * @param properties the provider properties
070     * @param parameters the provider parameters.
071     * @return the page provider instance.
072     * @since 5.7
073     */
074    PageProvider<?> getPageProvider(String name, PageProviderDefinition desc, DocumentModel searchDocument,
075            List<SortInfo> sortInfos, Long pageSize, Long currentPage, Map<String, Serializable> properties,
076            Object... parameters);
077
078    /**
079     * Returns an instance of page provider with given name.
080     *
081     * @param name the page provider name
082     * @param sortInfos sort information to set on the provider instance.
083     * @param pageSize the provider page size.
084     * @param currentPage the provider current page index.
085     * @param properties the provider properties
086     * @param parameters the provider parameters.
087     * @return the page provider instance.
088     * @since 5.4
089     */
090    PageProvider<?> getPageProvider(String name, List<SortInfo> sortInfos, Long pageSize, Long currentPage,
091            Map<String, Serializable> properties, Object... parameters);
092
093    /**
094     * Returns an instance of page provider with given name.
095     *
096     * @see #getPageProvider(String, PageProviderDefinition, DocumentModel, List, Long, Long, Map, Object...)
097     * @since 5.7
098     */
099    PageProvider<?> getPageProvider(String name, DocumentModel searchDocument, List<SortInfo> sortInfos, Long pageSize,
100            Long currentPage, Map<String, Serializable> properties, Object... parameters);
101
102    /**
103     * Returns an instance of page provider with given name.
104     *
105     * @see #getPageProvider(String, DocumentModel, List, Long, Long, Map, Object...)
106     * @since 8.4
107     */
108    PageProvider<?> getPageProvider(String name, DocumentModel searchDocument, List<SortInfo> sortInfos, Long pageSize,
109            Long currentPage, Map<String, Serializable> properties, List<QuickFilter> quickFilters,
110            Object... parameters);
111
112    /**
113     * Returns an instance of page provider with given name.
114     *
115     * @see #getPageProvider(String, PageProviderDefinition, DocumentModel, List, Long, Long, Map, Object...)
116     * @since 8.4
117     */
118    PageProvider<?> getPageProvider(String name, PageProviderDefinition desc, DocumentModel searchDocument,
119            List<SortInfo> sortInfos, Long pageSize, Long currentPage, Map<String, Serializable> properties,
120            List<QuickFilter> quickFilters, Object... parameters);
121
122    /**
123     * Returns an instance of page provider with given name.
124     *
125     * @see #getPageProvider(String, List, Long, Long, Map, Object...)
126     * @since 9.1
127     */
128    PageProvider<?> getPageProvider(String name, List<SortInfo> sortInfos, Long pageSize, Long currentPage,
129            Map<String, Serializable> properties, List<String> highlights, List<QuickFilter> quickFilters,
130            Object... parameters);
131
132    /**
133     * Returns an instance of page provider with given name.
134     *
135     * @see #getPageProvider(String, DocumentModel, List, Long, Long, Map, Object...)
136     * @since 9.1
137     */
138    PageProvider<?> getPageProvider(String name, DocumentModel searchDocument, List<SortInfo> sortInfos, Long pageSize,
139            Long currentPage, Map<String, Serializable> properties, List<String> highlights,
140            List<QuickFilter> quickFilters, Object... parameters);
141
142    /**
143     * Returns an instance of page provider with given name.
144     *
145     * @param name the name that will be set on the provider.
146     * @param searchDocument the search document to be used by the provider.
147     * @param sortInfos sort information to set on the provider instance.
148     * @param pageSize the provider page size.
149     * @param currentPage the provider current page index. Ignored if currentOffset set.
150     * @param currentOffset the provider current offset.
151     * @param properties the provider properties.
152     * @param highlights list of the fields to be highlighted.
153     * @param quickFilters list of the quickFilters to be applied.
154     * @param parameters the provider parameters.
155     * @return the page provider instance.
156     * @since 9.3
157     */
158    PageProvider<?> getPageProvider(String name, DocumentModel searchDocument, List<SortInfo> sortInfos, Long pageSize,
159            Long currentPage, Long currentOffset, Map<String, Serializable> properties, List<String> highlights,
160            List<QuickFilter> quickFilters, Object... parameters);
161
162    /**
163     * Returns an instance of page provider with given name.
164     *
165     * @see #getPageProvider(String, PageProviderDefinition, DocumentModel, List, Long, Long, Map, Object...)
166     * @since 9.1
167     */
168    PageProvider<?> getPageProvider(String name, PageProviderDefinition desc, DocumentModel searchDocument,
169            List<SortInfo> sortInfos, Long pageSize, Long currentPage, Map<String, Serializable> properties,
170            List<String> highlights, List<QuickFilter> quickFilters, Object... parameters);
171
172    /**
173     * Returns an instance of page provider with given name and definition.
174     * <p>
175     * If not null, parameters sortInfos and pageSize will override information computed in the XML file. If not null,
176     * currentPage will override default current page (0).
177     *
178     * @param name the name that will be set on the provider.
179     * @param desc the definition used to build the provider instance.
180     * @param searchDocument the search document to be used by the provider.
181     * @param sortInfos sort information to set on the provider instance.
182     * @param pageSize the provider page size.
183     * @param currentPage the provider current page index. Ignored if currentOffset set.
184     * @param currentOffset the provider current page offset.
185     * @param properties the provider properties.
186     * @param highlights list of the fields to be highlighted.
187     * @param quickFilters list of the quickFilters to be applied.
188     * @param parameters the provider parameters.
189     * @return the page provider instance.
190     * @since 9.3
191     */
192    PageProvider<?> getPageProvider(String name, PageProviderDefinition desc, DocumentModel searchDocument,
193            List<SortInfo> sortInfos, Long pageSize, Long currentPage, Long currentOffset,
194            Map<String, Serializable> properties, List<String> highlights, List<QuickFilter> quickFilters,
195            Object... parameters);
196
197    /**
198     * @since 6.0
199     */
200    void registerPageProviderDefinition(PageProviderDefinition desc);
201
202    /**
203     * @since 6.0
204     */
205    void unregisterPageProviderDefinition(PageProviderDefinition desc);
206
207    /**
208     * Returns all the registered page provider names, or an empty set if no page provider is registered.
209     *
210     * @since 6.0
211     */
212    Set<String> getPageProviderDefinitionNames();
213
214}