Search in sources :

Example 16 with VesselTransportMeansEntity

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;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) ArrayList(java.util.ArrayList) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 17 with VesselTransportMeansEntity

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;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) ArrayList(java.util.ArrayList)

Example 18 with VesselTransportMeansEntity

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;
}
Also used : FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) ArrayList(java.util.ArrayList) TripWidgetDto(eu.europa.ec.fisheries.ers.service.dto.view.TripWidgetDto) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) TripOverviewDto(eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet)

Example 19 with VesselTransportMeansEntity

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;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 20 with VesselTransportMeansEntity

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;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)

Aggregations

VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)25 ArrayList (java.util.ArrayList)12 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)8 VesselDetailsDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO)7 Test (org.junit.Test)6 HashSet (java.util.HashSet)5 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)4 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)4 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)3 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)3 HashMap (java.util.HashMap)3 List (java.util.List)3 SneakyThrows (lombok.SneakyThrows)3 VesselTransportMeans (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.VesselTransportMeans)3 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)2 FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)2 SizeDistributionEntity (eu.europa.ec.fisheries.ers.fa.entities.SizeDistributionEntity)2 VesselIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity)2 TripOverviewDto (eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto)2 TripWidgetDto (eu.europa.ec.fisheries.ers.service.dto.view.TripWidgetDto)2