use of org.ambraproject.wombat.model.SearchFilterItem in project wombat by PLOS.
the class CommonParams method buildActiveFilterItems.
/**
* Creates an instance of {SearchFilterItem} for active filters using url parameters
*
* @param activeFilterItems set of active filter items
* @param parameterMap request's query parameter
* @param filterName name of the filter
* @param filterValues values of the filter
*/
private void buildActiveFilterItems(Set<SearchFilterItem> activeFilterItems, Map<String, String[]> parameterMap, String filterName, String[] filterValues) {
for (String filterValue : filterValues) {
List<String> filterValueList = new ArrayList<>(Arrays.asList(filterValues));
// include the rest of filter values for that specific filter
if (filterValueList.size() > 1) {
filterValueList.remove(filterValue);
}
String displayName;
try {
if (filterName.equals("filterJournals")) {
displayName = siteSet.getJournalNameFromKey(filterValue);
} else {
displayName = filterValue;
}
SearchFilterItem filterItem = SearchFilterItem.builder().setDisplayName(displayName).setNumberOfHits(0).setFilterParamName(filterName).setFilterValue(filterValue).build();
activeFilterItems.add(filterItem);
} catch (UnmatchedSiteException umse) {
log.info("Search on an invalid journal filter: %s".format(filterValue));
}
}
}
Aggregations