Search in sources :

Example 1 with TripOverviewDto

use of eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripServiceBean method getTripWidgetDto.

@Override
public /**
 *  Returns TripWidgetDto based on the tripId and activityId
 */
TripWidgetDto getTripWidgetDto(FishingActivityEntity activityEntity, String tripId) {
    if (activityEntity == null && tripId == null) {
        return null;
    }
    TripWidgetDto tripWidgetDto = new TripWidgetDto();
    try {
        if (tripId != null) {
            log.debug("Trip Id found for Fishing Activity. Get TripWidget information for tripID :" + tripId);
            TripOverviewDto tripOverviewDto = getTripOverviewDto(activityEntity, tripId);
            List<TripOverviewDto> tripOverviewDtoList = new ArrayList<>();
            tripOverviewDtoList.add(tripOverviewDto);
            tripWidgetDto.setTrips(tripOverviewDtoList);
            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;
                    }
                }
            }
            // VesselDetailsDTO detailsDTO = getVesselDetailsForFishingTrip(tripId);
            // tripWidgetDto.setVesselDetails(detailsDTO);
            log.debug("tripWidgetDto set for tripID :" + tripId);
        } else {
            log.debug("TripId is not received for the screen. Try to get TripSummary information for all the tripIds specified for FishingActivity:" + activityEntity.getId());
            return createTripWidgetDtoWithFishingActivity(activityEntity);
        }
    } catch (ServiceException e) {
        log.error("Error while creating TripWidgetDto.", e);
    }
    return tripWidgetDto;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) ArrayList(java.util.ArrayList) TripWidgetDto(eu.europa.ec.fisheries.ers.service.dto.view.TripWidgetDto) TripOverviewDto(eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto)

Example 2 with TripOverviewDto

use of eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripServiceBean method getTripOverviewDto.

@NotNull
private TripOverviewDto getTripOverviewDto(FishingActivityEntity activityEntity, String tripId) throws ServiceException {
    Map<String, FishingActivityTypeDTO> typeDTOMap = populateFishingActivityReportListAndFishingTripSummary(tripId, null, null, true);
    TripOverviewDto tripOverviewDto = new TripOverviewDto();
    // Find out fishingTrip schemeId matching to tripId from fishingActivity object.
    Set<FishingTripEntity> fishingTripEntities = activityEntity.getFishingTrips();
    if (CollectionUtils.isNotEmpty(fishingTripEntities)) {
        for (FishingTripEntity fishingTripEntity : fishingTripEntities) {
            Set<FishingTripIdentifierEntity> identifierEntities = fishingTripEntity.getFishingTripIdentifiers();
            for (FishingTripIdentifierEntity tripIdentifierEntity : identifierEntities) {
                if (tripId.equalsIgnoreCase(tripIdentifierEntity.getTripId())) {
                    TripIdDto tripIdDto = new TripIdDto();
                    tripIdDto.setId(tripId);
                    tripIdDto.setSchemeId(tripIdentifierEntity.getTripSchemeId());
                    List<TripIdDto> tripIdList = new ArrayList<>();
                    tripIdList.add(tripIdDto);
                    tripOverviewDto.setTripId(tripIdList);
                    break;
                }
            }
        }
    }
    populateTripOverviewDto(typeDTOMap, tripOverviewDto);
    return tripOverviewDto;
}
Also used : FishingActivityTypeDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO) FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) TripIdDto(eu.europa.ec.fisheries.ers.service.dto.view.TripIdDto) ArrayList(java.util.ArrayList) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) TripOverviewDto(eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto) NotNull(javax.validation.constraints.NotNull)

Example 3 with TripOverviewDto

use of eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto 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)

Aggregations

TripOverviewDto (eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto)3 ArrayList (java.util.ArrayList)3 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)2 FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)2 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)2 TripWidgetDto (eu.europa.ec.fisheries.ers.service.dto.view.TripWidgetDto)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 FishingActivityTypeDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO)1 TripIdDto (eu.europa.ec.fisheries.ers.service.dto.view.TripIdDto)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 NotNull (javax.validation.constraints.NotNull)1