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