Search in sources :

Example 6 with VesselTransportMeansEntity

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

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

the class FluxMessageServiceBean method enrichFishingActivityVesselWithGuiId.

private void enrichFishingActivityVesselWithGuiId(FishingActivityEntity fishingActivityEntity) {
    Set<VesselTransportMeansEntity> vesselTransportMeansEntityList = fishingActivityEntity.getVesselTransportMeans();
    if (CollectionUtils.isEmpty(vesselTransportMeansEntityList)) {
        return;
    }
    for (VesselTransportMeansEntity entity : vesselTransportMeansEntityList) {
        enrichWithGuidFromAssets(entity);
        fishingActivityEntity.setVesselTransportGuid(entity.getGuid());
    }
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)

Example 8 with VesselTransportMeansEntity

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

the class FaCatchMapper method mapToAssetIdentifiers.

protected List<AssetIdentifierDto> mapToAssetIdentifiers(FaCatchEntity faCatch) {
    List<AssetIdentifierDto> assetIdentifierDtos = new ArrayList<>();
    if (faCatch != null && faCatch.getFishingActivity() != null && CollectionUtils.isNotEmpty(faCatch.getFishingActivity().getVesselTransportMeans())) {
        VesselTransportMeansEntity vesselTransportMeans = faCatch.getFishingActivity().getVesselTransportMeans().iterator().next();
        Map<VesselIdentifierSchemeIdEnum, String> vesselIdentifiers = vesselTransportMeans.getVesselIdentifiersMap();
        // Set IRCS always if present
        if (vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.IRCS) != null) {
            assetIdentifierDtos.add(new AssetIdentifierDto(VesselIdentifierSchemeIdEnum.IRCS, vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.IRCS)));
        }
        if (vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.ICCAT) != null) {
            assetIdentifierDtos.add(new AssetIdentifierDto(VesselIdentifierSchemeIdEnum.ICCAT, vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.ICCAT)));
        } else if (vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.CFR) != null) {
            assetIdentifierDtos.add(new AssetIdentifierDto(VesselIdentifierSchemeIdEnum.CFR, vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.CFR)));
        }
    }
    return assetIdentifierDtos;
}
Also used : AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) ArrayList(java.util.ArrayList) VesselIdentifierSchemeIdEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)

Example 9 with VesselTransportMeansEntity

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

the class FaReportDocumentMapper method getVesselTransportMeansEntity.

protected Set<VesselTransportMeansEntity> getVesselTransportMeansEntity(VesselTransportMeans vesselTransportMeans, FaReportDocumentEntity faReportDocumentEntity) {
    if (vesselTransportMeans == null) {
        return null;
    }
    Set<VesselTransportMeansEntity> entities = new HashSet<>();
    VesselTransportMeansEntity vesselTransportMeansEntity = VesselTransportMeansMapper.INSTANCE.mapToVesselTransportMeansEntity(vesselTransportMeans);
    vesselTransportMeansEntity.setFaReportDocument(faReportDocumentEntity);
    entities.add(vesselTransportMeansEntity);
    return entities;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) HashSet(java.util.HashSet)

Example 10 with VesselTransportMeansEntity

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

the class FishingTripIdWithGeometryMapper method getFlagStateFromActivityList.

private String getFlagStateFromActivityList(List<FishingActivityEntity> fishingActivities) {
    if (CollectionUtils.isEmpty(fishingActivities) || fishingActivities.get(fishingActivities.size() - 1) == null || fishingActivities.get(fishingActivities.size() - 1).getFaReportDocument() == null || fishingActivities.get(fishingActivities.size() - 1).getFaReportDocument().getVesselTransportMeans() == null) {
        return null;
    }
    int totalFishingActivityCount = fishingActivities.size();
    FishingActivityEntity fishingActivityEntity = fishingActivities.get(totalFishingActivityCount - 1);
    Set<VesselTransportMeansEntity> vesselTransportMeansEntityList = fishingActivityEntity.getFaReportDocument().getVesselTransportMeans();
    if (CollectionUtils.isEmpty(vesselTransportMeansEntityList)) {
        return null;
    }
    return vesselTransportMeansEntityList.iterator().next().getCountry();
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

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