Search in sources :

Example 16 with FishingActivityEntity

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

the class FaReportDocumentMapper method getFishingActivityEntities.

protected Set<FishingActivityEntity> getFishingActivityEntities(List<FishingActivity> fishingActivities, FaReportDocumentEntity faReportDocumentEntity) {
    if (CollectionUtils.isEmpty(fishingActivities)) {
        return Collections.emptySet();
    }
    Set<FishingActivityEntity> fishingActivityEntities = new HashSet<>();
    for (FishingActivity fishingActivity : fishingActivities) {
        FishingActivityEntity fishingActivityEntity = FishingActivityMapper.INSTANCE.mapToFishingActivityEntity(fishingActivity, faReportDocumentEntity, new FishingActivityEntity());
        fishingActivityEntities.add(fishingActivityEntity);
        if (fishingActivityEntity.getAllRelatedFishingActivities() != null && !fishingActivityEntity.getAllRelatedFishingActivities().isEmpty()) {
            fishingActivityEntities.addAll(fishingActivityEntity.getAllRelatedFishingActivities());
        }
    }
    return fishingActivityEntities;
}
Also used : FishingActivity(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) HashSet(java.util.HashSet)

Example 17 with FishingActivityEntity

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

the class FishingActivityMapper method getAllRelatedFishingActivities.

protected Set<FishingActivityEntity> getAllRelatedFishingActivities(List<FishingActivity> fishingActivity, FaReportDocumentEntity faReportDocumentEntity, FishingActivityEntity parentFishingActivity) {
    if (fishingActivity == null || fishingActivity.isEmpty()) {
        return Collections.emptySet();
    }
    Set<FishingActivityEntity> relatedFishingActivityEntities = new HashSet<>();
    for (FishingActivity relatedFishingActivity : fishingActivity) {
        FishingActivityEntity relatedFishingActivityEntity = FishingActivityMapper.INSTANCE.mapToFishingActivityEntity(relatedFishingActivity, faReportDocumentEntity, new FishingActivityEntity());
        relatedFishingActivityEntity.setRelatedFishingActivity(parentFishingActivity);
        relatedFishingActivityEntities.add(relatedFishingActivityEntity);
    }
    return relatedFishingActivityEntities;
}
Also used : FishingActivity(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) HashSet(java.util.HashSet)

Example 18 with FishingActivityEntity

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

Example 19 with FishingActivityEntity

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

the class FishingTripIdWithGeometryMapper method getVesselIdListsForFishingActivity.

private List<VesselIdentifierType> getVesselIdListsForFishingActivity(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 Collections.emptyList();
    }
    int totalFishingActivityCount = fishingActivities.size();
    FishingActivityEntity fishingActivityEntity = fishingActivities.get(totalFishingActivityCount - 1);
    Set<VesselTransportMeansEntity> vesselTransportMeansEntityList = fishingActivityEntity.getFaReportDocument().getVesselTransportMeans();
    if (CollectionUtils.isEmpty(vesselTransportMeansEntityList) || CollectionUtils.isEmpty(vesselTransportMeansEntityList.iterator().next().getVesselIdentifiers())) {
        return Collections.emptyList();
    }
    Set<VesselIdentifierEntity> vesselIdentifierEntities = vesselTransportMeansEntityList.iterator().next().getVesselIdentifiers();
    List<VesselIdentifierType> vesselIdentifierTypes = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(vesselIdentifierEntities)) {
        for (VesselIdentifierEntity vesselIdentifierEntity : vesselIdentifierEntities) {
            VesselIdentifierType vesselIdentifierType = new VesselIdentifierType();
            vesselIdentifierType.setKey(VesselIdentifierSchemeIdEnum.valueOf(vesselIdentifierEntity.getVesselIdentifierSchemeId()));
            vesselIdentifierType.setValue(vesselIdentifierEntity.getVesselIdentifierId());
            vesselIdentifierTypes.add(vesselIdentifierType);
        }
    }
    return vesselIdentifierTypes;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) VesselIdentifierType(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierType) VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) ArrayList(java.util.ArrayList) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 20 with FishingActivityEntity

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

the class ActivityEntityToModelMapper method mapFishingActivities.

private void mapFishingActivities(FAReportDocument faReportDocument, Set<FishingActivityEntity> fishingActivityEntities) {
    if (CollectionUtils.isNotEmpty(fishingActivityEntities)) {
        List<FishingActivity> fishingActivityList = new ArrayList<>();
        for (FishingActivityEntity source : fishingActivityEntities) {
            FishingActivity target = new FishingActivity();
            mapPurposeCode(target, source);
            mapReasonCode(target, source);
            mapOperationsQuantity(target, source);
            mapFisheryTypeCode(target, source);
            mapSpeciesTargetCode(target, source);
            mapFishingDurationMeasure(target, source);
            mapVesselRelatedActivityCode(target, source);
            mapOccurrenceDateTime(target, source.getOccurence());
            mapSourceVesselStorageCharacteristic(target, source.getSourceVesselCharId());
            mapDestinationVesselStorageCharacteristic(target, source.getDestVesselCharId());
            target.setRelatedFLUXLocations(FluxLocationMapper.INSTANCE.mapToFluxLocationList(source.getFluxLocations()));
            mapSpecifiedFLUXCharacteristics(target, source.getFluxCharacteristics());
            target.setSpecifiedDelimitedPeriods(DelimitedPeriodMapper.INSTANCE.mapToDelimitedPeriodList(source.getDelimitedPeriods()));
            List<FishingTrip> fishingTrips = FishingTripMapper.INSTANCE.mapToFishingTripList(source.getFishingTrips());
            if (CollectionUtils.isNotEmpty(fishingTrips)) {
                target.setSpecifiedFishingTrip(fishingTrips.get(0));
            }
            // TODO MAP
            source.getFishingGears();
            // TODO MAP
            source.getFlagState();
            // target.getSpecifiedFACatches() // TODO map
            fishingActivityList.add(target);
        }
        faReportDocument.setSpecifiedFishingActivities(fishingActivityList);
    }
}
Also used : FishingActivity(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity) ArrayList(java.util.ArrayList) FishingTrip(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingTrip) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Aggregations

FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)45 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)14 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)11 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)9 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)8 CatchEvolutionProgressDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO)5 FishingActivityViewDTO (eu.europa.ec.fisheries.ers.service.dto.view.parent.FishingActivityViewDTO)5 SneakyThrows (lombok.SneakyThrows)5 FishingActivity (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity)5 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)4 HashMap (java.util.HashMap)4 Geometry (com.vividsolutions.jts.geom.Geometry)3 FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)3 FluxLocationEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity)3 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)3 BaseActivityViewMapper (eu.europa.ec.fisheries.ers.service.mapper.view.base.BaseActivityViewMapper)3 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)3 FishingActivitySummary (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary)3 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)3