001/*
002 *  Copyright 2017 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.web.frontoffice;
017
018import java.util.Collection;
019import java.util.List;
020import java.util.Set;
021
022import org.apache.cocoon.environment.Request;
023
024import org.ametys.cms.search.query.Query;
025import org.ametys.web.frontoffice.FrontOfficeSearcherFactory.QueryFacet;
026
027/**
028 * Modify the FO search query.<br>
029 */
030public interface QueryAdapterFOSearch
031{
032    /** Minimum priority. */
033    public static final int MIN_PRIORITY = Integer.MAX_VALUE;
034    /** Maximum priority. */
035    public static final int MAX_PRIORITY = 0;
036    
037    /**
038     * Modify the FO search query.
039     * @param query the initial query
040     * @param request The request
041     * @param siteNames The site names.
042     * @param language The language
043     * @return the new modify query
044     */
045    Query modifyQuery(Query query, Request request, Collection<String> siteNames, String language);
046    
047    /**
048     * Modify the site query.
049     * @param siteQuery the initial site query
050     * @param request The request
051     * @param siteNames The site names.
052     * @param language The language
053     * @return the new modify site query
054     */
055    Query modifySiteQueryFilter(Query siteQuery, Request request, Collection<String> siteNames, String language);
056    
057    /**
058     * Modify the sitemap query.
059     * @param sitemapQuery the initial sitemap query
060     * @param request The request
061     * @param siteNames The site names.
062     * @param language The language
063     * @return the new modify site query
064     */
065    Query modifySitemapQueryFilter(Query sitemapQuery, Request request, Collection<String> siteNames, String language);
066    
067    /**
068     * Modify the query facets
069     * @param queryFacets the initial query facets
070     * @param request the request
071     * @return the new query facets
072     */
073    Set<QueryFacet> modifyQueryFacets(Set<QueryFacet> queryFacets, Request request);
074    
075    /**
076     * Add document type
077     * @param documentTypes the document types
078     */
079    void addDocumentType(List<String> documentTypes);
080    
081    /**
082     * Retrieves the priority to modify the query.<br>
083     * This can be used to process a query modification before an other.
084     * @return the priority where 0 the max priority and Integer.MAX_VALUE the min priority.
085     */
086    int getPriority();
087    
088}