001/*
002 *  Copyright 2015 Anyware Services
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 */
016package org.ametys.cms.search.ui.model;
017
018import java.util.Map;
019
020import org.ametys.cms.search.model.SearchModel;
021import org.ametys.runtime.model.ElementDefinition;
022
023/**
024 * Search tool model.
025 */
026public interface SearchUIModel extends SearchModel
027{
028    @Override
029    Map<String, SearchUICriterion> getCriteria(Map<String, Object> contextualParameters);
030    
031    @Override
032    default SearchUICriterion getCriterion(String id, Map<String, Object> contextualParameters)
033    {
034        return getCriteria(contextualParameters).get(id);
035    }
036    
037    @Override
038    Map<String, SearchUICriterion> getFacetedCriteria(Map<String, Object> contextualParameters);
039    
040    @Override
041    default SearchUICriterion getFacetedCriterion(String id, Map<String, Object> contextualParameters)
042    {
043        return getFacetedCriteria(contextualParameters).get(id);
044    }
045    
046    /**
047     * Get the list of search criteria in advanced mode
048     * @param contextualParameters the contextual parameters
049     * @return the list of search criteria in advanced mode
050     */
051    Map<String, SearchUICriterion> getAdvancedCriteria(Map<String, Object> contextualParameters);
052    
053    /**
054     * Get an advanced search criterion by its id.
055     * @param id The advanced search criterion id.
056     * @param contextualParameters the contextual parameters
057     * @return the advanced criterion or <code>null</code> if not found
058     */
059    default SearchUICriterion getAdvancedCriterion(String id, Map<String, Object> contextualParameters)
060    {
061        return getAdvancedCriteria(contextualParameters).get(id);
062    }
063    
064    /**
065     * Get the page size.
066     * @param contextualParameters the contextual parameters.
067     * @return The page size, unlimited or default used when negative or 0.
068     */
069    int getPageSize(Map<String, Object> contextualParameters);
070    
071    /**
072     * Get the URL for search
073     * @param contextualParameters the contextual parameters
074     * @return the URL for search
075     */
076    String getSearchUrl(Map<String, Object> contextualParameters);
077    
078    /**
079     * Get the plugin name for search
080     * @param contextualParameters the contextual parameters
081     * @return the plugin name for search
082     */
083    String getSearchUrlPlugin(Map<String, Object> contextualParameters);
084    
085    /**
086     * Get the URL for CSV export of results
087     * @param contextualParameters the contextual parameters
088     * @return the URL for CSV export
089     */
090    String getExportCSVUrl(Map<String, Object> contextualParameters);
091    
092    /**
093     * Get the plugin name for CSV export of results
094     * @param contextualParameters the contextual parameters
095     * @return the plugin name for CSV export
096     */
097    String getExportCSVUrlPlugin(Map<String, Object> contextualParameters);
098    
099    /**
100     * Get the URL for DOC export of results
101     * @param contextualParameters the contextual parameters
102     * @return the URL for DOC export
103     */
104    String getExportDOCUrl(Map<String, Object> contextualParameters);
105
106    /**
107     * Get the plugin name for DOC export of results
108     * @param contextualParameters the contextual parameters
109     * @return the plugin name for DOC export
110     */
111    String getExportDOCUrlPlugin(Map<String, Object> contextualParameters);
112
113    /**
114     * Get the URL for XML export of results
115     * @param contextualParameters the contextual parameters
116     * @return the URL for XML export
117     */
118    String getExportXMLUrl(Map<String, Object> contextualParameters);
119    
120    /**
121     * Get the plugin name for XML export of results
122     * @param contextualParameters the contextual parameters
123     * @return the plugin name for XML export
124     */
125    String getExportXMLUrlPlugin(Map<String, Object> contextualParameters);
126    
127    /**
128     * Get the URL for PDF export of results
129     * @param contextualParameters the contextual parameters
130     * @return the URL for PDF export
131     */
132    String getExportPDFUrl(Map<String, Object> contextualParameters);
133    
134    /**
135     * Get the plugin name for PDF export of results
136     * @param contextualParameters the contextual parameters
137     * @return the plugin name for PDF export
138     */
139    String getExportPDFUrlPlugin(Map<String, Object> contextualParameters);
140    
141    /**
142     * Get the URL for print results
143     * @param contextualParameters the contextual parameters
144     * @return the URL for print results
145     */
146    String getPrintUrl(Map<String, Object> contextualParameters);
147    
148    /**
149     * Get the plugin name for print results
150     * @param contextualParameters the contextual parameters    
151     * @return the plugin name for print results
152     */
153    String getPrintUrlPlugin(Map<String, Object> contextualParameters);
154    
155    /**
156     * Get the name of the view to use for summary of the content.
157     * @return the name of the view to use for summary of the content. Can be null.
158     */
159    String getSummaryView();
160    
161    /**
162     * Indicates if sorting on join columns which contain at least one {@link ElementDefinition#isMultiple() multiple} {@link ElementDefinition definition} in its path (intermediate ones only) must be allowed.
163     * <br>If the final metadata of the path is multiple, the column will not be sortable though.
164     * @return true if sorting on join columns which contains at least one multiple metadata in its path (intermediate ones only) must be allowed.
165     */
166    default boolean allowSortOnMultipleJoin()
167    {
168        return false;
169    }
170}