use of eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class JointFishingOperationViewMapper method getVesselDetailsDTO.
/**
* Addded this method as we want to set storage information explicitely in VesselDetailsDTO.Storage informaation we can only get from activities
* @param faEntity
* @return VesselDetailsDTO
*/
protected List<VesselDetailsDTO> getVesselDetailsDTO(FishingActivityEntity faEntity) {
if (faEntity == null)
return null;
List<VesselDetailsDTO> vesselDetailsDTOs = new ArrayList<>();
Set<VesselTransportMeansEntity> entities = faEntity.getVesselTransportMeans();
if (CollectionUtils.isEmpty(entities)) {
entities = new HashSet<>();
}
if (CollectionUtils.isNotEmpty(faEntity.getAllRelatedFishingActivities())) {
for (FishingActivityEntity fishingActivityEntity : faEntity.getAllRelatedFishingActivities()) {
entities.addAll(fishingActivityEntity.getVesselTransportMeans());
}
}
for (VesselTransportMeansEntity vesselTransportMeansEntity : entities) {
VesselDetailsDTO vesselDetails = VesselTransportMeansMapper.INSTANCE.map(vesselTransportMeansEntity);
if (vesselDetails != null && faEntity.getDestVesselCharId() != null) {
vesselDetails.setStorageDto(VesselStorageCharacteristicsMapper.INSTANCE.mapToStorageDto(faEntity.getDestVesselCharId()));
}
vesselDetailsDTOs.add(vesselDetails);
}
return vesselDetailsDTOs;
}
use of eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityTranshipmentViewMapper method getVesselDetailsDTO.
/**
* Addded this method as we want to set storage information explicitely in VesselDetailsDTO.Storage informaation we can only get from activities
* @param faEntity
* @return VesselDetailsDTO
*/
protected List<VesselDetailsDTO> getVesselDetailsDTO(FishingActivityEntity faEntity) {
if (faEntity == null || CollectionUtils.isEmpty(faEntity.getVesselTransportMeans()))
return null;
List<VesselDetailsDTO> vesselDetailsDTOs = new ArrayList<>();
Set<VesselTransportMeansEntity> entities = faEntity.getVesselTransportMeans();
for (VesselTransportMeansEntity vesselTransportMeansEntity : entities) {
VesselDetailsDTO vesselDetails = VesselTransportMeansMapper.INSTANCE.map(vesselTransportMeansEntity);
if (vesselDetails != null && faEntity.getDestVesselCharId() != null) {
vesselDetails.setStorageDto(VesselStorageCharacteristicsMapper.INSTANCE.mapToStorageDto(faEntity.getDestVesselCharId()));
}
vesselDetailsDTOs.add(vesselDetails);
}
return vesselDetailsDTOs;
}
use of eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity 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.ers.fa.entities.VesselTransportMeansEntity 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.ers.fa.entities.VesselTransportMeansEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class VesselTransportMeansDao method findLatestVesselByTripId.
public VesselTransportMeansEntity findLatestVesselByTripId(String tripId) throws ServiceException {
VesselTransportMeansEntity vesselTransportMeansEntity = null;
List<VesselTransportMeansEntity> byNamedQuery = findEntityByNamedQuery(VesselTransportMeansEntity.class, VesselTransportMeansEntity.FIND_LATEST_VESSEL_BY_TRIP_ID, QueryParameter.with("tripId", tripId).parameters(), 1);
if (!CollectionUtils.isEmpty(byNamedQuery)) {
vesselTransportMeansEntity = byNamedQuery.get(0);
}
return vesselTransportMeansEntity;
}
Aggregations