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

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

Simplified model by merging FacetSelection? into QueryFacetsSelection?

File size: 2.5 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 *
26 * @author twagoo
27 */
28public class QueryFacetsSelection implements Serializable {
29
30    private final String queryString;
31    private final Map<String, Collection<String>> selection;
32
33    /**
34     * creates an empty selection (no string, no facet values)
35     */
36    public QueryFacetsSelection() {
37        this(null, Collections.<String, Collection<String>>emptyMap());
38    }
39
40    /**
41     * creates a selection without a query
42     *
43     * @param selection facet values selection map
44     */
45    public QueryFacetsSelection(Map<String, Collection<String>> selection) {
46        this(null, selection);
47    }
48
49    /**
50     * creates a selection with a textual query and facet value selection
51     *
52     * @param query textual query
53     * @param selection facet values selection map
54     */
55    public QueryFacetsSelection(String query, Map<String, Collection<String>> selection) {
56        this.queryString = query;
57        this.selection = selection;
58    }
59
60    /**
61     *
62     * @return a facet -> values map representing the current selection
63     */
64    public Map<String, Collection<String>> getSelection() {
65        return selection;
66    }
67
68    /**
69     *
70     * @return the facets present in the current selection
71     */
72    public Collection<String> getFacets() {
73        return selection.keySet();
74    }
75
76    /**
77     *
78     * @param facet facet to get values for
79     * @return the selected values for the specified facet
80     */
81    public Collection<String> getSelectionValues(String facet) {
82        return selection.get(facet);
83    }
84
85    /**
86     *
87     * @return the current textual query, may be null in case of no query
88     */
89    public String getQuery() {
90        return queryString;
91    }
92
93}
Note: See TracBrowser for help on using the repository browser.