001/*
002 * (C) Copyright 2014 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 *     Thomas Roger
018 *     Nelson Silva
019 */
020
021package org.nuxeo.search.ui;
022
023import java.util.List;
024
025import org.nuxeo.ecm.core.api.CoreSession;
026import org.nuxeo.ecm.core.api.DocumentModel;
027import org.nuxeo.ecm.platform.actions.ActionContext;
028import org.nuxeo.ecm.platform.contentview.jsf.ContentViewHeader;
029import org.nuxeo.ecm.platform.contentview.jsf.ContentViewState;
030
031/**
032 * Service handling contributed searches and related saved searches.
033 *
034 * @since 6.0
035 */
036public interface SearchUIService {
037
038    /**
039     * Returns the list of Content view headers associated to a search.
040     */
041    List<ContentViewHeader> getContentViewHeaders(ActionContext actionContext);
042
043    /**
044     * Returns the list of Content view headers associated to a search and depending of a local configuration.
045     */
046    List<ContentViewHeader> getContentViewHeaders(ActionContext actionContext, DocumentModel doc);
047
048    /**
049     * Save the current search in the user workspace with the given title.
050     *
051     * @param session the {@code CoreSession} to use
052     * @param searchContentViewState the search to save
053     * @param title the title of the being saved search
054     * @return the saved search DocumentModel
055     */
056    DocumentModel saveSearch(CoreSession session, ContentViewState searchContentViewState, String title);
057
058    /**
059     * Returns the current user saved searches, located into its own user workspace.
060     */
061    List<DocumentModel> getCurrentUserSavedSearches(CoreSession session);
062
063    /**
064     * Returns all the accessible saved searches except the ones for the current user.
065     */
066    List<DocumentModel> getSharedSavedSearches(CoreSession session);
067
068    /**
069     * Load the content view state for a given saved search.
070     *
071     * @since 7.3
072     */
073    ContentViewState loadSearch(DocumentModel savedSearch);
074}