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