use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getFishingActivitySummaryList.
/**
* This method creates FishingActivitySummary object from FishingActivityEntity object retrieved from database.
*
* @param uniqueActivityIdList This method helps parent function to collect FishingActivities for all the fishingTrips. In order to avoid duplicate fishing Activities, we need to maintain uniqueActivityIdList
* @param fishingActivityEntityList
* @return
*/
public List<FishingActivitySummary> getFishingActivitySummaryList(List<FishingActivityEntity> fishingActivityEntityList, List<Integer> uniqueActivityIdList) {
List<FishingActivitySummary> fishingActivitySummaryList = new ArrayList<>();
if (CollectionUtils.isEmpty(uniqueActivityIdList)) {
uniqueActivityIdList = new ArrayList<>();
}
for (FishingActivityEntity fishingActivityEntity : fishingActivityEntityList) {
if (fishingActivityEntity != null && uniqueActivityIdList.add(fishingActivityEntity.getId())) {
FishingActivitySummary fishingActivitySummary = FishingActivityMapper.INSTANCE.mapToFishingActivitySummary(fishingActivityEntity);
ContactPartyEntity contactParty = getContactParty(fishingActivityEntity);
if (contactParty != null) {
VesselContactPartyType vesselContactParty = FishingActivityMapper.INSTANCE.mapToVesselContactParty(contactParty);
fishingActivitySummary.setVesselContactParty(vesselContactParty);
}
if (fishingActivitySummary != null) {
fishingActivitySummaryList.add(fishingActivitySummary);
}
}
}
return fishingActivitySummaryList;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity 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;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method createMessageCounter.
/**
* Populates the MessageCounter adding to the right counter 1 unit depending on the type of report (typeCode, purposeCode, size()).
*
* @param faReportDocumentList
*/
public MessageCountDTO createMessageCounter(List<FaReportDocumentEntity> faReportDocumentList) {
MessageCountDTO messagesCounter = new MessageCountDTO();
if (CollectionUtils.isEmpty(faReportDocumentList)) {
return messagesCounter;
}
// Reports total
messagesCounter.setNoOfReports(faReportDocumentList.size());
for (FaReportDocumentEntity faReport : faReportDocumentList) {
String faDocumentType = faReport.getTypeCode();
String purposeCode = faReport.getFluxReportDocument().getPurpose();
// Declarations / Notifications
if (ActivityConstants.DECLARATION.equalsIgnoreCase(faDocumentType)) {
messagesCounter.setNoOfDeclarations(messagesCounter.getNoOfDeclarations() + 1);
} else if (ActivityConstants.NOTIFICATION.equalsIgnoreCase(faDocumentType)) {
messagesCounter.setNoOfNotifications(messagesCounter.getNoOfNotifications() + 1);
}
// Fishing operations
Set<FishingActivityEntity> faEntitiyList = faReport.getFishingActivities();
if (isNotEmpty(faEntitiyList)) {
for (FishingActivityEntity faEntity : faEntitiyList) {
if (FishingActivityTypeEnum.FISHING_OPERATION.toString().equalsIgnoreCase(faEntity.getTypeCode())) {
messagesCounter.setNoOfFishingOperations(messagesCounter.getNoOfFishingOperations() + 1);
}
}
}
// PurposeCode : Deletions / Cancellations / Corrections
if (ActivityConstants.DELETE.equalsIgnoreCase(purposeCode)) {
messagesCounter.setNoOfDeletions(messagesCounter.getNoOfDeletions() + 1);
} else if (ActivityConstants.CANCELLATION.equalsIgnoreCase(purposeCode)) {
messagesCounter.setNoOfCancellations(messagesCounter.getNoOfCancellations() + 1);
} else if (ActivityConstants.CORRECTION.equalsIgnoreCase(purposeCode)) {
messagesCounter.setNoOfCorrections(messagesCounter.getNoOfCorrections() + 1);
}
}
return messagesCounter;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getVesselDetailsForFishingTrip.
@Override
public VesselDetailsDTO getVesselDetailsForFishingTrip(final String fishingTripId) throws ServiceException {
if (fishingTripId == null) {
throw new IllegalArgumentException("PARAMETER CANNOT BE NULL");
}
VesselDetailsDTO detailsDTO = null;
try {
VesselTransportMeansEntity latestVesselByTripId = vesselTransportMeansDao.findLatestVesselByTripId(fishingTripId);
if (latestVesselByTripId != null) {
FishingActivityEntity parent = latestVesselByTripId.getFishingActivity();
detailsDTO = getVesselDetailsDTO(latestVesselByTripId, parent);
}
} catch (ServiceException e) {
throw new ServiceException(e.getMessage(), e);
}
return detailsDTO;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FluxMessageServiceBean method setTripStartAndEndDateForFishingTrip.
private void setTripStartAndEndDateForFishingTrip(FishingTripEntity fishingTripEntity) {
Set<FishingTripIdentifierEntity> identifierEntities = fishingTripEntity.getFishingTripIdentifiers();
if (CollectionUtils.isEmpty(identifierEntities))
return;
for (FishingTripIdentifierEntity tripIdentifierEntity : identifierEntities) {
try {
List<FishingActivityEntity> fishingActivityEntityList = fishingTripService.getAllFishingActivitiesForTrip(tripIdentifierEntity.getTripId());
if (CollectionUtils.isNotEmpty(fishingActivityEntityList)) {
// Calculate trip start date
FishingActivityEntity firstFishingActivity = fishingActivityEntityList.get(0);
tripIdentifierEntity.setCalculatedTripStartDate(firstFishingActivity.getCalculatedStartTime());
// calculate trip end date
Date calculatedTripEndDate;
int totalActivities = fishingActivityEntityList.size();
if (totalActivities > 1) {
calculatedTripEndDate = fishingActivityEntityList.get(totalActivities - 1).getCalculatedStartTime();
} else {
calculatedTripEndDate = firstFishingActivity.getCalculatedStartTime();
}
tripIdentifierEntity.setCalculatedTripEndDate(calculatedTripEndDate);
}
} catch (Exception e) {
log.error("Error while trying to calculate FishingTrip start and end Date", e);
}
}
}
Aggregations