Search in sources :

Example 6 with FishingTripEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class BaseMapper method mapToFishingTripEntitySet.

public static Set<FishingTripEntity> mapToFishingTripEntitySet(FishingTrip fishingTrip, FishingActivityEntity fishingActivityEntity) {
    if (fishingTrip == null) {
        return Collections.emptySet();
    }
    FishingTripEntity fishingTripEntity = mapToFishingTripEntity(fishingTrip);
    fishingTripEntity.setFishingActivity(fishingActivityEntity);
    return new HashSet<>(Collections.singletonList(fishingTripEntity));
}
Also used : FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) HashSet(java.util.HashSet)

Example 7 with FishingTripEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class BaseMapper method mapToFishingTripEntitySet.

public static Set<FishingTripEntity> mapToFishingTripEntitySet(List<FishingTrip> fishingTrips, FaCatchEntity faCatchEntity) {
    if (fishingTrips == null || fishingTrips.isEmpty()) {
        return Collections.emptySet();
    }
    Set<FishingTripEntity> fishingTripEntities = new HashSet<>();
    for (FishingTrip fishingTrip : fishingTrips) {
        FishingTripEntity fishingTripEntity = mapToFishingTripEntity(fishingTrip);
        fishingTripEntity.setFaCatch(faCatchEntity);
        fishingTripEntities.add(fishingTripEntity);
    }
    return fishingTripEntities;
}
Also used : FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) FishingTrip(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingTrip) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) HashSet(java.util.HashSet)

Example 8 with FishingTripEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityMapper method getFishingTripId.

protected String getFishingTripId(FishingActivityEntity fishingActivityEntity) {
    if (fishingActivityEntity == null || CollectionUtils.isEmpty(fishingActivityEntity.getFishingTrips())) {
        return null;
    }
    Set<FishingTripEntity> fishingTripEntities = fishingActivityEntity.getFishingTrips();
    FishingTripEntity fishingTripEntity = fishingTripEntities.iterator().next();
    if (CollectionUtils.isEmpty(fishingTripEntity.getFishingTripIdentifiers()))
        return null;
    return fishingTripEntity.getFishingTripIdentifiers().iterator().next().getTripId();
}
Also used : FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)

Example 9 with FishingTripEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity 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 10 with FishingTripEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity 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

FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)15 HashSet (java.util.HashSet)6 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)4 FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)4 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)3 FishingTrip (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingTrip)3 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)2 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)2 FishingActivityIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityIdentifierEntity)2 FishingGearEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity)2 FluxCharacteristicEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity)2 FluxLocationEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity)2 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)2 TripOverviewDto (eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto)2 AapProcessEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity)1 AapStockEntity (eu.europa.ec.fisheries.ers.fa.entities.AapStockEntity)1 ContactPartyEntity (eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity)1