use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary 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;
}
use of eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary 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.uvms.activity.model.schemas.FishingActivitySummary in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripIdSearchBuilder method getFishingActivitySummary.
private FishingActivitySummary getFishingActivitySummary(Set<Integer> uniqueFishingActivityIdList, FishingTripEntity entity) {
FishingActivitySummary fishingActivitySummary = null;
FishingActivityEntity fishingActivityEntity = entity.getFishingActivity();
if (fishingActivityEntity != null && uniqueFishingActivityIdList.add(fishingActivityEntity.getId())) {
fishingActivitySummary = FishingActivityMapper.INSTANCE.mapToFishingActivitySummary(entity.getFishingActivity());
ContactPartyEntity contactParty = getContactParty(fishingActivityEntity);
if (contactParty != null) {
VesselContactPartyType vesselContactParty = FishingActivityMapper.INSTANCE.mapToVesselContactParty(contactParty);
fishingActivitySummary.setVesselContactParty(vesselContactParty);
}
}
return fishingActivitySummary;
}
Aggregations