Changeset 4968
- Timestamp:
- 04/14/14 12:57:31 (10 years ago)
- Location:
- vlo/branches/vlo-3.0/vlo-web-app/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/service/solr/impl/QueryFacetsSelectionParametersConverter.java
r4967 r4968 102 102 103 103 // put all selections in 'fq' parameters 104 for (Entry<String, FacetSelection> facetSelection : selection.getSelection().entrySet()) { 105 //Assuming AND 106 //TODO: encode NOT,OR 107 for (String value : facetSelection.getValue().getValues()) { 108 params.add(FILTER_QUERY, String.format("%s:%s", facetSelection.getKey(), value)); 104 for (Entry<String, FacetSelection> facetSelectionEntry : selection.getSelection().entrySet()) { 105 final String facet = facetSelectionEntry.getKey(); 106 final FacetSelection facetSelection = facetSelectionEntry.getValue(); 107 // put a parameter for the selection type (unless it is AND which is default) 108 if (facetSelection.getSelectionType() != FacetSelectionType.AND) { 109 params.add(FILTER_QUERY_TYPE, String.format("%s:%s", facet, facetSelection.getSelectionType().toString().toLowerCase())); 110 } 111 for (String value : facetSelection.getValues()) { 112 //TODO: Encode? 113 params.add(FILTER_QUERY, String.format("%s:%s", facet, value)); 109 114 } 110 115 } -
vlo/branches/vlo-3.0/vlo-web-app/src/test/java/eu/clarin/cmdi/vlo/service/impl/QueryFacetsSelectionParametersConverterTest.java
r4967 r4968 110 110 final String query = "query"; 111 111 final Map<String, FacetSelection> map = Maps.newHashMapWithExpectedSize(3); 112 map.put("facet1", new FacetSelection(Arrays.asList("valueA", "valueB"))); 113 map.put("facet2", new FacetSelection(Collections.singleton("valueC"))); 112 map.put("facet1", new FacetSelection(FacetSelectionType.OR, Arrays.asList("valueA", "valueB"))); 113 map.put("facet2", new FacetSelection(FacetSelectionType.AND, Collections.singleton("valueC"))); 114 map.put("facet3", new FacetSelection(FacetSelectionType.NOT_EMPTY)); 114 115 115 116 QueryFacetsSelection selection = new QueryFacetsSelection(query, map); … … 123 124 assertThat(fq, hasItem(StringValue.valueOf("facet1:valueB"))); 124 125 assertThat(fq, hasItem(StringValue.valueOf("facet2:valueC"))); 126 127 final List<StringValue> fqType = result.getValues("fqType"); 128 assertNotNull(fqType); 129 assertThat(fqType, hasItem(StringValue.valueOf("facet1:or"))); 130 //facet 2 is AND, which is default and should not be encoded 131 assertThat(fqType, hasItem(StringValue.valueOf("facet3:not_empty"))); 125 132 } 126 133
Note: See TracChangeset
for help on using the changeset viewer.