use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class BaseMapper method mapToFishingTripEntitySet.
public static Set<FishingTripEntity> mapToFishingTripEntitySet(FishingTrip fishingTrip, FishingActivityEntity fishingActivityEntity) {
if (fishingTrip == null) {
return Collections.emptySet();
}
FishingTripEntity fishingTripEntity = mapToFishingTripEntity(fishingTrip);
fishingTripEntity.setFishingActivity(fishingActivityEntity);
return new HashSet<>(Collections.singletonList(fishingTripEntity));
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class BaseMapper method mapToFishingTripEntitySet.
public static Set<FishingTripEntity> mapToFishingTripEntitySet(List<FishingTrip> fishingTrips, FaCatchEntity faCatchEntity) {
if (fishingTrips == null || fishingTrips.isEmpty()) {
return Collections.emptySet();
}
Set<FishingTripEntity> fishingTripEntities = new HashSet<>();
for (FishingTrip fishingTrip : fishingTrips) {
FishingTripEntity fishingTripEntity = mapToFishingTripEntity(fishingTrip);
fishingTripEntity.setFaCatch(faCatchEntity);
fishingTripEntities.add(fishingTripEntity);
}
return fishingTripEntities;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityMapper method getFishingTripId.
protected String getFishingTripId(FishingActivityEntity fishingActivityEntity) {
if (fishingActivityEntity == null || CollectionUtils.isEmpty(fishingActivityEntity.getFishingTrips())) {
return null;
}
Set<FishingTripEntity> fishingTripEntities = fishingActivityEntity.getFishingTrips();
FishingTripEntity fishingTripEntity = fishingTripEntities.iterator().next();
if (CollectionUtils.isEmpty(fishingTripEntity.getFishingTripIdentifiers()))
return null;
return fishingTripEntity.getFishingTripIdentifiers().iterator().next().getTripId();
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getTripOverviewDto.
@NotNull
private TripOverviewDto getTripOverviewDto(FishingActivityEntity activityEntity, String tripId) throws ServiceException {
Map<String, FishingActivityTypeDTO> typeDTOMap = populateFishingActivityReportListAndFishingTripSummary(tripId, null, null, true);
TripOverviewDto tripOverviewDto = new TripOverviewDto();
// Find out fishingTrip schemeId matching to tripId from fishingActivity object.
Set<FishingTripEntity> fishingTripEntities = activityEntity.getFishingTrips();
if (CollectionUtils.isNotEmpty(fishingTripEntities)) {
for (FishingTripEntity fishingTripEntity : fishingTripEntities) {
Set<FishingTripIdentifierEntity> identifierEntities = fishingTripEntity.getFishingTripIdentifiers();
for (FishingTripIdentifierEntity tripIdentifierEntity : identifierEntities) {
if (tripId.equalsIgnoreCase(tripIdentifierEntity.getTripId())) {
TripIdDto tripIdDto = new TripIdDto();
tripIdDto.setId(tripId);
tripIdDto.setSchemeId(tripIdentifierEntity.getTripSchemeId());
List<TripIdDto> tripIdList = new ArrayList<>();
tripIdList.add(tripIdDto);
tripOverviewDto.setTripId(tripIdList);
break;
}
}
}
}
populateTripOverviewDto(typeDTOMap, tripOverviewDto);
return tripOverviewDto;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method createTripWidgetDtoWithFishingActivity.
public TripWidgetDto createTripWidgetDtoWithFishingActivity(FishingActivityEntity activityEntity) throws ServiceException {
TripWidgetDto tripWidgetDto = new TripWidgetDto();
Set<FishingTripEntity> fishingTripEntities = activityEntity.getFishingTrips();
if (CollectionUtils.isEmpty(fishingTripEntities)) {
throw new ServiceException(" Could not find fishingTrips associated with FishingActivity id :" + activityEntity.getId());
}
List<TripOverviewDto> tripOverviewDtoList = new ArrayList<>();
// try to find unique tripIds for the fishing Activity
Set<String> tripIdSet = new HashSet<>();
for (FishingTripEntity fishingTripEntity : fishingTripEntities) {
Set<FishingTripIdentifierEntity> identifierEntities = fishingTripEntity.getFishingTripIdentifiers();
for (FishingTripIdentifierEntity tripIdentifierEntity : identifierEntities) {
if (!tripIdSet.contains(tripIdentifierEntity.getTripId())) {
log.debug("Get Trip summary information for tripID :" + tripIdentifierEntity.getTripId());
tripOverviewDtoList.add(getTripOverviewDto(activityEntity, tripIdentifierEntity.getTripId()));
tripIdSet.add(tripIdentifierEntity.getTripId());
}
}
}
tripWidgetDto.setTrips(tripOverviewDtoList);
// As per new requirement, vessel should always be the one associated with fishing Activity in the trip widget
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;
}
}
}
return tripWidgetDto;
}
Aggregations