Search in sources :

Example 1 with FishingActivityTypeDTO

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

the class FishingTripServiceBean method populateTripOverviewDto.

private void populateTripOverviewDto(Map<String, FishingActivityTypeDTO> typeDTOMap, TripOverviewDto tripOverviewDto) {
    for (Map.Entry<String, FishingActivityTypeDTO> entry : typeDTOMap.entrySet()) {
        String key = entry.getKey();
        FishingActivityTypeDTO fishingActivityTypeDTO = entry.getValue();
        switch(FishingActivityTypeEnum.valueOf(key)) {
            case DEPARTURE:
                tripOverviewDto.setDepartureTime(fishingActivityTypeDTO.getDate());
                break;
            case ARRIVAL:
                tripOverviewDto.setArrivalTime(fishingActivityTypeDTO.getDate());
                break;
            case LANDING:
                tripOverviewDto.setLandingTime(fishingActivityTypeDTO.getDate());
                break;
            default:
                log.debug("Fishing Activity type found is :" + key);
                break;
        }
    }
}
Also used : FishingActivityTypeDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO) Map(java.util.Map) EnumMap(java.util.EnumMap) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap)

Example 2 with FishingActivityTypeDTO

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

the class FishingTripServiceBean method populateFishingTripSummary.

public void populateFishingTripSummary(FishingActivityEntity activityEntity, Map<String, FishingActivityTypeDTO> summary) {
    String activityTypeCode = activityEntity.getTypeCode();
    if (DEPARTURE.toString().equalsIgnoreCase(activityTypeCode) || ARRIVAL.toString().equalsIgnoreCase(activityTypeCode) || LANDING.toString().equalsIgnoreCase(activityTypeCode)) {
        Date occurrence = activityEntity.getOccurence();
        Boolean isCorrection = BaseMapper.getCorrection(activityEntity);
        FishingActivityTypeDTO fishingActivityTypeDTO = summary.get(activityTypeCode);
        if (fishingActivityTypeDTO == null || (isCorrection && fishingActivityTypeDTO.getDate() != null && occurrence != null && occurrence.compareTo(fishingActivityTypeDTO.getDate()) > 0)) {
            fishingActivityTypeDTO = new FishingActivityTypeDTO();
            fishingActivityTypeDTO.setDate(occurrence);
            summary.put(activityTypeCode, fishingActivityTypeDTO);
        }
    }
}
Also used : FishingActivityTypeDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO) Date(java.util.Date)

Example 3 with FishingActivityTypeDTO

use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO 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 4 with FishingActivityTypeDTO

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

the class FishingTripServiceBean method getFishingTripSummaryAndReports.

@Override
public FishingTripSummaryViewDTO getFishingTripSummaryAndReports(String fishingTripId, List<Dataset> datasets) throws ServiceException {
    List<ReportDTO> reportDTOList = new ArrayList<>();
    Geometry multipolygon = getRestrictedAreaGeom(datasets);
    Map<String, FishingActivityTypeDTO> summary = populateFishingActivityReportListAndFishingTripSummary(fishingTripId, reportDTOList, multipolygon, false);
    return populateFishingTripSummary(fishingTripId, reportDTOList, summary);
}
Also used : FishingTripIdWithGeometry(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripIdWithGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) FishingActivityTypeDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO) ArrayList(java.util.ArrayList) ReportDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.ReportDTO)

Example 5 with FishingActivityTypeDTO

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

the class FishingTripServiceBean method populateFishingActivityReportListAndFishingTripSummary.

/**
 * @param fishingTripId     - Fishing trip summary will be collected for this tripID
 * @param reportDTOList     - This DTO will have details about Fishing Activities.Method will process and populate data into this list     *
 * @param multipolygon      - Activities only in this area would be selected
 * @param isOnlyTripSummary - This method you could reuse to only get Fishing trip summary as well
 * @throws ServiceException
 */
@Override
public Map<String, FishingActivityTypeDTO> populateFishingActivityReportListAndFishingTripSummary(String fishingTripId, List<ReportDTO> reportDTOList, Geometry multipolygon, boolean isOnlyTripSummary) throws ServiceException {
    List<FishingActivityEntity> fishingActivityList = fishingActivityDao.getFishingActivityListForFishingTrip(fishingTripId, multipolygon);
    if (CollectionUtils.isEmpty(fishingActivityList)) {
        return Collections.emptyMap();
    }
    Map<String, FishingActivityTypeDTO> tripSummary = new HashMap<>();
    for (FishingActivityEntity activityEntity : fishingActivityList) {
        if (!isOnlyTripSummary) {
            ReportDTO reportDTO = FishingActivityMapper.INSTANCE.mapToReportDTO(activityEntity);
            reportDTOList.add(reportDTO);
        }
        if (activityEntity != null && activityEntity.getFaReportDocument() != null && ActivityConstants.DECLARATION.equalsIgnoreCase(activityEntity.getFaReportDocument().getTypeCode())) {
            // FA Report should be of type Declaration. And Fishing Activity type should be Either Departure,Arrival or Landing
            populateFishingTripSummary(activityEntity, tripSummary);
        }
    }
    return tripSummary;
}
Also used : FishingActivityTypeDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO) HashMap(java.util.HashMap) ReportDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.ReportDTO) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Aggregations

FishingActivityTypeDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO)5 ReportDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.ReportDTO)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)1 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)1 FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)1 TripIdDto (eu.europa.ec.fisheries.ers.service.dto.view.TripIdDto)1 TripOverviewDto (eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto)1 FishingTripIdWithGeometry (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripIdWithGeometry)1 Date (java.util.Date)1 EnumMap (java.util.EnumMap)1 Map (java.util.Map)1 NotNull (javax.validation.constraints.NotNull)1