use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getPreviousTrips.
private Set<String> getPreviousTrips(String tripId, Integer limit, List<VesselIdentifierEntity> vesselIdentifiers) {
Set<String> tripIds = new LinkedHashSet<>();
if (vesselIdentifiers != null && !vesselIdentifiers.isEmpty()) {
for (VesselIdentifierEntity vesselIdentifier : vesselIdentifiers) {
// FIXME
List<FishingTripIdentifierEntity> identifierEntities = fishingTripIdentifierDao.getPreviousTrips(vesselIdentifier.getVesselIdentifierId(), vesselIdentifier.getVesselIdentifierSchemeId(), tripId, limit);
for (FishingTripIdentifierEntity identifiers : identifierEntities) {
tripIds.add(identifiers.getTripId());
}
}
}
log.debug("Previous Trips : " + tripIds);
return tripIds;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity 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.FishingTripIdentifierEntity 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;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getNextTrips.
private Set<String> getNextTrips(String tripId, Integer limit, List<VesselIdentifierEntity> vesselIdentifiers) {
Set<String> tripIds = new LinkedHashSet<>();
if (vesselIdentifiers != null && !vesselIdentifiers.isEmpty()) {
for (VesselIdentifierEntity vesselIdentifier : vesselIdentifiers) {
// FIXME
List<FishingTripIdentifierEntity> identifierEntities = fishingTripIdentifierDao.getNextTrips(vesselIdentifier.getVesselIdentifierId(), vesselIdentifier.getVesselIdentifierSchemeId(), tripId, limit);
for (FishingTripIdentifierEntity identifiers : identifierEntities) {
tripIds.add(identifiers.getTripId());
}
}
}
log.debug("Next Trips : " + tripIds);
return tripIds;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getCurrentTrip.
private String getCurrentTrip(List<VesselIdentifierEntity> vesselIdentifiers) {
String currentTrip = null;
if (vesselIdentifiers != null && !vesselIdentifiers.isEmpty()) {
for (VesselIdentifierEntity vesselIdentifier : vesselIdentifiers) {
FishingTripIdentifierEntity identifierEntity = fishingTripIdentifierDao.getCurrentTrip(vesselIdentifier.getVesselIdentifierId(), vesselIdentifier.getVesselIdentifierSchemeId());
currentTrip = identifierEntity != null ? identifierEntity.getTripId() : null;
break;
}
}
log.info("Current Trip : " + currentTrip);
return currentTrip;
}
Aggregations