use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.
the class AssetModuleServiceBean method getAssetListResponse.
@Override
public List<Asset> getAssetListResponse(AssetListQuery assetListQuery) throws ServiceException {
List<Asset> assetList;
try {
String assetsRequest = AssetModuleRequestMapper.createAssetListModuleRequest(assetListQuery);
String correlationID = assetProducer.sendModuleMessage(assetsRequest, activityConsumer.getDestination());
TextMessage response = activityConsumer.getMessage(correlationID, TextMessage.class);
assetList = AssetModuleResponseMapper.mapToAssetListFromResponse(response, correlationID);
} catch (AssetModelMapperException | MessageException e) {
log.error("Error while trying to send message to Assets module.", e);
throw new ServiceException(e.getMessage(), e.getCause());
}
return assetList;
}
use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method createTripWidgetDtoWithFishingActivity.
public TripWidgetDto createTripWidgetDtoWithFishingActivity(FishingActivityEntity activityEntity) throws ServiceException {
TripWidgetDto tripWidgetDto = new TripWidgetDto();
Set<FishingTripEntity> fishingTripEntities = activityEntity.getFishingTrips();
if (CollectionUtils.isEmpty(fishingTripEntities)) {
throw new ServiceException(" Could not find fishingTrips associated with FishingActivity id :" + activityEntity.getId());
}
List<TripOverviewDto> tripOverviewDtoList = new ArrayList<>();
// try to find unique tripIds for the fishing Activity
Set<String> tripIdSet = new HashSet<>();
for (FishingTripEntity fishingTripEntity : fishingTripEntities) {
Set<FishingTripIdentifierEntity> identifierEntities = fishingTripEntity.getFishingTripIdentifiers();
for (FishingTripIdentifierEntity tripIdentifierEntity : identifierEntities) {
if (!tripIdSet.contains(tripIdentifierEntity.getTripId())) {
log.debug("Get Trip summary information for tripID :" + tripIdentifierEntity.getTripId());
tripOverviewDtoList.add(getTripOverviewDto(activityEntity, tripIdentifierEntity.getTripId()));
tripIdSet.add(tripIdentifierEntity.getTripId());
}
}
}
tripWidgetDto.setTrips(tripOverviewDtoList);
// As per new requirement, vessel should always be the one associated with fishing Activity in the trip widget
if (activityEntity != null && activityEntity.getFaReportDocument() != null && CollectionUtils.isNotEmpty(activityEntity.getFaReportDocument().getVesselTransportMeans())) {
Set<VesselTransportMeansEntity> vesselTransportMeansEntities = activityEntity.getFaReportDocument().getVesselTransportMeans();
for (VesselTransportMeansEntity vesselTransportMeansEntity : vesselTransportMeansEntities) {
if (vesselTransportMeansEntity.getFishingActivity() == null) {
tripWidgetDto.setVesselDetails(getVesselDetailsDTO(vesselTransportMeansEntity, activityEntity));
break;
}
}
}
return tripWidgetDto;
}
use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method enrichWithAssetsModuleDataIfNeeded.
// need confirmation for removal of this method
private void enrichWithAssetsModuleDataIfNeeded(VesselDetailsDTO vesselDetailsDTO) {
if (vesselDetailsDTO != null && vesselDetailsDTO.hasEmptyIdentifierValues()) {
try {
Set<AssetIdentifierDto> vesselIdentifiers = vesselDetailsDTO.getVesselIdentifiers();
List<AssetListCriteriaPair> assetListCriteriaPairs = BaseMapper.mapToAssetListCriteriaPairList(vesselIdentifiers);
AssetListCriteria criteria = new AssetListCriteria();
criteria.getCriterias().addAll(assetListCriteriaPairs);
AssetListQuery query = new AssetListQuery();
query.setAssetSearchCriteria(criteria);
List<Asset> assetList = assetModuleService.getAssetListResponse(query);
vesselDetailsDTO.enrichIdentifiers(assetList.get(0));
} catch (ServiceException e) {
log.error("Error while trying to send message to Assets module.", e);
}
}
}
use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getVesselDetailsForFishingTrip.
@Override
public VesselDetailsDTO getVesselDetailsForFishingTrip(final String fishingTripId) throws ServiceException {
if (fishingTripId == null) {
throw new IllegalArgumentException("PARAMETER CANNOT BE NULL");
}
VesselDetailsDTO detailsDTO = null;
try {
VesselTransportMeansEntity latestVesselByTripId = vesselTransportMeansDao.findLatestVesselByTripId(fishingTripId);
if (latestVesselByTripId != null) {
FishingActivityEntity parent = latestVesselByTripId.getFishingActivity();
detailsDTO = getVesselDetailsDTO(latestVesselByTripId, parent);
}
} catch (ServiceException e) {
throw new ServiceException(e.getMessage(), e);
}
return detailsDTO;
}
use of eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException in project UVMS-ActivityModule-APP by UnionVMS.
the class FluxMessageServiceBean method calculateIntermediatePoint.
private Geometry calculateIntermediatePoint(MovementType previousMovement, MovementType nextMovement, Date acceptedDate) throws ServiceException {
Geometry point;
Long durationAB = nextMovement.getPositionTime().getTime() - previousMovement.getPositionTime().getTime();
Long durationAC = acceptedDate.getTime() - previousMovement.getPositionTime().getTime();
Long durationBC = nextMovement.getPositionTime().getTime() - acceptedDate.getTime();
try {
if (durationAC == 0) {
log.info("The point is same as the start point");
point = GeometryMapper.INSTANCE.wktToGeometry(previousMovement.getWkt()).getValue();
} else if (durationBC == 0) {
log.info("The point is the same as end point");
point = GeometryMapper.INSTANCE.wktToGeometry(nextMovement.getWkt()).getValue();
} else {
log.info("The point is between start and end point");
LengthIndexedLine lengthIndexedLine = GeometryUtils.createLengthIndexedLine(previousMovement.getWkt(), nextMovement.getWkt());
Double index = durationAC * (lengthIndexedLine.getEndIndex() - lengthIndexedLine.getStartIndex()) / durationAB;
point = GeometryUtils.calculateIntersectingPoint(lengthIndexedLine, index);
}
} catch (ParseException e) {
throw new ServiceException(e.getMessage(), e);
}
point.setSRID(dialect.defaultSRID());
return point;
}
Aggregations