use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method populateTripOverviewDto.
private void populateTripOverviewDto(Map<String, FishingActivityTypeDTO> typeDTOMap, TripOverviewDto tripOverviewDto) {
for (Map.Entry<String, FishingActivityTypeDTO> entry : typeDTOMap.entrySet()) {
String key = entry.getKey();
FishingActivityTypeDTO fishingActivityTypeDTO = entry.getValue();
switch(FishingActivityTypeEnum.valueOf(key)) {
case DEPARTURE:
tripOverviewDto.setDepartureTime(fishingActivityTypeDTO.getDate());
break;
case ARRIVAL:
tripOverviewDto.setArrivalTime(fishingActivityTypeDTO.getDate());
break;
case LANDING:
tripOverviewDto.setLandingTime(fishingActivityTypeDTO.getDate());
break;
default:
log.debug("Fishing Activity type found is :" + key);
break;
}
}
}
use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method populateFishingTripSummary.
public void populateFishingTripSummary(FishingActivityEntity activityEntity, Map<String, FishingActivityTypeDTO> summary) {
String activityTypeCode = activityEntity.getTypeCode();
if (DEPARTURE.toString().equalsIgnoreCase(activityTypeCode) || ARRIVAL.toString().equalsIgnoreCase(activityTypeCode) || LANDING.toString().equalsIgnoreCase(activityTypeCode)) {
Date occurrence = activityEntity.getOccurence();
Boolean isCorrection = BaseMapper.getCorrection(activityEntity);
FishingActivityTypeDTO fishingActivityTypeDTO = summary.get(activityTypeCode);
if (fishingActivityTypeDTO == null || (isCorrection && fishingActivityTypeDTO.getDate() != null && occurrence != null && occurrence.compareTo(fishingActivityTypeDTO.getDate()) > 0)) {
fishingActivityTypeDTO = new FishingActivityTypeDTO();
fishingActivityTypeDTO.setDate(occurrence);
summary.put(activityTypeCode, fishingActivityTypeDTO);
}
}
}
use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO 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.fishingtrip.FishingActivityTypeDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getFishingTripSummaryAndReports.
@Override
public FishingTripSummaryViewDTO getFishingTripSummaryAndReports(String fishingTripId, List<Dataset> datasets) throws ServiceException {
List<ReportDTO> reportDTOList = new ArrayList<>();
Geometry multipolygon = getRestrictedAreaGeom(datasets);
Map<String, FishingActivityTypeDTO> summary = populateFishingActivityReportListAndFishingTripSummary(fishingTripId, reportDTOList, multipolygon, false);
return populateFishingTripSummary(fishingTripId, reportDTOList, summary);
}
use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method populateFishingActivityReportListAndFishingTripSummary.
/**
* @param fishingTripId - Fishing trip summary will be collected for this tripID
* @param reportDTOList - This DTO will have details about Fishing Activities.Method will process and populate data into this list *
* @param multipolygon - Activities only in this area would be selected
* @param isOnlyTripSummary - This method you could reuse to only get Fishing trip summary as well
* @throws ServiceException
*/
@Override
public Map<String, FishingActivityTypeDTO> populateFishingActivityReportListAndFishingTripSummary(String fishingTripId, List<ReportDTO> reportDTOList, Geometry multipolygon, boolean isOnlyTripSummary) throws ServiceException {
List<FishingActivityEntity> fishingActivityList = fishingActivityDao.getFishingActivityListForFishingTrip(fishingTripId, multipolygon);
if (CollectionUtils.isEmpty(fishingActivityList)) {
return Collections.emptyMap();
}
Map<String, FishingActivityTypeDTO> tripSummary = new HashMap<>();
for (FishingActivityEntity activityEntity : fishingActivityList) {
if (!isOnlyTripSummary) {
ReportDTO reportDTO = FishingActivityMapper.INSTANCE.mapToReportDTO(activityEntity);
reportDTOList.add(reportDTO);
}
if (activityEntity != null && activityEntity.getFaReportDocument() != null && ActivityConstants.DECLARATION.equalsIgnoreCase(activityEntity.getFaReportDocument().getTypeCode())) {
// FA Report should be of type Declaration. And Fishing Activity type should be Either Departure,Arrival or Landing
populateFishingTripSummary(activityEntity, tripSummary);
}
}
return tripSummary;
}
Aggregations