Search in sources :

Example 1 with SingleValueTypeFilter

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.SingleValueTypeFilter in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityRequestMapper method extractFiltersAsMap.

/**
 * Some search Filters expect only single value. Others support multiple values for search.
 * This method sorts Filter list and separates filters with single values and return the map with its value.
 * @param filterTypes
 * @return Map<SearchFilter,String> Map of SearchFilter and its value
 * @throws ServiceException
 */
private static Map<SearchFilter, String> extractFiltersAsMap(List<SingleValueTypeFilter> filterTypes) throws ServiceException {
    Set<SearchFilter> filtersWithMultipleValues = FilterMap.getFiltersWhichSupportMultipleValues();
    Map<SearchFilter, String> searchMap = new EnumMap<>(SearchFilter.class);
    for (SingleValueTypeFilter filterType : filterTypes) {
        SearchFilter filter = filterType.getKey();
        if (filtersWithMultipleValues.contains(filter)) {
            throw new ServiceException("Filter provided with Single Value. Application Expects values as List for the Filter :" + filter);
        }
        searchMap.put(filterType.getKey(), filterType.getValue());
    }
    return searchMap;
}
Also used : SingleValueTypeFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SingleValueTypeFilter) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) EnumMap(java.util.EnumMap)

Aggregations

SearchFilter (eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter)1 SingleValueTypeFilter (eu.europa.ec.fisheries.uvms.activity.model.schemas.SingleValueTypeFilter)1 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)1 EnumMap (java.util.EnumMap)1