use of eu.europa.ec.fisheries.ers.service.dto.FilterFishingActivityReportResultDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityServiceBean method createResultDTO.
@NotNull
private FilterFishingActivityReportResultDTO createResultDTO(List<FishingActivityEntity> activityList, int totalCountOfRecords) {
if (CollectionUtils.isEmpty(activityList)) {
log.debug("Could not find FishingActivity entities matching search criteria");
activityList = Collections.emptyList();
}
// Prepare DTO to return to Frontend
log.debug("Fishing Activity Report resultset size : " + Integer.toString(activityList.size()));
FilterFishingActivityReportResultDTO filterFishingActivityReportResultDTO = new FilterFishingActivityReportResultDTO();
filterFishingActivityReportResultDTO.setResultList(mapToFishingActivityReportDTOList(activityList));
filterFishingActivityReportResultDTO.setTotalCountOfRecords(totalCountOfRecords);
return filterFishingActivityReportResultDTO;
}
use of eu.europa.ec.fisheries.ers.service.dto.FilterFishingActivityReportResultDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityResource method listActivityReportsByQuery.
@POST
@Path("/list")
@Consumes(value = { MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Interceptors(ActivityExceptionInterceptor.class)
@IUserRoleInterceptor(requiredUserRole = { ActivityFeaturesEnum.LIST_ACTIVITY_REPORTS })
public Response listActivityReportsByQuery(@Context HttpServletRequest request, @HeaderParam("scopeName") String scopeName, @HeaderParam("roleName") String roleName, FishingActivityQuery fishingActivityQuery) throws ServiceException {
log.info("Query Received to search Fishing Activity Reports. " + fishingActivityQuery);
if (fishingActivityQuery == null) {
return createErrorResponse("Query to find list is null.");
}
String username = request.getRemoteUser();
List<Dataset> datasets = usmService.getDatasetsPerCategory(USMSpatial.USM_DATASET_CATEGORY, username, USMSpatial.APPLICATION_NAME, roleName, scopeName);
log.info("Successful retrieved");
FilterFishingActivityReportResultDTO resultDTO = activityService.getFishingActivityListByQuery(fishingActivityQuery, datasets);
return createSuccessPaginatedResponse(resultDTO.getResultList(), resultDTO.getTotalCountOfRecords());
}
use of eu.europa.ec.fisheries.ers.service.dto.FilterFishingActivityReportResultDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityServiceBeanTest method getFishingActivityListByQuery.
@Test
@SneakyThrows
public void getFishingActivityListByQuery() throws ServiceException {
FishingActivityQuery query = new FishingActivityQuery();
Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
searchCriteriaMap.put(SearchFilter.OWNER, "OWNER1");
List<AreaIdentifierType> areaIdentifierTypes = new ArrayList<>();
Map<SearchFilter, List<String>> searchCriteriaMapMultipleValue = new HashMap<>();
List<String> purposeCodeList = new ArrayList<>();
purposeCodeList.add("9");
searchCriteriaMapMultipleValue.put(SearchFilter.PURPOSE, purposeCodeList);
PaginationDto pagination = new PaginationDto();
pagination.setPageSize(4);
pagination.setOffset(1);
query.setPagination(pagination);
query.setSearchCriteriaMap(searchCriteriaMap);
query.setSearchCriteriaMapMultipleValues(searchCriteriaMapMultipleValue);
when(spatialModule.getFilteredAreaGeom(areaIdentifierTypes)).thenReturn("('MULTIPOINT (10 40, 40 30, 20 20, 30 10)')");
when(fishingActivityDao.getFishingActivityListByQuery(query)).thenReturn(MapperUtil.getFishingActivityEntityList());
// Trigger
FilterFishingActivityReportResultDTO filterFishingActivityReportResultDTO = activityService.getFishingActivityListByQuery(query, null);
Mockito.verify(fishingActivityDao, Mockito.times(1)).getFishingActivityListByQuery(Mockito.any(FishingActivityQuery.class));
// Verify
assertNotNull(filterFishingActivityReportResultDTO);
assertNotNull(filterFishingActivityReportResultDTO.getResultList());
}
use of eu.europa.ec.fisheries.ers.service.dto.FilterFishingActivityReportResultDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityServiceBeanTest method getFishingActivityListByQuery_emptyResultSet.
@Test
@SneakyThrows
public void getFishingActivityListByQuery_emptyResultSet() throws ServiceException {
FishingActivityQuery query = new FishingActivityQuery();
Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
List<AreaIdentifierType> areaIdentifierTypes = new ArrayList<>();
searchCriteriaMap.put(SearchFilter.OWNER, "OWNER1");
Map<SearchFilter, List<String>> searchCriteriaMapMultipleValue = new HashMap<>();
List<String> purposeCodeList = new ArrayList<>();
purposeCodeList.add("9");
searchCriteriaMapMultipleValue.put(SearchFilter.PURPOSE, purposeCodeList);
PaginationDto pagination = new PaginationDto();
pagination.setPageSize(4);
pagination.setOffset(1);
query.setPagination(pagination);
query.setSearchCriteriaMap(searchCriteriaMap);
query.setSearchCriteriaMapMultipleValues(searchCriteriaMapMultipleValue);
when(spatialModule.getFilteredAreaGeom(areaIdentifierTypes)).thenReturn("('MULTIPOINT (10 40, 40 30, 20 20, 30 10)')");
when(fishingActivityDao.getFishingActivityListByQuery(query)).thenReturn(new ArrayList<FishingActivityEntity>());
// Trigger
FilterFishingActivityReportResultDTO filterFishingActivityReportResultDTO = activityService.getFishingActivityListByQuery(query, new ArrayList<Dataset>());
Mockito.verify(fishingActivityDao, Mockito.times(1)).getFishingActivityListByQuery(Mockito.any(FishingActivityQuery.class));
// Verify
assertNotNull(filterFishingActivityReportResultDTO);
}
Aggregations