source: vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/pojo/QueryFacetsSelection.java @ 4528

Last change on this file since 4528 was 4528, checked in by twagoo, 10 years ago

Added search form to the search page

File size: 2.8 KB
Line 
1/*
2 * Copyright (C) 2014 CLARIN
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17package eu.clarin.cmdi.vlo.pojo;
18
19import java.io.Serializable;
20import java.util.Collection;
21import java.util.Collections;
22import java.util.Map;
23
24/**
25 * Represents a query and any number of selected values for zero or more facets
26 *
27 * @author twagoo
28 */
29public class QueryFacetsSelection implements Serializable {
30
31    private String queryString;
32    private final Map<String, Collection<String>> selection;
33
34    /**
35     * Creates an empty selection (no string, no facet values)
36     */
37    public QueryFacetsSelection() {
38        this(null, Collections.<String, Collection<String>>emptyMap());
39    }
40
41    /**
42     * Creates a selection without a query
43     *
44     * @param selection facet values selection map
45     */
46    public QueryFacetsSelection(Map<String, Collection<String>> selection) {
47        this(null, selection);
48    }
49
50    /**
51     * Creates a selection with a textual query and facet value selection
52     *
53     * @param query textual query
54     * @param selection facet values selection map
55     */
56    public QueryFacetsSelection(String query, Map<String, Collection<String>> selection) {
57        this.queryString = query;
58        this.selection = selection;
59    }
60
61    /**
62     *
63     * @return a facet -> values map representing the current selection
64     */
65    public Map<String, Collection<String>> getSelection() {
66        return selection;
67    }
68
69    /**
70     *
71     * @return the facets present in the current selection
72     */
73    public Collection<String> getFacets() {
74        return selection.keySet();
75    }
76
77    /**
78     *
79     * @param facet facet to get values for
80     * @return the selected values for the specified facet
81     */
82    public Collection<String> getSelectionValues(String facet) {
83        return selection.get(facet);
84    }
85
86    /**
87     *
88     * @return the current textual query, may be null in case of no query
89     */
90    public String getQuery() {
91        return queryString;
92    }
93
94    public void setQuery(String queryString) {
95        this.queryString = queryString;
96    }
97   
98    public void selectValues(String facet, Collection<String> values){
99        selection.put(facet, values);
100    }
101
102}
Note: See TracBrowser for help on using the repository browser.