Search in sources :

Example 1 with FishingActivitySummary

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;
}
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)

Example 2 with FishingActivitySummary

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;
}
Also used : FishingActivitySummary(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary) ArrayList(java.util.ArrayList) VesselContactPartyType(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselContactPartyType) ContactPartyEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 3 with FishingActivitySummary

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;
}
Also used : FishingActivitySummary(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary) VesselContactPartyType(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselContactPartyType) ContactPartyEntity(eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Aggregations

FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)3 FishingActivitySummary (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary)3 ContactPartyEntity (eu.europa.ec.fisheries.ers.fa.entities.ContactPartyEntity)2 VesselContactPartyType (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselContactPartyType)2 ArrayList (java.util.ArrayList)2 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 FishingTripIdWithGeometry (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripIdWithGeometry)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 EnumMap (java.util.EnumMap)1