Commit cd615bd3 authored by Maxym Borodenko's avatar Maxym Borodenko
Browse files

Filter accessions by GeoRegion (changes for feedback)

parent cb7d2630
......@@ -41,4 +41,5 @@ public interface GenesysFilterService {
void listGeoTile(boolean distinct, AppliedFilters filters, Integer limit, int zoom, int xtile, int ytile, RowCallbackHandler rowHandler);
AppliedFilters transformFiltersIfNeed(AppliedFilters appliedFilters);
}
......@@ -25,6 +25,10 @@ public interface GeoRegionService {
GeoRegion getRegion(Country country);
List<GeoRegion> getGeoRegionsForFilter();
List<GeoRegion> conversionToSubRegionsList(GeoRegion parentGeo);
List<GeoRegion> getChildren(String regionIsoCode);
}
......@@ -99,6 +99,9 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
@Autowired
private FilterHandler filterHandler;
@Autowired
private GenesysFilterService filterService;
private final Map<String, Class<?>> clazzMap;
@Autowired
......@@ -160,6 +163,7 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
@Override
public String getBoundingBox(final AppliedFilters filters) {
filterService.transformFiltersIfNeed(filters);
AndFilterBuilder filterBuilder = getFilterBuilder(filters);
final FilterAggregationBuilder builder = AggregationBuilders
......@@ -223,6 +227,8 @@ public class ElasticsearchSearchServiceImpl implements ElasticService, Initializ
*/
@Override
public TermResult termStatisticsAuto(AppliedFilters appliedFilters, String term, int size) throws SearchException {
filterService.transformFiltersIfNeed(appliedFilters);
TermResult termResult = null;
int newSize = size;
do {
......
......@@ -137,6 +137,17 @@ public class FilterHandler {
return null;
}
public List<GenesysFilter> getAdditionalFilters(String[] selectedFilters) {
List<String> gmFilterList = new ArrayList<>();
for (String filter : selectedFilters) {
if (filter.startsWith("gm:")) {
gmFilterList.add(filter);
}
}
String[] gmFilters = gmFilterList.toArray(new String[gmFilterList.size()]);
return selectFilters(gmFilters);
}
public List<GenesysFilter> selectFilters(String[] selectedFilters) {
LOG.debug("Loading filter definitions sel=" + ArrayUtils.toString(selectedFilters));
final List<GenesysFilter> filters = new ArrayList<GenesysFilter>();
......
......@@ -20,6 +20,7 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
......@@ -33,6 +34,7 @@ import org.genesys2.server.model.genesys.Method;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.model.impl.GeoRegion;
import org.genesys2.server.persistence.domain.AccessionRepository;
import org.genesys2.server.persistence.domain.MethodRepository;
import org.genesys2.server.service.CropService;
......@@ -40,6 +42,7 @@ import org.genesys2.server.service.ElasticService;
import org.genesys2.server.service.FilterConstants;
import org.genesys2.server.service.GenesysFilterService;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.GeoRegionService;
import org.genesys2.server.service.GeoService;
import org.genesys2.server.service.InstituteService;
import org.genesys2.server.service.TaxonomyService;
......@@ -99,6 +102,9 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
@Autowired
private ElasticService elasticService;
@Autowired
private GeoRegionService geoRegionService;
@Autowired
public void setDataSource(final DataSource dataSource) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
......@@ -157,6 +163,8 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
}
}
transformFiltersIfNeed(filters);
if (pageable.getPageNumber() > PAGINATION_MAXPAGE_LIMIT) {
throw new RuntimeException("Genesys does not support requests for data beyond " + PAGINATION_MAXPAGE_LIMIT + "th page.");
}
......@@ -197,6 +205,7 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
LOG.debug("Autocomplete " + filter + " ac=" + ac);
}
transformFiltersIfNeed(filters);
Crop crop = null;
{
......@@ -415,4 +424,132 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
}, rowHandler);
}
@Override
public AppliedFilters transformFiltersIfNeed(final AppliedFilters appliedFilters) {
AppliedFilter regionOriginFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("regionOrigin")).findFirst().orElse(null);
AppliedFilter regionHoldInstFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("regionHoldInst")).findFirst().orElse(null);
AppliedFilter countryOriginFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("orgCty.iso3")).findFirst().orElse(null);
AppliedFilter countryHoldInstFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("institute.country.iso3")).findFirst().orElse(null);
List<String> regionHoldInstValues = new ArrayList<>();
if (regionOriginFilter !=null && countryOriginFilter!=null && !countryOriginFilter.getValues().isEmpty()) {
regionHoldInstValues.addAll(getFilterValues(countryOriginFilter));
}
List<String> instituteCountryValues = new ArrayList<>();
if (regionHoldInstFilter !=null && countryHoldInstFilter!=null && !countryHoldInstFilter.getValues().isEmpty()) {
instituteCountryValues.addAll(getFilterValues(countryHoldInstFilter));
}
conversionFiltersFromGeoRegions(appliedFilters);
transformFilterListIfExistsRegionAndCountryInFilters(appliedFilters, regionOriginFilter, countryOriginFilter, regionHoldInstValues);
transformFilterListIfExistsRegionAndCountryInFilters(appliedFilters, regionHoldInstFilter, countryHoldInstFilter, instituteCountryValues);
return appliedFilters;
}
private void transformFilterListIfExistsRegionAndCountryInFilters(final AppliedFilters appliedFilters,
final AppliedFilter regionFilter,
final AppliedFilter countryFilter,
final List<String> regionValues) {
if (regionFilter != null && countryFilter != null && !regionValues.isEmpty()) {
AppliedFilter newCountryFilter = new AppliedFilter();
newCountryFilter.setFilterName(countryFilter.getFilterName());
for (String value : regionValues) {
newCountryFilter.addFilterValue(new FilterHandler.LiteralValueFilter(value));
}
appliedFilters.removeIf(appliedFilter1 -> appliedFilter1.getFilterName().equals(countryFilter.getFilterName()));
appliedFilters.add(newCountryFilter);
}
}
private AppliedFilters conversionFiltersFromGeoRegions(final AppliedFilters appliedFilters) {
AppliedFilter regionOriginFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("regionOrigin")).findFirst().orElse(null);
AppliedFilter regionHoldInstFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("regionHoldInst")).findFirst().orElse(null);
if (regionOriginFilter != null && !regionOriginFilter.getValues().isEmpty()) {
conversionGeoRegionsFilterToAnotherFilter(appliedFilters, regionOriginFilter, "orgCty.iso3");
}
if (regionHoldInstFilter != null && !regionHoldInstFilter.getValues().isEmpty()) {
conversionGeoRegionsFilterToAnotherFilter(appliedFilters, regionHoldInstFilter, "institute.country.iso3");
}
return appliedFilters;
}
private AppliedFilters conversionGeoRegionsFilterToAnotherFilter(final AppliedFilters appliedFilters,
final AppliedFilter oldFilter,
final String anotherFilterName) {
List<GeoRegion> geoRegionList = new ArrayList<>();
List<Country> countryList = new ArrayList<>();
Set<String> countryIsoList = new HashSet<>();
for (String isoCode: getFilterValues(oldFilter)) {
GeoRegion geoRegion = geoRegionService.find(isoCode);
if (geoRegion != null) {
if (geoRegion.getParentRegion().getName().equals("Americas") ||
geoRegion.getParentRegion().getName().equals("World")) {
geoRegionList.addAll(geoRegionService.conversionToSubRegionsList(geoRegion));
} else {
geoRegionList.add(geoRegionService.find(isoCode));
}
}
}
if (!geoRegionList.isEmpty()) {
for (GeoRegion geoRegion: geoRegionList) {
countryList.addAll(geoRegion.getCountries());
}
}
if (!countryList.isEmpty()) {
for (Country country: countryList) {
countryIsoList.add(country.getCode3());
}
}
if (!countryIsoList.isEmpty()) {
AppliedFilter orgCtyFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals(anotherFilterName))
.findFirst().orElse(new AppliedFilter().setFilterName(anotherFilterName));
if (!orgCtyFilter.getValues().isEmpty())
countryIsoList.addAll(getFilterValues(orgCtyFilter));
for (String isoCode: countryIsoList) {
orgCtyFilter.addFilterValue(new FilterHandler.LiteralValueFilter(isoCode));
}
appliedFilters.removeIf(appliedFilter1 -> appliedFilter1.getFilterName().equals(oldFilter.getFilterName()));
if (!appliedFilters.hasFilter(anotherFilterName))
appliedFilters.add(orgCtyFilter);
}
return appliedFilters;
}
private Set<String> getFilterValues(final AppliedFilter appliedFilter) {
Set<String> literals = new HashSet<>();
for (FilterHandler.FilterValue filterValue : appliedFilter.getValues()) {
if (filterValue instanceof FilterHandler.LiteralValueFilter) {
FilterHandler.LiteralValueFilter literal = (FilterHandler.LiteralValueFilter) filterValue;
literals.add(literal.getValue().toString());
}
}
return literals;
}
}
......@@ -20,6 +20,7 @@ import org.genesys2.server.service.worker.GeoRegionDataCLDR;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.xml.sax.SAXException;
......@@ -140,6 +141,40 @@ public class GeoRegionServiceImpl implements GeoRegionService {
}
}
@Override
public List<GeoRegion> getGeoRegionsForFilter() {
List<GeoRegion> geoRegionList = findAll();
geoRegionList.removeIf(geoRegion -> geoRegion.getName().equals("World") || geoRegion.getName().equals("Americas"));
List<GeoRegion> resultList = new ArrayList<>();
for (GeoRegion geoRegion: geoRegionList) {
if (geoRegion.getParentRegion().getName().equals("World") || geoRegion.getParentRegion().getName().equals("Americas")) {
geoRegion.setParentRegion(null);
resultList.add(geoRegion);
}
else resultList.add(geoRegion);
}
Locale locale = LocaleContextHolder.getLocale();
resultList.sort(Comparator.comparing(o -> o.getName(locale)));
return resultList;
}
@Override
public List<GeoRegion> conversionToSubRegionsList(final GeoRegion parentGeo) {
List<GeoRegion> geoRegionList = findAll();
List<GeoRegion> subRegionsList = new ArrayList<>();
geoRegionList.removeIf(geoRegion -> geoRegion.getName().equals("World"));
subRegionsList.addAll(geoRegionList.stream().
filter(geoRegion -> parentGeo.getName().equals(geoRegion.getParentRegion().getName()))
.collect(Collectors.toList()));
return subRegionsList;
}
private boolean isChild(GeoRegion region, String parentIsoCode) {
return region.getParentRegion() != null && (region.getParentRegion().getIsoCode().equals(parentIsoCode) || isChild(region.getParentRegion(), parentIsoCode));
......
......@@ -154,6 +154,7 @@ public class MappingServiceImpl implements MappingService {
@Override
@Cacheable(value = "tileserver", key = "'tile-' + #zoom + '-' + #xtile + '-' + #ytile + '-' + #filters")
public byte[] getTile(AppliedFilters filters, final int zoom, final int xtile, final int ytile) {
filterService.transformFiltersIfNeed(filters);
final BufferedImage bi = new BufferedImage(256, 256, BufferedImage.TYPE_INT_ARGB);
// final int pixelSize = (int) Math.round(1.0 + (1 << (zoom / 2))) / 2;
......
......@@ -28,12 +28,10 @@ import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.TreeMap;
import javax.imageio.ImageIO;
......@@ -129,7 +127,7 @@ public class ExplorerController extends BaseController implements InitializingBe
private GeoService geoService;
@Autowired
GeoRegionService geoRegionService;
private GeoRegionService geoRegionService;
private final ObjectMapper mapper = new ObjectMapper();
......@@ -196,9 +194,8 @@ public class ExplorerController extends BaseController implements InitializingBe
_logger.debug("Filtering by: " + jsonFilter);
AppliedFilters appliedFilters = mapper.readValue(jsonFilter, AppliedFilters.class);
final AppliedFilters storedTransformedFilters = conversionFiltersFromGeoRegions(appliedFilters);
appliedFilters = storedTransformedFilters;
final AppliedFilters storedTransformedFilters = filterService.transformFiltersIfNeed(appliedFilters);
Crop crop = null;
{
String shortName = appliedFilters.getFirstLiteralValue(FilterConstants.CROPS, String.class);
......@@ -220,7 +217,7 @@ public class ExplorerController extends BaseController implements InitializingBe
selectedFilters = appliedFilters.getFilterNames();
final List<GenesysFilter> currentFilters = filterHandler.selectFilters(selectedFilters);
final Map<String, GenesysFilter> availableFilters = filterHandler.mapAvailableFilters();
final List<GenesysFilter> additionalFilters = getAdditionalFilters(selectedFilters);
final List<GenesysFilter> additionalFilters = filterHandler.getAdditionalFilters(selectedFilters);
//assign suggested values instead of all values to the list filters
GenesysFilter filter = availableFilters.get(FilterConstants.SAMPSTAT);
......@@ -259,7 +256,6 @@ public class ExplorerController extends BaseController implements InitializingBe
_logger.debug(appliedFilters.toString());
}
transformFiltersIfNeed(appliedFilters);
final Page<AccessionDetails> accessions = filterService.listAccessionDetails(appliedFilters, new PageRequest(page - 1, results, new Sort("seqNo")));
if (_logger.isDebugEnabled()) {
......@@ -270,7 +266,7 @@ public class ExplorerController extends BaseController implements InitializingBe
model.addAttribute("crop", crop);
model.addAttribute("filters", filters);
model.addAttribute("jsonFilter", tempFilters.toString());
model.addAttribute("jsonFilter", jsonFilter);
model.addAttribute("availableColumns", validDisplayColumns);
model.addAttribute("selectedColumns", cleanupDisplayColumns(columns, cookieColumns, response));
model.addAttribute("crops", getCrops(appliedFilters));
......@@ -279,27 +275,11 @@ public class ExplorerController extends BaseController implements InitializingBe
model.addAttribute("currentFilters", currentFilters);
model.addAttribute("additionalFilters", additionalFilters);
model.addAttribute("availableFilters", availableFilters);
model.addAttribute("geoRegions", getGeoRegions());
model.addAttribute("geoRegions", geoRegionService.getGeoRegionsForFilter());
return "/accession/explore2";
}
private List<GeoRegion> getGeoRegions() {
List<GeoRegion> geoRegionList = geoRegionService.findAll();
geoRegionList.removeIf(geoRegion -> geoRegion.getName().equals("World") || geoRegion.getName().equals("Americas"));
List<GeoRegion> resultList = new ArrayList<>();
for (GeoRegion geoRegion: geoRegionList) {
if (geoRegion.getParentRegion().getName().equals("World") || geoRegion.getParentRegion().getName().equals("Americas")) {
geoRegion.setParentRegion(null);
resultList.add(geoRegion);
}
else resultList.add(geoRegion);
}
return resultList;
}
private AppliedFilters getAppliedFilters (final AppliedFilters filters) {
AppliedFilters newAppliedFilters = new AppliedFilters();
for (AppliedFilter appliedFilter: filters) {
......@@ -330,11 +310,9 @@ public class ExplorerController extends BaseController implements InitializingBe
AppliedFilters tempFilters = mapper.readValue(jsonFilter, AppliedFilters.class);
// Composition overview
appliedFilters = transformFiltersIfNeed(appliedFilters);
model.addAttribute("crops", getCrops(appliedFilters));
appliedFilters = mapper.readValue(jsonFilter, AppliedFilters.class);
appliedFilters = transformFiltersIfNeed(appliedFilters);
model.addAttribute("appliedFilters", tempFilters);
model.addAttribute("accessionCount", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.INSTCODE, 10).getTotalCount());
......@@ -344,7 +322,7 @@ public class ExplorerController extends BaseController implements InitializingBe
overviewHistoric(model, appliedFilters);
overviewManagement(model, appliedFilters);
overviewSources(model, appliedFilters);
model.addAttribute("geoRegions", getGeoRegions());
model.addAttribute("geoRegions", geoRegionService.getGeoRegionsForFilter());
return "/accession/overview";
}
......@@ -369,7 +347,7 @@ public class ExplorerController extends BaseController implements InitializingBe
AppliedFilters appliedFilters2 = mapper.readValue(jsonFilter, AppliedFilters.class);
String[] selectedFilters = appliedFilters.getFilterNames();
final List<GenesysFilter> currentFilters = filterHandler.selectFilters(selectedFilters);
final List<GenesysFilter> additionalFilters = getAdditionalFilters(selectedFilters);
final List<GenesysFilter> additionalFilters = filterHandler.getAdditionalFilters(selectedFilters);
final Map<?, ?> filters = mapper.readValue(appliedFilters.toString(), Map.class);
final Map<String, GenesysFilter> availableFilters = filterHandler.mapAvailableFilters();
......@@ -377,13 +355,11 @@ public class ExplorerController extends BaseController implements InitializingBe
model.addAttribute("availableFilters", availableFilters);
model.addAttribute("currentFilters", currentFilters);
model.addAttribute("jsonFilter", appliedFilters.toString());
model.addAttribute("jsonFilter", jsonFilter);
model.addAttribute("filters", filters);
model.addAttribute("additionalFilters", additionalFilters);
model.addAttribute("appliedFilters", getAppliedFilters(appliedFilters2));
model.addAttribute("geoRegions", getGeoRegions());
transformFiltersIfNeed(tempFilters);
model.addAttribute("geoRegions", geoRegionService.getGeoRegionsForFilter());
model.addAttribute("crops", getCrops(tempFilters));
return "/accession/map";
......@@ -396,8 +372,6 @@ public class ExplorerController extends BaseController implements InitializingBe
throws IOException, SearchException {
AppliedFilters appliedFilters = mapper.readValue(jsonFilter, AppliedFilters.class);
transformFiltersIfNeed(appliedFilters);
Map<String, TermResult> pageData = new HashMap<>();
pageData.put("statsInstCode", elasticService.termStatisticsAuto(appliedFilters, FilterConstants.INSTCODE, 20));
......@@ -458,129 +432,9 @@ public class ExplorerController extends BaseController implements InitializingBe
@RequestParam(value = "filter", required = true, defaultValue = "{}") String jsonFilter,
@RequestParam(value = "results", required = true, defaultValue = "50") int results) throws IOException, SearchException {
AppliedFilters appliedFilters = mapper.readValue(jsonFilter, AppliedFilters.class);
transformFiltersIfNeed(appliedFilters);
return filterService.listAccessionDetails(appliedFilters, new PageRequest(page - 1, results, new Sort("seqNo")));
}
private AppliedFilters transformFiltersIfNeed(final AppliedFilters appliedFilters) {
AppliedFilter regionOriginFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("regionOrigin")).findFirst().orElse(null);
AppliedFilter regionHoldInstFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("regionHoldInst")).findFirst().orElse(null);
AppliedFilter countryOriginFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("orgCty.iso3")).findFirst().orElse(null);
AppliedFilter countryHoldInstFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("institute.country.iso3")).findFirst().orElse(null);
List<String> regionHoldInstValues = new ArrayList<>();
if (regionOriginFilter !=null && countryOriginFilter!=null && !countryOriginFilter.getValues().isEmpty()) {
regionHoldInstValues.addAll(getFilterValues(countryOriginFilter));
}
List<String> instituteCountryValues = new ArrayList<>();
if (regionHoldInstFilter !=null && countryHoldInstFilter!=null && !countryHoldInstFilter.getValues().isEmpty()) {
instituteCountryValues.addAll(getFilterValues(countryHoldInstFilter));
}
conversionFiltersFromGeoRegions(appliedFilters);
transformFilterListIfExistsRegionAndCountryInFilters(appliedFilters, regionOriginFilter, countryOriginFilter, regionHoldInstValues);
transformFilterListIfExistsRegionAndCountryInFilters(appliedFilters, regionHoldInstFilter, countryHoldInstFilter, instituteCountryValues);
return appliedFilters;
}
private void transformFilterListIfExistsRegionAndCountryInFilters(final AppliedFilters appliedFilters,
final AppliedFilter regionFilter,
final AppliedFilter countryFilter,
final List<String> regionValues) {
if (regionFilter != null && countryFilter != null && !regionValues.isEmpty()) {
AppliedFilter newCountryFilter = new AppliedFilter();
newCountryFilter.setFilterName(countryFilter.getFilterName());
for (String value : regionValues) {
newCountryFilter.addFilterValue(new FilterHandler.LiteralValueFilter(value));
}
appliedFilters.removeIf(appliedFilter1 -> appliedFilter1.getFilterName().equals(countryFilter.getFilterName()));
appliedFilters.add(newCountryFilter);
}
}
private AppliedFilters conversionFiltersFromGeoRegions(final AppliedFilters appliedFilters) {
AppliedFilter regionOriginFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("regionOrigin")).findFirst().orElse(null);
AppliedFilter regionHoldInstFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals("regionHoldInst")).findFirst().orElse(null);
if (regionOriginFilter != null && !regionOriginFilter.getValues().isEmpty()) {
conversionGeoRegionsFilterToAnotherFilter(appliedFilters, regionOriginFilter, "orgCty.iso3");
}
if (regionHoldInstFilter != null && !regionHoldInstFilter.getValues().isEmpty()) {
conversionGeoRegionsFilterToAnotherFilter(appliedFilters, regionHoldInstFilter, "institute.country.iso3");
}
return appliedFilters;
}
private AppliedFilters conversionGeoRegionsFilterToAnotherFilter(final AppliedFilters appliedFilters,
final AppliedFilter oldFilter,
final String anotherFilterName) {
List<GeoRegion> geoRegionList = new ArrayList<>();
List<Country> countryList = new ArrayList<>();
Set<String> countryIsoList = new HashSet<>();
for (String isoCode: getFilterValues(oldFilter)) {
geoRegionList.add(geoRegionService.find(isoCode));
}
if (!geoRegionList.isEmpty()) {
for (GeoRegion geoRegion: geoRegionList) {
countryList.addAll(geoRegion.getCountries());
}
}
if (!countryList.isEmpty()) {
for (Country country: countryList) {
countryIsoList.add(country.getCode3());
}
}
if (!countryIsoList.isEmpty()) {
AppliedFilter orgCtyFilter = appliedFilters.stream()
.filter(filter -> filter.getFilterName().equals(anotherFilterName))
.findFirst().orElse(new AppliedFilter().setFilterName(anotherFilterName));
if (!orgCtyFilter.getValues().isEmpty())
countryIsoList.addAll(getFilterValues(orgCtyFilter));
for (String isoCode: countryIsoList) {
orgCtyFilter.addFilterValue(new FilterHandler.LiteralValueFilter(isoCode));
}
appliedFilters.removeIf(appliedFilter1 -> appliedFilter1.getFilterName().equals(oldFilter.getFilterName()));
if (!appliedFilters.hasFilter(anotherFilterName))
appliedFilters.add(orgCtyFilter);
}
return appliedFilters;
}
private Set<String> getFilterValues(final AppliedFilter appliedFilter) {
Set<String> literals = new HashSet<>();
for (FilterHandler.FilterValue filterValue : appliedFilter.getValues()) {
if (filterValue instanceof FilterHandler.LiteralValueFilter) {
FilterHandler.LiteralValueFilter literal = (FilterHandler.LiteralValueFilter) filterValue;
literals.add(literal.getValue().toString());
}
}
return literals;
}
@RequestMapping(value = "/explore/booleanSuggestions", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Map<String, Map<String, Integer>> getBooleanSuggestions(@RequestParam