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;
021
022/**
023 * Search tool model.
024 */
025public interface SearchUIModel extends SearchModel
026{
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    @Override
047    Map<String, SearchUIColumn> getResultFields(Map<String, Object> contextualParameters);
048    
049    @Override
050    default SearchUIColumn getResultField(String id, Map<String, Object> contextualParameters)
051    {
052        return getResultFields(contextualParameters).get(id);
053    }
054    
055    /**
056     * Get the list of search criteria in advanced mode
057     * @param contextualParameters the contextual parameters
058     * @return the list of search criteria in advanced mode
059     */
060    Map<String, SearchUICriterion> getAdvancedCriteria(Map<String, Object> contextualParameters);
061    
062    /**
063     * Get an advanced search criterion by its id.
064     * @param id The advanced search criterion id.
065     * @param contextualParameters the contextual parameters
066     * @return the advanced criterion or <code>null</code> if not found
067     */
068    default SearchUICriterion getAdvancedCriterion(String id, Map<String, Object> contextualParameters)
069    {
070        return getAdvancedCriteria(contextualParameters).get(id);
071    }
072    
073    /**
074     * Get the page size.
075     * @param contextualParameters the contextual parameters.
076     * @return The page size, unlimited or default used when negative or 0.
077     */
078    int getPageSize(Map<String, Object> contextualParameters);
079    
080    /**
081     * Get the specific workspace to use.
082     * @param contextualParameters the contextual parameters.
083     * @return the workspace to use when searching, or null to use the default workspace.
084     */
085    String getWorkspace(Map<String, Object> contextualParameters);
086    
087    /**
088     * Get the URL for search
089     * @param contextualParameters the contextual parameters
090     * @return the URL for search
091     */
092    String getSearchUrl(Map<String, Object> contextualParameters);
093    
094    /**
095     * Get the plugin name for search
096     * @param contextualParameters the contextual parameters
097     * @return the plugin name for search
098     */
099    String getSearchUrlPlugin(Map<String, Object> contextualParameters);
100    
101    /**
102     * Get the URL for CVS export of results
103     * @param contextualParameters the contextual parameters
104     * @return the URL for CVS export
105     */
106    String getExportCSVUrl(Map<String, Object> contextualParameters);
107    
108    /**
109     * Get the plugin name for CVS export of results
110     * @param contextualParameters the contextual parameters
111     * @return the plugin name for CVS export
112     */
113    String getExportCSVUrlPlugin(Map<String, Object> contextualParameters);
114    
115    /**
116     * Get the URL for XML export of results
117     * @param contextualParameters the contextual parameters
118     * @return the URL for XML export
119     */
120    String getExportXMLUrl(Map<String, Object> contextualParameters);
121    
122    /**
123     * Get the plugin name for XML export of results
124     * @param contextualParameters the contextual parameters
125     * @return the plugin name for XML export
126     */
127    String getExportXMLUrlPlugin(Map<String, Object> contextualParameters);
128    
129    /**
130     * Get the URL for print results
131     * @param contextualParameters the contextual parameters
132     * @return the URL for print results
133     */
134    String getPrintUrl(Map<String, Object> contextualParameters);
135    
136    /**
137     * Get the plugin name for print results
138     * @param contextualParameters the contextual parameters    
139     * @return the plugin name for print results
140     */
141    String getPrintUrlPlugin(Map<String, Object> contextualParameters);
142    
143}