001/*
002 * This library is part of OpenCms -
003 * the Open Source Content Management System
004 *
005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com)
006 *
007 * This library is free software; you can redistribute it and/or
008 * modify it under the terms of the GNU Lesser General Public
009 * License as published by the Free Software Foundation; either
010 * version 2.1 of the License, or (at your option) any later version.
011 *
012 * This library is distributed in the hope that it will be useful,
013 * but WITHOUT ANY WARRANTY; without even the implied warranty of
014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015 * Lesser General Public License for more details.
016 *
017 * For further information about Alkacon Software, please see the
018 * company website: http://www.alkacon.com
019 *
020 * For further information about OpenCms, please see the
021 * project website: http://www.opencms.org
022 *
023 * You should have received a copy of the GNU Lesser General Public
024 * License along with this library; if not, write to the Free Software
025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
026 */
027
028package org.opencms.jsp.search.config;
029
030import org.opencms.util.CmsStringUtil;
031
032/**
033 * The interface a Geo filter configuration must implement.
034 */
035public interface I_CmsSearchConfigurationGeoFilter {
036
037    /** The default name of the coordinates parameter. */
038    String DEFAULT_COORDINATES_PARAM = "coordinates";
039
040    /** The default name of the Solr field where coordinates are stored. */
041    String DEFAULT_FIELD_NAME = "geocoords_loc";
042
043    /** The default name of the radius parameter. */
044    String DEFAULT_RADIUS_PARAM = "radius";
045
046    /** The default units of the search radius. */
047    String DEFAULT_UNITS = "km";
048
049    /** The default name of the units parameter. */
050    String DEFAULT_UNITS_PARAM = "units";
051
052    /**
053     * Returns the coordinates.
054     * @return the coordinates
055     */
056    String getCoordinates();
057
058    /**
059     * Returns the name of the coordinates parameter.
060     * @return the name of the coordinates parameter
061     */
062    String getCoordinatesParam();
063
064    /**
065     * Returns the Solr field name storing the coordinates.
066     * @return the Solr field name storing the coordinates
067     */
068    String getFieldName();
069
070    /**
071     * Returns the radius.
072     * @return the radius
073     */
074    String getRadius();
075
076    /**
077     * Returns the name of the radius parameter.
078     * @return the name of the radius parameter
079     */
080    String getRadiusParam();
081
082    /**
083     * Returns the units the search radius uses, either kilometers (km) or miles (mi).
084     * @return the search radius units
085     */
086    String getUnits();
087
088    /**
089     * Returns the name of the units parameter.
090     * @return the name of the units parameter
091     */
092    String getUnitsParam();
093
094    /**
095     * Returns whether this Geo filter configuration has a valid Geo filter set.
096     * @return whether this configuration has a valid Geo filter set or not
097     */
098    default boolean hasGeoFilter() {
099
100        return !CmsStringUtil.isEmptyOrWhitespaceOnly(getCoordinates())
101            && !CmsStringUtil.isEmptyOrWhitespaceOnly(getRadius());
102    }
103}