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());
}
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;
}
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;
}
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;
}
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);
}
Aggregations