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 java.util.ArrayList;
031import java.util.Collection;
032import java.util.List;
033
034/**
035 * Search configuration special for field facets. Extends @see{org.opencms.jsp.search.config.CmsSearchConfigurationFacet}.
036 */
037public class CmsSearchConfigurationFacetRange extends CmsSearchConfigurationFacet
038implements I_CmsSearchConfigurationFacetRange {
039
040    /** The range field to use for the facet. */
041    protected String m_range;
042    /** The start of the complete range. */
043    private String m_start;
044    /** The end of the complete range. */
045    private String m_end;
046    /** The range size for one facet entry. */
047    private String m_gap;
048    /** The method, the range facet is calculated. */
049    private Method m_method;
050    /** Additional information collected by the facet. */
051    private Collection<Other> m_other;
052    /** The value to use for facet.range.hardend. */
053    private boolean m_hardEnd;
054
055    /** Constructor directly setting all configuration values.
056     * @param range The numeric index field to use for the facet.
057     * @param start The begin of the range of the complete facet
058     * @param end The end of the range of the complete facet
059     * @param gap The range of one facet entry
060     * @param other The way how to group other values
061     * @param hardEnd Flag, indicating if the last facet item range should end at <code>end</code> (use <code>true</code>) or extend to the full size of <code>gap</code> (use <code>false</code>).
062     * @param method The method to use for filtering, see the Solr documentation for suitable values.
063     * @param name The name of the facet. If <code>null</code> it defaults to the name of the index field.
064     * @param minCount The minimal number of hits that is necessary to add a term to the facet.
065     * @param label The label that can be shown over the facet entries in your search form.
066     * @param isAndFacet If set to true, the facets filters for results containing all checked entries. Otherwise it filters for results containing at least one checked entry.
067     * @param preselection The list of facet items that should be preselected for the first search.
068     * @param ignoreFilterFromAllFacets A flag, indicating if filters from all facets should be ignored or not.
069     * @param excludeTags The tags (keys) of (filter) queries to be not taken into account for the facet. If "ignoreFiltersFromFacets" is true, the according tags for facets and queries will be added.
070     */
071    public CmsSearchConfigurationFacetRange(
072        final String range,
073        final String start,
074        final String end,
075        final String gap,
076        final Collection<Other> other,
077        final Boolean hardEnd,
078        final Method method,
079        final String name,
080        final Integer minCount,
081        final String label,
082        final Boolean isAndFacet,
083        final List<String> preselection,
084        final Boolean ignoreFilterFromAllFacets,
085        final Collection<String> excludeTags) {
086
087        super(
088            minCount,
089            label,
090            null != name ? name : range,
091            isAndFacet,
092            preselection,
093            ignoreFilterFromAllFacets,
094            excludeTags);
095
096        m_range = range;
097        m_start = start;
098        m_end = end;
099        m_gap = gap;
100        m_other = null == other ? new ArrayList<Other>() : other;
101        m_hardEnd = null == hardEnd ? false : hardEnd.booleanValue();
102        m_method = method;
103    }
104
105    /**
106     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationFacetRange#getEnd()
107     */
108    public String getEnd() {
109
110        return m_end;
111    }
112
113    /**
114     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationFacetRange#getGap()
115     */
116    public String getGap() {
117
118        return m_gap;
119    }
120
121    /**
122     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationFacetRange#getHardEnd()
123     */
124    public boolean getHardEnd() {
125
126        return m_hardEnd;
127    }
128
129    /**
130     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationFacetRange#getMethod()
131     */
132    public Method getMethod() {
133
134        return m_method;
135    }
136
137    /**
138     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationFacetRange#getOther()
139     */
140    public Collection<Other> getOther() {
141
142        return m_other;
143    }
144
145    /**
146     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationFacetRange#getRange()
147     */
148    @Override
149    public String getRange() {
150
151        return m_range;
152    }
153
154    /**
155     * @see org.opencms.jsp.search.config.I_CmsSearchConfigurationFacetRange#getStart()
156     */
157    public String getStart() {
158
159        return m_start;
160    }
161
162}