Search in sources :

Example 6 with SearchFilter

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter 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)

Example 7 with SearchFilter

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

the class FishingActivityDaoTest method testGetFishingActivityListByQuery.

@Test
@SneakyThrows
public void testGetFishingActivityListByQuery() throws Exception {
    dbSetupTracker.skipNextLaunch();
    FishingActivityQuery query = new FishingActivityQuery();
    Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
    Map<SearchFilter, List<String>> searchCriteriaMapMultiVal = new HashMap<>();
    List<String> activityTypeValues = new ArrayList<>();
    activityTypeValues.add("FISHING_OPERATION");
    activityTypeValues.add("DEPARTURE");
    searchCriteriaMapMultiVal.put(SearchFilter.ACTIVITY_TYPE, activityTypeValues);
    query.setSearchCriteriaMapMultipleValues(searchCriteriaMapMultiVal);
    searchCriteriaMap.put(SearchFilter.OWNER, "OWNER1");
    searchCriteriaMap.put(SearchFilter.PERIOD_START, "2012-05-27T07:47:31");
    searchCriteriaMap.put(SearchFilter.PERIOD_END, "2015-05-27T07:47:31");
    searchCriteriaMap.put(SearchFilter.VESSEL_NAME, "vessel1");
    searchCriteriaMap.put(SearchFilter.VESSEL_IDENTIFIRE, "CFR123");
    searchCriteriaMap.put(SearchFilter.REPORT_TYPE, "DECLARATION");
    searchCriteriaMap.put(SearchFilter.GEAR, "GEAR_TYPE");
    searchCriteriaMap.put(SearchFilter.SPECIES, "PLE");
    searchCriteriaMap.put(SearchFilter.MASTER, "MARK");
    searchCriteriaMap.put(SearchFilter.AREAS, "27.4.b");
    // searchCriteriaMap.put(SearchFilter.PORT, "GBR");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MIN, "0");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MAX, "25");
    query.setSearchCriteriaMap(searchCriteriaMap);
    PaginationDto pagination = new PaginationDto();
    pagination.setPageSize(2);
    pagination.setOffset(1);
    query.setPagination(pagination);
    SortKey sortingDto = new SortKey();
    sortingDto.setSortBy(SearchFilter.OCCURRENCE);
    sortingDto.setReversed(false);
    query.setSorting(sortingDto);
    List<FishingActivityEntity> finishingActivityList = dao.getFishingActivityListByQuery(query);
    System.out.println("done:" + finishingActivityList.size());
    assertNotNull(finishingActivityList);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PaginationDto(eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) SortKey(eu.europa.ec.fisheries.ers.service.search.SortKey) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 8 with SearchFilter

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

the class FishingActivityDaoTest method testGetFishingActivityListByQuery_GetByFaReportID.

@Test
@SneakyThrows
public void testGetFishingActivityListByQuery_GetByFaReportID() throws Exception {
    dbSetupTracker.skipNextLaunch();
    FishingActivityQuery query = new FishingActivityQuery();
    Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
    Map<SearchFilter, List<String>> searchCriteriaMapMultiVal = new HashMap<>();
    List<String> activityTypeValues = new ArrayList<>();
    activityTypeValues.add("FISHING_OPERATION");
    activityTypeValues.add("DEPARTURE");
    searchCriteriaMapMultiVal.put(SearchFilter.ACTIVITY_TYPE, activityTypeValues);
    List<String> purposeCodeValues = new ArrayList<>();
    purposeCodeValues.add("5");
    purposeCodeValues.add("9");
    searchCriteriaMapMultiVal.put(SearchFilter.PURPOSE, purposeCodeValues);
    query.setSearchCriteriaMapMultipleValues(searchCriteriaMapMultiVal);
    searchCriteriaMap.put(SearchFilter.OWNER, "OWNER1");
    searchCriteriaMap.put(SearchFilter.PERIOD_START, "2012-05-27T07:47:31");
    searchCriteriaMap.put(SearchFilter.PERIOD_END, "2015-05-27T07:47:31");
    searchCriteriaMap.put(SearchFilter.VESSEL_NAME, "vessel1");
    searchCriteriaMap.put(SearchFilter.VESSEL_IDENTIFIRE, "CFR123");
    searchCriteriaMap.put(SearchFilter.REPORT_TYPE, "DECLARATION");
    searchCriteriaMap.put(SearchFilter.GEAR, "GEAR_TYPE");
    searchCriteriaMap.put(SearchFilter.SPECIES, "PLE");
    searchCriteriaMap.put(SearchFilter.MASTER, "MARK");
    searchCriteriaMap.put(SearchFilter.AREAS, "27.4.b");
    // searchCriteriaMap.put(SearchFilter.PORT, "GBR");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MIN, "0");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MAX, "25");
    searchCriteriaMap.put(SearchFilter.FA_REPORT_ID, "1");
    query.setSearchCriteriaMap(searchCriteriaMap);
    PaginationDto pagination = new PaginationDto();
    pagination.setPageSize(2);
    pagination.setOffset(1);
    query.setPagination(pagination);
    SortKey sortingDto = new SortKey();
    sortingDto.setSortBy(SearchFilter.OCCURRENCE);
    sortingDto.setReversed(false);
    query.setSorting(sortingDto);
    List<FishingActivityEntity> finishingActivityList = dao.getFishingActivityListByQuery(query);
    assertNotNull(finishingActivityList);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PaginationDto(eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) SortKey(eu.europa.ec.fisheries.ers.service.search.SortKey) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 9 with SearchFilter

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

the class FishingTripDaoTest method testGetFishingTripIdsForMatchingFilterCriteria_allCommonFilters.

@Test
@SneakyThrows
public void testGetFishingTripIdsForMatchingFilterCriteria_allCommonFilters() throws Exception {
    dbSetupTracker.skipNextLaunch();
    Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
    searchCriteriaMap.put(SearchFilter.ACTIVITY_TYPE, "DEPARTURE");
    searchCriteriaMap.put(SearchFilter.SOURCE, "FLUX");
    searchCriteriaMap.put(SearchFilter.OWNER, "OWNER1");
    searchCriteriaMap.put(SearchFilter.FROM, "OWNER1");
    searchCriteriaMap.put(SearchFilter.PERIOD_START, "2012-05-27T07:47:31");
    searchCriteriaMap.put(SearchFilter.PERIOD_END, "2018-05-27T07:47:31");
    searchCriteriaMap.put(SearchFilter.REPORT_TYPE, "DECLARATION");
    searchCriteriaMap.put(SearchFilter.AREAS, "J");
    searchCriteriaMap.put(SearchFilter.GEAR, "GEAR_TYPE");
    searchCriteriaMap.put(SearchFilter.SPECIES, "BFT");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MIN, "0");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MAX, "50");
    searchCriteriaMap.put(SearchFilter.MASTER, "MARK");
    Map<SearchFilter, List<String>> searchCriteriaMapMultiVal = new HashMap<>();
    List<String> purposeCodeValues = new ArrayList<>();
    purposeCodeValues.add("9");
    purposeCodeValues.add("1");
    purposeCodeValues.add("5");
    purposeCodeValues.add("3");
    FishingActivityQuery query = new FishingActivityQuery();
    query.setSearchCriteriaMap(searchCriteriaMap);
    query.setSearchCriteriaMapMultipleValues(searchCriteriaMapMultiVal);
    searchCriteriaMapMultiVal.put(SearchFilter.PURPOSE, purposeCodeValues);
    Set<FishingTripId> fishingTripIdSet = dao.getFishingTripIdsForMatchingFilterCriteria(query);
    FishingTripId fishingTripId = new FishingTripId("NOR-TRP-20160517234053706", "EU_TRIP_ID");
    assertEquals(true, fishingTripIdSet.contains(fishingTripId));
    assertNotNull(fishingTripIdSet);
}
Also used : FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) ArrayList(java.util.ArrayList) List(java.util.List) FishingTripId(eu.europa.ec.fisheries.ers.service.search.FishingTripId) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 10 with SearchFilter

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

the class SearchQueryBuilderTest method testCreateSQL.

@Test
@SneakyThrows
public void testCreateSQL() throws ServiceException {
    FishingActivityQuery query = new FishingActivityQuery();
    Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
    searchCriteriaMap.put(SearchFilter.ACTIVITY_TYPE, "DEPARTURE");
    query.setSearchCriteriaMap(searchCriteriaMap);
    PaginationDto pagination = new PaginationDto();
    pagination.setPageSize(2);
    pagination.setOffset(1);
    query.setPagination(pagination);
    SearchQueryBuilder search = new FishingActivitySearchBuilder();
    StringBuilder sql = search.createSQL(query);
    System.out.println("done:" + sql);
    assertNotNull(sql);
}
Also used : FishingActivitySearchBuilder(eu.europa.ec.fisheries.ers.service.search.builder.FishingActivitySearchBuilder) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) HashMap(java.util.HashMap) PaginationDto(eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto) SearchQueryBuilder(eu.europa.ec.fisheries.ers.service.search.builder.SearchQueryBuilder) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

SearchFilter (eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter)29 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)19 ArrayList (java.util.ArrayList)18 List (java.util.List)17 Test (org.junit.Test)17 SneakyThrows (lombok.SneakyThrows)16 HashMap (java.util.HashMap)14 EnumMap (java.util.EnumMap)9 SortKey (eu.europa.ec.fisheries.ers.service.search.SortKey)8 PaginationDto (eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto)7 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)7 FilterMap (eu.europa.ec.fisheries.ers.service.search.FilterMap)4 FishingTripId (eu.europa.ec.fisheries.ers.service.search.FishingTripId)4 GroupCriteria (eu.europa.ec.fisheries.uvms.activity.model.schemas.GroupCriteria)4 Map (java.util.Map)4 FishingTripResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripResponse)3 FaCatchSummaryCustomProxy (eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy)2 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)2 FilterFishingActivityReportResultDTO (eu.europa.ec.fisheries.ers.service.dto.FilterFishingActivityReportResultDTO)2 FilterDetails (eu.europa.ec.fisheries.ers.service.search.FilterDetails)2