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;
}
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);
}
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);
}
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);
}
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);
}
Aggregations