use of eu.europa.ec.fisheries.wsdl.user.types.Dataset in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityResource method listFishingTripsByQuery.
@POST
@Path("/listTrips")
@Consumes(value = { MediaType.APPLICATION_JSON })
@Produces(MediaType.APPLICATION_JSON)
@Interceptors(ActivityExceptionInterceptor.class)
@IUserRoleInterceptor(requiredUserRole = { ActivityFeaturesEnum.LIST_ACTIVITY_REPORTS })
public Response listFishingTripsByQuery(@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");
FishingTripResponse fishingTripIdsForFilter = fishingTripService.filterFishingTrips(fishingActivityQuery);
return createSuccessResponse(fishingTripIdsForFilter);
}
use of eu.europa.ec.fisheries.wsdl.user.types.Dataset in project UVMS-ActivityModule-APP by UnionVMS.
the class UsmUtils method convertDataSetToAreaId.
public static List<AreaIdentifierType> convertDataSetToAreaId(List<Dataset> datasets) throws ServiceException {
List<AreaIdentifierType> areaRestrictions = new ArrayList<>(datasets.size());
for (Dataset dataset : datasets) {
int lastIndexDelimiter = dataset.getDiscriminator().lastIndexOf(USMSpatial.DELIMITER);
if (lastIndexDelimiter > -1) {
AreaIdentifierType areaIdentifierType = new AreaIdentifierType();
AreaType areaType = AreaType.valueOf(dataset.getDiscriminator().substring(0, lastIndexDelimiter));
String areaId = dataset.getDiscriminator().substring(lastIndexDelimiter + 1);
if (areaType != null && StringUtils.isNotBlank(areaId)) {
areaIdentifierType.setAreaType(areaType);
areaIdentifierType.setId(areaId);
areaRestrictions.add(areaIdentifierType);
}
}
}
return areaRestrictions;
}
use of eu.europa.ec.fisheries.wsdl.user.types.Dataset 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.wsdl.user.types.Dataset 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