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.contentview.jsf; 020 021import java.io.Serializable; 022import java.util.List; 023 024import javax.faces.context.FacesContext; 025 026import org.nuxeo.ecm.core.api.DocumentModel; 027import org.nuxeo.ecm.core.api.SortInfo; 028import org.nuxeo.ecm.platform.query.api.PageProvider; 029import org.nuxeo.ecm.platform.query.api.QuickFilter; 030 031/** 032 * A content view is a notion to handle lists of objects rendering, as well as query filters to build the list. 033 * <p> 034 * It has a name that will be the resulting page provider name too. It handles a page provider and accepts configuration 035 * needed to handle rendering, like the search layout (for filtering options), the result layout (for results 036 * rendering), actions (for buttons available when selecting result objects), the selection list name... 037 * <p> 038 * It also handles refresh or reset of its provider, depending on its cache key and refresh events configuration. 039 * 040 * @author Anahide Tchertchian 041 * @since 5.4 042 */ 043public interface ContentView extends Serializable { 044 045 String SEARCH_DOCUMENT_EL_VARIABLE = "searchDocument"; 046 047 /** 048 * Seam event to be fired when the current page of the content view's page provider has changed 049 * 050 * @since 5.7 051 */ 052 String CONTENT_VIEW_PAGE_CHANGED_EVENT = "contentViewPageChanged"; 053 054 /** 055 * Seam event to be fired when the content view's page provider has refreshed 056 * 057 * @since 5.7 058 */ 059 String CONTENT_VIEW_REFRESH_EVENT = "contentViewRefresh"; 060 061 /** 062 * Seam event to be fired when the page size of the content view has changed 063 * 064 * @since 5.7 065 */ 066 String CONTENT_VIEW_PAGE_SIZE_CHANGED_EVENT = "contentViewPageSizeChanged"; 067 068 /** 069 * Returns the name of this content view 070 */ 071 String getName(); 072 073 /** 074 * Returns a title for this content view 075 */ 076 String getTitle(); 077 078 /** 079 * Returns a boolean stating if title has to be translated 080 * 081 * @see #getTitle() 082 */ 083 boolean getTranslateTitle(); 084 085 /** 086 * Returns true is the title should be displayed before the result layout selector. 087 * 088 * @since 5.4.2 089 */ 090 boolean getShowTitle(); 091 092 /** 093 * Returns the selection list name 094 */ 095 String getSelectionListName(); 096 097 /** 098 * Returns the pagination type to be used in pagination rendering 099 */ 100 String getPagination(); 101 102 /** 103 * Returns the list of action categories to display buttons available on selection of items. 104 */ 105 List<String> getActionsCategories(); 106 107 /** 108 * Returns the list of flags set on this content view, useful to group them, see 109 * {@link ContentViewService#getContentViewNames(String)} 110 */ 111 List<String> getFlags(); 112 113 /** 114 * Returns the search layout, used to filter results. 115 */ 116 ContentViewLayout getSearchLayout(); 117 118 /** 119 * Returns the result layouts, used to display results. 120 */ 121 List<ContentViewLayout> getResultLayouts(); 122 123 /** 124 * Returns the current result layout, as set using {@link #setCurrentResultLayout(ContentViewLayout)}, or the first 125 * of defined result layouts when not set. 126 */ 127 ContentViewLayout getCurrentResultLayout(); 128 129 /** 130 * Sets the current result layout. 131 */ 132 void setCurrentResultLayout(ContentViewLayout layout); 133 134 /** 135 * Sets the current result layout given its name. 136 * 137 * @since 5.7 138 */ 139 void setCurrentResultLayout(String resultLayoutName); 140 141 /** 142 * @since 6.0 143 */ 144 boolean hasResultLayoutBinding(); 145 146 /** 147 * Returns the current page size, as set using {@link #setCurrentPageSize(Long)}, or the page size set on current 148 * page provider if not null. 149 */ 150 Long getCurrentPageSize(); 151 152 /** 153 * Sets the current page size. 154 */ 155 void setCurrentPageSize(Long pageSize); 156 157 /** 158 * Returns the list of selected result layout columns, resolving the bound EL expression set in the content view 159 * definition if columns where not explicitely set with {@link #setCurrentResultLayoutColumns(List)}. 160 * 161 * @since 5.4.2 162 */ 163 List<String> getCurrentResultLayoutColumns(); 164 165 /** 166 * Sets the list of result layout columns. 167 * 168 * @since 5.4.2 169 */ 170 void setCurrentResultLayoutColumns(List<String> resultColumns); 171 172 /** 173 * @since 6.0 174 */ 175 boolean hasResultLayoutColumnsBinding(); 176 177 /** 178 * Returns the cache key for this content view provider, resolving from the current {@link FacesContext} instance if 179 * it's an EL expression. 180 */ 181 String getCacheKey(); 182 183 /** 184 * Returns the cache size for this content view. 185 */ 186 Integer getCacheSize(); 187 188 /** 189 * Returns the icon relative path for this content view. 190 */ 191 String getIconPath(); 192 193 /** 194 * Returns the query parameters for this content view provider provider, resolving from the current 195 * {@link FacesContext} instance if they are EL expressions. 196 */ 197 Object[] getQueryParameters(); 198 199 /** 200 * Returns the list of event names that should trigger a refresh of this content view page provider. 201 */ 202 List<String> getRefreshEventNames(); 203 204 /** 205 * Returns the list of event names that should trigger a reset of this content view page provider. 206 */ 207 List<String> getResetEventNames(); 208 209 /** 210 * Gets page provider according to given parameters 211 * 212 * @param searchDocument document that will be set on the page provider. If this document is null, we try to 213 * retrieve the content view document model calling {@link #getSearchDocumentModel()}. If it is not null, 214 * it is set on the page provider. 215 * @param sortInfos if not null, will override default sort info put in the page provider XML description 216 * @param pageSize if not null, will override default page size put in the page provider XML description 217 * @param currentPage if not null, will set the current page to given one 218 * @param params if not null, will set the parameters on provider. If null, will take parameters as resolved on the 219 * content view from the XML configuration, see {@link #getQueryParameters()} 220 */ 221 PageProvider<?> getPageProvider(DocumentModel searchDocument, List<SortInfo> sortInfos, Long pageSize, 222 Long currentPage, Object... params); 223 224 /** 225 * Gets page provider according to given parameters 226 * 227 * @see #getPageProvider(DocumentModel, List, Long, Long, Object...) using null as every argument except params 228 */ 229 PageProvider<?> getPageProviderWithParams(Object... params); 230 231 /** 232 * Gets page provider according to given parameters 233 * 234 * @see #getPageProvider(DocumentModel, List, Long, Long, Object...) , using null as every argument 235 */ 236 PageProvider<?> getPageProvider(); 237 238 /** 239 * Returns the current page provider, or null if methods {@link #getPageProvider()}, 240 * {@link #getPageProvider(DocumentModel, List, Long, Long, Object...)} or 241 * {@link #getPageProviderWithParams(Object...)} were never called before. 242 */ 243 PageProvider<?> getCurrentPageProvider(); 244 245 /** 246 * Resets the page provider. 247 * <p> 248 * A new page provider will be computed next time {@link #getPageProviderWithParams(Object...)} is called. Sort 249 * information and query parameters will have to be re-generated. 250 */ 251 void resetPageProvider(); 252 253 /** 254 * Refreshes the current page provider if not null, see {@link PageProvider#refresh()}. 255 * <p> 256 * Sort information and query parameters and current page are kept. 257 */ 258 void refreshPageProvider(); 259 260 /** 261 * Refreshes the current page provider if not null, see {@link PageProvider#refresh()}, and resets the current page 262 * to the first one. 263 * <p> 264 * Sort information and query parameters are kept. 265 */ 266 void refreshAndRewindPageProvider(); 267 268 /** 269 * Reset the page provider aggregates. 270 * 271 * @since 6.0 272 */ 273 void resetPageProviderAggregates(); 274 275 /** 276 * Returns true is this content view can use the global page size set on the application. 277 */ 278 boolean getUseGlobalPageSize(); 279 280 /** 281 * Returns true is the page size selector should be displayed. 282 * 283 * @since 5.4.2 284 */ 285 boolean getShowPageSizeSelector(); 286 287 /** 288 * Returns true is the refresh command should be displayed. 289 * 290 * @since 5.4.2 291 */ 292 boolean getShowRefreshCommand(); 293 294 /** 295 * Returns true is the filter form should be displayed. 296 * <p> 297 * Filter form is displayed on top of content view results, using the search document model and search layout if 298 * they have been set on the content view. 299 * 300 * @since 5.4.2 301 */ 302 boolean getShowFilterForm(); 303 304 /** 305 * Returns the search document model as set on the content view. 306 * <p> 307 * If this document is null and a EL binding has been set on the content view description, the document model will 308 * be resolved from this binding, and set as the search document model. 309 * <p> 310 * Else, if the content view is using a provider that needs a search document model, a new one is created and 311 * attached to it thanks to the document type held in the definition. 312 */ 313 DocumentModel getSearchDocumentModel(); 314 315 /** 316 * Sets the search document model to be passed on the page provider, and set it also on the current page provider if 317 * not null. 318 */ 319 void setSearchDocumentModel(DocumentModel doc); 320 321 /** 322 * Resets the search document model, setting it to null so that it's recomputed when calling 323 * {@link #getSearchDocumentModel()} 324 */ 325 void resetSearchDocumentModel(); 326 327 /** 328 * Returns the search document model type as defined in the XML configuration. 329 */ 330 String getSearchDocumentModelType(); 331 332 /** 333 * Returns a sentence to display when this content view is empty 334 * 335 * @since 5.4.2 336 */ 337 String getEmptySentence(); 338 339 /** 340 * Returns a boolean stating if sentence to display is empty has to be translated 341 * 342 * @see #getEmptySentence() 343 * @since 5.4.2 344 */ 345 boolean getTranslateEmptySentence(); 346 347 /** 348 * Returns the sentence to display when content view is waiting for a first execution. 349 * 350 * @since 7.4 351 */ 352 String getWaitForExecutionSentence(); 353 354 /** 355 * Returns true if content view will not display results until an explicit search is executed. 356 * 357 * @see ContentView#isExecuted() 358 * @since 7.4 359 */ 360 boolean isWaitForExecution(); 361 362 /** 363 * Returns true if content view has been executed. 364 * <p> 365 * Execution is detected when either {@link #refreshPageProvider()} or {@link #refreshAndRewindPageProvider()} 366 * methods are called, or when {@link #setExecuted(boolean)} is called explicitely. 367 * 368 * @since 7.4 369 */ 370 boolean isExecuted(); 371 372 /** 373 * Sets the content view execution status. 374 * 375 * @since 7.4 376 */ 377 void setExecuted(boolean executed); 378 379 /** 380 * @since 8.4 381 */ 382 void setQuickFilters(List<QuickFilter> quickFilters); 383 384 /** 385 * @since 8.4 386 */ 387 List<QuickFilter> getQuickFilters(); 388}