use of eu.europa.ec.fisheries.ers.service.dto.view.TripWidgetDto in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getTripWidgetDto.
@Override
public /**
* Returns TripWidgetDto based on the tripId and activityId
*/
TripWidgetDto getTripWidgetDto(FishingActivityEntity activityEntity, String tripId) {
if (activityEntity == null && tripId == null) {
return null;
}
TripWidgetDto tripWidgetDto = new TripWidgetDto();
try {
if (tripId != null) {
log.debug("Trip Id found for Fishing Activity. Get TripWidget information for tripID :" + tripId);
TripOverviewDto tripOverviewDto = getTripOverviewDto(activityEntity, tripId);
List<TripOverviewDto> tripOverviewDtoList = new ArrayList<>();
tripOverviewDtoList.add(tripOverviewDto);
tripWidgetDto.setTrips(tripOverviewDtoList);
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;
}
}
}
// VesselDetailsDTO detailsDTO = getVesselDetailsForFishingTrip(tripId);
// tripWidgetDto.setVesselDetails(detailsDTO);
log.debug("tripWidgetDto set for tripID :" + tripId);
} else {
log.debug("TripId is not received for the screen. Try to get TripSummary information for all the tripIds specified for FishingActivity:" + activityEntity.getId());
return createTripWidgetDtoWithFishingActivity(activityEntity);
}
} catch (ServiceException e) {
log.error("Error while creating TripWidgetDto.", e);
}
return tripWidgetDto;
}
use of eu.europa.ec.fisheries.ers.service.dto.view.TripWidgetDto 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