use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripIdWithGeometry in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripIdWithGeometryMapper method mapToFishingTripIdWithDetails.
public FishingTripIdWithGeometry mapToFishingTripIdWithDetails(FishingTripId dto, List<FishingActivityEntity> fishingActivities) {
if (dto == null && fishingActivities == null) {
return null;
}
FishingTripIdWithGeometry fishingTripIdWithGeometry = new FishingTripIdWithGeometry();
if (dto != null) {
fishingTripIdWithGeometry.setTripId(dto.getTripId());
fishingTripIdWithGeometry.setSchemeId(dto.getSchemeID());
}
fishingTripIdWithGeometry.setFirstFishingActivityDateTime(getFirstFishingActivityStartTime(fishingActivities));
fishingTripIdWithGeometry.setVesselIdLists(getVesselIdListsForFishingActivity(fishingActivities));
fishingTripIdWithGeometry.setNoOfCorrections(getNumberOfCorrectionsForFishingActivities(fishingActivities));
fishingTripIdWithGeometry.setRelativeLastFaDateTime(getRelativeLastFishingActivityDateForTrip(fishingActivities));
fishingTripIdWithGeometry.setFirstFishingActivity(getFirstFishingActivityType(fishingActivities));
fishingTripIdWithGeometry.setFlagState(getFlagStateFromActivityList(fishingActivities));
fishingTripIdWithGeometry.setLastFishingActivity(getLastFishingActivityType(fishingActivities));
fishingTripIdWithGeometry.setRelativeFirstFaDateTime(getRelativeFirstFishingActivityDateForTrip(fishingActivities));
fishingTripIdWithGeometry.setGeometry(getGeometryMultiPointForAllFishingActivities(fishingActivities));
fishingTripIdWithGeometry.setTripDuration(getTotalTripDuration(fishingActivities));
fishingTripIdWithGeometry.setLastFishingActivityDateTime(getLastFishingActivityStartTime(fishingActivities));
return fishingTripIdWithGeometry;
}
use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripIdWithGeometry in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method buildFishingTripSearchRespose.
/**
* This method builds FishingTripSerachReponse objectc for FishingTripIds passed to the method
* collectFishingActivities : If the value is TRUE, all fishing Activities for every fishing Trip would be sent in the response.
* If the value is FALSE, No fishing activities would be sent in the response.
*/
public FishingTripResponse buildFishingTripSearchRespose(Set<FishingTripId> fishingTripIds, boolean collectFishingActivities) throws ServiceException {
if (fishingTripIds == null || fishingTripIds.isEmpty()) {
return new FishingTripResponse();
}
List<Integer> uniqueActivityIdList = new ArrayList<>();
List<FishingActivitySummary> fishingActivitySummaries = new ArrayList<>();
List<FishingTripIdWithGeometry> fishingTripIdLists = new ArrayList<>();
for (FishingTripId fishingTripId : fishingTripIds) {
// FIXME find a way to remove execution of queries inside loop
FishingActivityQuery query = new FishingActivityQuery();
Map<SearchFilter, String> searchCriteriaMap = new EnumMap<>(SearchFilter.class);
searchCriteriaMap.put(SearchFilter.TRIP_ID, fishingTripId.getTripId());
searchCriteriaMap.put(SearchFilter.FISHING_TRIP_SCHEME_ID, fishingTripId.getSchemeID());
query.setSearchCriteriaMap(searchCriteriaMap);
SortKey sortKey = new SortKey();
// this is important to find out first and last fishing activity for the Fishing Trip
sortKey.setSortBy(SearchFilter.PERIOD_START);
sortKey.setReversed(false);
query.setSorting(sortKey);
List<FishingActivityEntity> fishingActivityEntityList = fishingActivityDao.getFishingActivityListByQuery(query);
if (collectFishingActivities) {
fishingActivitySummaries.addAll(getFishingActivitySummaryList(fishingActivityEntityList, uniqueActivityIdList));
}
FishingTripIdWithGeometry fishingTripIdWithGeometry = new FishingTripIdWithGeometryMapper().mapToFishingTripIdWithDetails(fishingTripId, fishingActivityEntityList);
fishingTripIdLists.add(fishingTripIdWithGeometry);
}
// populate response object
FishingTripResponse response = new FishingTripResponse();
response.setFishingActivityLists(fishingActivitySummaries);
response.setFishingTripIdLists(fishingTripIdLists);
return response;
}
Aggregations