Search in sources :

Example 1 with FishingTripIdWithGeometry

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;
}
Also used : FishingTripIdWithGeometry(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripIdWithGeometry)

Example 2 with 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;
}
Also used : FishingActivitySummary(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary) FishingTripIdWithGeometryMapper(eu.europa.ec.fisheries.ers.service.mapper.FishingTripIdWithGeometryMapper) ArrayList(java.util.ArrayList) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) SortKey(eu.europa.ec.fisheries.ers.service.search.SortKey) FishingTripIdWithGeometry(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripIdWithGeometry) FishingTripId(eu.europa.ec.fisheries.ers.service.search.FishingTripId) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) BigInteger(java.math.BigInteger) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) FishingTripResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripResponse) EnumMap(java.util.EnumMap)

Aggregations

FishingTripIdWithGeometry (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripIdWithGeometry)2 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)1 FishingTripIdWithGeometryMapper (eu.europa.ec.fisheries.ers.service.mapper.FishingTripIdWithGeometryMapper)1 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)1 FishingTripId (eu.europa.ec.fisheries.ers.service.search.FishingTripId)1 SortKey (eu.europa.ec.fisheries.ers.service.search.SortKey)1 FishingActivitySummary (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary)1 FishingTripResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripResponse)1 SearchFilter (eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter)1 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 EnumMap (java.util.EnumMap)1