Changeset 4543
- Timestamp:
- 02/20/14 16:39:58 (10 years ago)
- Location:
- vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/pojo/QueryFacetsSelection.java
r4528 r4543 20 20 import java.util.Collection; 21 21 import java.util.Collections; 22 import java.util.HashMap; 22 23 import java.util.Map; 23 24 … … 51 52 * Creates a selection with a textual query and facet value selection 52 53 * 53 * @param query textual query 54 * @param selection facet values selection map 54 * @param query textual query (can be null) 55 * @param selection facet values selection map (can be null) 55 56 */ 56 57 public QueryFacetsSelection(String query, Map<String, Collection<String>> selection) { 57 58 this.queryString = query; 58 this.selection = selection; 59 if (selection == null) { 60 this.selection = new HashMap<String, Collection<String>>(); 61 } else { 62 this.selection = selection; 63 } 59 64 } 60 65 … … 95 100 this.queryString = queryString; 96 101 } 97 98 public void selectValues(String facet, Collection<String> values) {102 103 public void selectValues(String facet, Collection<String> values) { 99 104 selection.put(facet, values); 100 105 } -
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/impl/SolrQueryFactoryImpl.java
r4531 r4543 75 75 Map<String, Collection<String>> selections = queryFacetsSelections.getSelection(); 76 76 77 final List<String> encodedQueries = new ArrayList(selections.size()); // assuming every facet has one selection, most common scenario 78 for (Map.Entry<String, Collection<String>> selection : selections.entrySet()) { 79 final String facetName = selection.getKey(); 80 final Collection<String> values = selection.getValue(); 81 if (values != null) { 82 for (String value : values) { 83 encodedQueries.add(String.format("%s:%s", facetName, ClientUtils.escapeQueryChars(value))); 77 if (selections != null) { 78 final List<String> encodedQueries = new ArrayList(selections.size()); // assuming every facet has one selection, most common scenario 79 for (Map.Entry<String, Collection<String>> selection : selections.entrySet()) { 80 final String facetName = selection.getKey(); 81 final Collection<String> values = selection.getValue(); 82 if (values != null) { 83 for (String value : values) { 84 encodedQueries.add(String.format("%s:%s", facetName, ClientUtils.escapeQueryChars(value))); 85 } 84 86 } 85 87 } 88 query.setFilterQueries(encodedQueries.toArray(new String[encodedQueries.size()])); 86 89 } 87 query.setFilterQueries(encodedQueries.toArray(new String[encodedQueries.size()]));88 90 } 89 91 -
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/FacetedSearchPage.java
r4530 r4543 6 6 import eu.clarin.cmdi.vlo.wicket.components.SearchResultsPanel; 7 7 import java.util.Collection; 8 import java.util.Collections; 9 import java.util.HashMap; 8 import java.util.Map; 10 9 import org.apache.wicket.request.mapper.parameter.PageParameters; 11 10 import org.apache.wicket.markup.html.WebPage; … … 24 23 super(parameters); 25 24 26 final QueryFacetsSelection selection = new QueryFacetsSelection( 27 new HashMap<String, Collection<String>>() { 28 { 29 // put("language", Collections.singleton("Dutch")); 30 put("continent", Collections.<String>emptyList()); 31 } 32 }); 25 final QueryFacetsSelection selection = paramsToQueryFacetSelection(parameters); 33 26 final Model<QueryFacetsSelection> queryModel = new Model<QueryFacetsSelection>(selection); 34 27 35 28 add(new FacetsPanel("facets", queryModel)); 36 29 37 30 add(new SearchForm("search", queryModel)); 38 31 39 32 add(new SearchResultsPanel("searchResults", queryModel)); 40 33 } 34 35 private QueryFacetsSelection paramsToQueryFacetSelection(final PageParameters parameters) { 36 final String query = parameters.get("q").toOptionalString(); 37 38 //TODO: Map parameters to facet selection 39 final Map<String, Collection<String>> selection = null; 40 41 return new QueryFacetsSelection(query, selection); 42 } 41 43 }
Note: See TracChangeset
for help on using the changeset viewer.