use of eu.europa.ec.fisheries.uvms.spatial.model.schemas.AreaIdentifierType in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getRestrictedAreaGeom.
private Geometry getRestrictedAreaGeom(List<Dataset> datasets) throws ServiceException {
if (CollectionUtils.isEmpty(datasets)) {
return null;
}
try {
List<AreaIdentifierType> areaIdentifierTypes = UsmUtils.convertDataSetToAreaId(datasets);
String areaWkt = spatialModule.getFilteredAreaGeom(areaIdentifierTypes);
Geometry geometry = GeometryMapper.INSTANCE.wktToGeometry(areaWkt).getValue();
geometry.setSRID(GeometryUtils.DEFAULT_EPSG_SRID);
return geometry;
} catch (ParseException e) {
throw new ServiceException(e.getMessage(), e);
}
}
use of eu.europa.ec.fisheries.uvms.spatial.model.schemas.AreaIdentifierType in project UVMS-ActivityModule-APP by UnionVMS.
the class SpatialModuleServiceBean method getFilteredAreaGeom.
/**
* {@inheritDoc}
*/
@Override
public String getFilteredAreaGeom(Collection<AreaIdentifierType> areaIdentifiers) throws ServiceException {
try {
String request = SpatialModuleRequestMapper.mapToFilterAreaSpatialRequest(new ArrayList<>(areaIdentifiers), new ArrayList<AreaIdentifierType>());
String correlationId = spatialProducer.sendModuleMessage(request, activityConsumer.getDestination());
TextMessage message = activityConsumer.getMessage(correlationId, TextMessage.class);
if (message != null && !isUserFault(message)) {
FilterAreasSpatialRS response = SpatialModuleResponseMapper.mapToFilterAreasSpatialRSFromResponse(message, correlationId);
return response.getGeometry();
} else {
throw new ServiceException("FAILED TO GET DATA FROM SPATIAL");
}
} catch (ServiceException | MessageException | SpatialModelMapperException e) {
log.error("Exception in communication with spatial while retrieving filtered area", e);
throw new ServiceException(e.getMessage(), e);
}
}
use of eu.europa.ec.fisheries.uvms.spatial.model.schemas.AreaIdentifierType in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityServiceBean method getRestrictedAreaGeometry.
private Geometry getRestrictedAreaGeometry(List<Dataset> datasets) throws ServiceException {
if (datasets == null || datasets.isEmpty()) {
return null;
}
try {
List<AreaIdentifierType> areaIdentifierTypes = UsmUtils.convertDataSetToAreaId(datasets);
String areaWkt = spatialModule.getFilteredAreaGeom(areaIdentifierTypes);
Geometry geometry = GeometryMapper.INSTANCE.wktToGeometry(areaWkt).getValue();
geometry.setSRID(GeometryUtils.DEFAULT_EPSG_SRID);
return geometry;
} catch (ParseException e) {
throw new ServiceException(e.getMessage(), e);
}
}
use of eu.europa.ec.fisheries.uvms.spatial.model.schemas.AreaIdentifierType 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.uvms.spatial.model.schemas.AreaIdentifierType 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());
}
Aggregations