Search in sources :

Example 6 with FishingTripIdentifierEntity

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

the class FishingTripServiceBean method getPreviousTrips.

private Set<String> getPreviousTrips(String tripId, Integer limit, List<VesselIdentifierEntity> vesselIdentifiers) {
    Set<String> tripIds = new LinkedHashSet<>();
    if (vesselIdentifiers != null && !vesselIdentifiers.isEmpty()) {
        for (VesselIdentifierEntity vesselIdentifier : vesselIdentifiers) {
            // FIXME
            List<FishingTripIdentifierEntity> identifierEntities = fishingTripIdentifierDao.getPreviousTrips(vesselIdentifier.getVesselIdentifierId(), vesselIdentifier.getVesselIdentifierSchemeId(), tripId, limit);
            for (FishingTripIdentifierEntity identifiers : identifierEntities) {
                tripIds.add(identifiers.getTripId());
            }
        }
    }
    log.debug("Previous Trips : " + tripIds);
    return tripIds;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)

Example 7 with FishingTripIdentifierEntity

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

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

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

the class FishingTripServiceBean method getNextTrips.

private Set<String> getNextTrips(String tripId, Integer limit, List<VesselIdentifierEntity> vesselIdentifiers) {
    Set<String> tripIds = new LinkedHashSet<>();
    if (vesselIdentifiers != null && !vesselIdentifiers.isEmpty()) {
        for (VesselIdentifierEntity vesselIdentifier : vesselIdentifiers) {
            // FIXME
            List<FishingTripIdentifierEntity> identifierEntities = fishingTripIdentifierDao.getNextTrips(vesselIdentifier.getVesselIdentifierId(), vesselIdentifier.getVesselIdentifierSchemeId(), tripId, limit);
            for (FishingTripIdentifierEntity identifiers : identifierEntities) {
                tripIds.add(identifiers.getTripId());
            }
        }
    }
    log.debug("Next Trips : " + tripIds);
    return tripIds;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)

Example 10 with FishingTripIdentifierEntity

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

the class FishingTripServiceBean method getCurrentTrip.

private String getCurrentTrip(List<VesselIdentifierEntity> vesselIdentifiers) {
    String currentTrip = null;
    if (vesselIdentifiers != null && !vesselIdentifiers.isEmpty()) {
        for (VesselIdentifierEntity vesselIdentifier : vesselIdentifiers) {
            FishingTripIdentifierEntity identifierEntity = fishingTripIdentifierDao.getCurrentTrip(vesselIdentifier.getVesselIdentifierId(), vesselIdentifier.getVesselIdentifierSchemeId());
            currentTrip = identifierEntity != null ? identifierEntity.getTripId() : null;
            break;
        }
    }
    log.info("Current Trip : " + currentTrip);
    return currentTrip;
}
Also used : VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)

Aggregations

FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)18 ArrayList (java.util.ArrayList)5 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)4 CronologyTripDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO)4 SneakyThrows (lombok.SneakyThrows)4 Test (org.junit.Test)4 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)3 VesselIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity)3 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)3 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)2 TripOverviewDto (eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 ParseException (com.vividsolutions.jts.io.ParseException)1 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)1 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)1 FishingActivityIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityIdentifierEntity)1 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)1 SizeDistributionEntity (eu.europa.ec.fisheries.ers.fa.entities.SizeDistributionEntity)1 FishingActivityTypeDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO)1