use of eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto 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.TripOverviewDto 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.service.dto.view.TripOverviewDto 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