Search in sources :

Example 1 with FluxLocationEntity

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

the class FaCatchMapperTest method testFaCatchMapper.

@Test
public void testFaCatchMapper() {
    FACatch faCatch = MapperUtil.getFaCatch();
    FaCatchEntity faCatchEntity = FaCatchMapper.INSTANCE.mapToFaCatchEntity(faCatch);
    assertFaCatchFields(faCatch, faCatchEntity);
    assertNull(faCatchEntity.getFishingActivity());
    assertNotNull(faCatchEntity.getAapProcesses());
    AapProcessEntity aapProcessEntity = faCatchEntity.getAapProcesses().iterator().next();
    assertNotNull(aapProcessEntity);
    assertFaCatchFields(faCatch, aapProcessEntity.getFaCatch());
    assertNotNull(faCatchEntity.getAapStocks());
    AapStockEntity aapStockEntity = faCatchEntity.getAapStocks().iterator().next();
    assertNotNull(aapStockEntity);
    assertFaCatchFields(faCatch, aapStockEntity.getFaCatch());
    assertNotNull(faCatchEntity.getSizeDistribution());
    assertFaCatchFields(faCatch, faCatchEntity.getSizeDistribution().getFaCatch());
    assertNotNull(faCatchEntity.getFishingGears());
    FishingGearEntity fishingGearEntity = faCatchEntity.getFishingGears().iterator().next();
    assertNotNull(fishingGearEntity);
    assertFaCatchFields(faCatch, fishingGearEntity.getFaCatch());
    assertNotNull(faCatchEntity.getFishingTrips());
    FishingTripEntity fishingTripEntity = faCatchEntity.getFishingTrips().iterator().next();
    assertNotNull(fishingTripEntity);
    assertFaCatchFields(faCatch, fishingTripEntity.getFaCatch());
    assertNotNull(faCatchEntity.getFluxCharacteristics());
    FluxCharacteristicEntity fluxCharacteristicEntity = faCatchEntity.getFluxCharacteristics().iterator().next();
    assertNotNull(fluxCharacteristicEntity);
    assertFaCatchFields(faCatch, fluxCharacteristicEntity.getFaCatch());
    assertNotNull(faCatchEntity.getFluxLocations());
    FluxLocationEntity fluxLocationEntity = faCatchEntity.getFluxLocations().iterator().next();
    assertNotNull(fluxLocationEntity);
    assertFaCatchFields(faCatch, fluxLocationEntity.getFaCatch());
}
Also used : FaCatchEntity(eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity) AapStockEntity(eu.europa.ec.fisheries.ers.fa.entities.AapStockEntity) FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) AapProcessEntity(eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity) FACatch(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FACatch) FishingGearEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity) FluxCharacteristicEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity) FluxLocationEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity) Test(org.junit.Test)

Example 2 with FluxLocationEntity

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

the class FluxLocationMapperTest method getFluxLocationEntityMock.

private FluxLocationEntity getFluxLocationEntityMock() {
    FLUXLocation fluxLocation = MapperUtil.getFluxLocation();
    FluxLocationCatchTypeEnum fluxLocationTypeEnum = FluxLocationCatchTypeEnum.FA_CATCH_SPECIFIED;
    FluxLocationEntity fluxLocationEntity = FluxLocationMapper.INSTANCE.mapToFluxLocationEntity(fluxLocation);
    fluxLocationEntity.setFluxLocationType(fluxLocationTypeEnum.getType());
    return fluxLocationEntity;
}
Also used : FLUXLocation(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXLocation) FluxLocationCatchTypeEnum(eu.europa.ec.fisheries.ers.fa.utils.FluxLocationCatchTypeEnum) FluxLocationEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity)

Example 3 with FluxLocationEntity

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

the class FluxMessageServiceBean method populateGeometriesForFishingActivities.

private List<Geometry> populateGeometriesForFishingActivities(List<MovementType> movements, Set<FishingActivityEntity> fishingActivityEntities) throws ServiceException {
    List<Geometry> multiPointForFaReport = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(fishingActivityEntities)) {
        for (FishingActivityEntity fishingActivity : fishingActivityEntities) {
            List<Geometry> multiPointForFa = new ArrayList<>();
            Date activityDate = fishingActivity.getOccurence() != null ? fishingActivity.getOccurence() : getFirstDateFromDelimitedPeriods(fishingActivity.getDelimitedPeriods());
            Geometry interpolatedPoint = interpolatePointFromMovements(movements, activityDate);
            for (FluxLocationEntity fluxLocation : fishingActivity.getFluxLocations()) {
                Geometry point = null;
                String fluxLocationStr = fluxLocation.getTypeCode();
                if (fluxLocationStr.equalsIgnoreCase(FluxLocationEnum.AREA.name())) {
                    point = interpolatedPoint;
                    fluxLocation.setGeom(point);
                } else if (fluxLocationStr.equalsIgnoreCase(FluxLocationEnum.LOCATION.name())) {
                    point = getGeometryForLocation(fluxLocation);
                    log.debug("Geometry calculated for location is:" + point);
                    fluxLocation.setGeom(point);
                } else if (fluxLocationStr.equalsIgnoreCase(FluxLocationEnum.POSITION.name())) {
                    point = GeometryUtils.createPoint(fluxLocation.getLongitude(), fluxLocation.getLatitude());
                    fluxLocation.setGeom(point);
                }
                if (point != null) {
                    multiPointForFa.add(point);
                    multiPointForFaReport.add(point);
                }
            }
            fishingActivity.setGeom(GeometryUtils.createMultipoint(multiPointForFa));
        }
    }
    return multiPointForFaReport;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ArrayList(java.util.ArrayList) Date(java.util.Date) FluxLocationEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 4 with FluxLocationEntity

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

the class FaCatchMapper method getFluxLocationEntities.

protected Set<FluxLocationEntity> getFluxLocationEntities(List<FLUXLocation> specifiedFluxLocations, List<FLUXLocation> destFluxLocations, FaCatchEntity faCatchEntity) {
    Set<FluxLocationEntity> fluxLocationEntities = new HashSet<>();
    if (specifiedFluxLocations != null && !specifiedFluxLocations.isEmpty()) {
        for (FLUXLocation fluxLocation : specifiedFluxLocations) {
            FluxLocationEntity fluxLocationEntity = FluxLocationMapper.INSTANCE.mapToFluxLocationEntity(fluxLocation);
            Set<StructuredAddressEntity> structuredAddressEntitySet = new HashSet<>();
            StructuredAddress physicalStructuredAddress = fluxLocation.getPhysicalStructuredAddress();
            StructuredAddressEntity physicalStructuredAddressEntity = StructuredAddressMapper.INSTANCE.mapToStructuredAddressEntity(physicalStructuredAddress);
            if (physicalStructuredAddressEntity != null) {
                physicalStructuredAddressEntity.setFluxLocation(fluxLocationEntity);
                physicalStructuredAddressEntity.setStructuredAddressType(StructuredAddressTypeEnum.FLUX_PHYSICAL.getType());
                structuredAddressEntitySet.add(physicalStructuredAddressEntity);
            }
            List<StructuredAddress> postalStructuredAddresses = fluxLocation.getPostalStructuredAddresses();
            if (postalStructuredAddresses != null && !postalStructuredAddresses.isEmpty()) {
                for (StructuredAddress structuredAddress : postalStructuredAddresses) {
                    StructuredAddressEntity structuredAddressEntity = StructuredAddressMapper.INSTANCE.mapToStructuredAddressEntity(structuredAddress);
                    if (structuredAddressEntity != null) {
                        structuredAddressEntity.setStructuredAddressType(StructuredAddressTypeEnum.FLUX_POSTAL.getType());
                        structuredAddressEntity.setFluxLocation(fluxLocationEntity);
                        structuredAddressEntitySet.add(structuredAddressEntity);
                    }
                }
            }
            fluxLocationEntity.setStructuredAddresses(structuredAddressEntitySet);
            fluxLocationEntity.setFaCatch(faCatchEntity);
            fluxLocationEntity.setFluxLocationType(FluxLocationCatchTypeEnum.FA_CATCH_SPECIFIED.getType());
            fluxLocationEntities.add(fluxLocationEntity);
        }
    }
    if (destFluxLocations != null && !destFluxLocations.isEmpty()) {
        for (FLUXLocation fluxLocation : destFluxLocations) {
            FluxLocationEntity fluxLocationEntity = FluxLocationMapper.INSTANCE.mapToFluxLocationEntity(fluxLocation);
            fluxLocationEntity.setFaCatch(faCatchEntity);
            fluxLocationEntity.setFluxLocationType(FluxLocationCatchTypeEnum.FA_CATCH_DESTINATION.getType());
            fluxLocationEntities.add(fluxLocationEntity);
        }
    }
    return fluxLocationEntities;
}
Also used : StructuredAddressEntity(eu.europa.ec.fisheries.ers.fa.entities.StructuredAddressEntity) FLUXLocation(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXLocation) StructuredAddress(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.StructuredAddress) FluxLocationEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity) HashSet(java.util.HashSet)

Example 5 with FluxLocationEntity

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

the class FishingActivityMapper method getPortsForFishingActivity.

protected List<String> getPortsForFishingActivity(FishingActivityEntity entity) {
    if (entity == null || entity.getFluxLocations() == null) {
        return Collections.emptyList();
    }
    Set<String> ports = new HashSet<>();
    Set<FluxLocationEntity> fluxLocations = entity.getFluxLocations();
    for (FluxLocationEntity location : fluxLocations) {
        if (LOCATION_PORT.equalsIgnoreCase(location.getTypeCode())) {
            ports.add(location.getFluxLocationIdentifier());
        }
    }
    ports.remove(null);
    return new ArrayList<>(ports);
}
Also used : ArrayList(java.util.ArrayList) FluxLocationEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity) HashSet(java.util.HashSet)

Aggregations

FluxLocationEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity)16 Test (org.junit.Test)7 HashSet (java.util.HashSet)5 FLUXLocation (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXLocation)5 FluxLocationDto (eu.europa.ec.fisheries.ers.service.dto.view.FluxLocationDto)4 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)3 ArrayList (java.util.ArrayList)3 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)2 FishingGearEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingGearEntity)2 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)2 FluxCharacteristicEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxCharacteristicEntity)2 BaseUnitilsTest (eu.europa.ec.fisheries.uvms.BaseUnitilsTest)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 AapProcessEntity (eu.europa.ec.fisheries.ers.fa.entities.AapProcessEntity)1 AapStockEntity (eu.europa.ec.fisheries.ers.fa.entities.AapStockEntity)1 DelimitedPeriodEntity (eu.europa.ec.fisheries.ers.fa.entities.DelimitedPeriodEntity)1 FishingActivityIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityIdentifierEntity)1 StructuredAddressEntity (eu.europa.ec.fisheries.ers.fa.entities.StructuredAddressEntity)1 FluxLocationCatchTypeEnum (eu.europa.ec.fisheries.ers.fa.utils.FluxLocationCatchTypeEnum)1 DestinationLocationDto (eu.europa.ec.fisheries.ers.service.dto.facatch.DestinationLocationDto)1