Search in sources :

Example 21 with FishingActivityEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripIdWithGeometryMapper method getGeometryMultiPointForAllFishingActivities.

private String getGeometryMultiPointForAllFishingActivities(List<FishingActivityEntity> fishingActivities) {
    if (CollectionUtils.isEmpty(fishingActivities) || fishingActivities.get(0) == null) {
        return null;
    }
    String GeometryWkt = null;
    List<Geometry> activityGeomList = new ArrayList<>();
    for (FishingActivityEntity fishingActivityEntity : fishingActivities) {
        if (fishingActivityEntity.getGeom() != null) {
            activityGeomList.add(fishingActivityEntity.getGeom());
        }
    }
    if (CollectionUtils.isNotEmpty(activityGeomList)) {
        Geometry geometry = GeometryUtils.createMultipoint(activityGeomList);
        StringWrapper stringWrapper = GeometryMapper.INSTANCE.geometryToWkt(geometry);
        if (stringWrapper != null) {
            return stringWrapper.getValue();
        }
    }
    return GeometryWkt;
}
Also used : FishingTripIdWithGeometry(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripIdWithGeometry) Geometry(com.vividsolutions.jts.geom.Geometry) StringWrapper(eu.europa.ec.fisheries.uvms.commons.geometry.model.StringWrapper) ArrayList(java.util.ArrayList) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 22 with FishingActivityEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class JointFishingOperationViewMapper method getVesselDetailsDTO.

/**
 * Addded this method as we want to set storage information explicitely in VesselDetailsDTO.Storage informaation we can only get from activities
 * @param faEntity
 * @return VesselDetailsDTO
 */
protected List<VesselDetailsDTO> getVesselDetailsDTO(FishingActivityEntity faEntity) {
    if (faEntity == null)
        return null;
    List<VesselDetailsDTO> vesselDetailsDTOs = new ArrayList<>();
    Set<VesselTransportMeansEntity> entities = faEntity.getVesselTransportMeans();
    if (CollectionUtils.isEmpty(entities)) {
        entities = new HashSet<>();
    }
    if (CollectionUtils.isNotEmpty(faEntity.getAllRelatedFishingActivities())) {
        for (FishingActivityEntity fishingActivityEntity : faEntity.getAllRelatedFishingActivities()) {
            entities.addAll(fishingActivityEntity.getVesselTransportMeans());
        }
    }
    for (VesselTransportMeansEntity vesselTransportMeansEntity : entities) {
        VesselDetailsDTO vesselDetails = VesselTransportMeansMapper.INSTANCE.map(vesselTransportMeansEntity);
        if (vesselDetails != null && faEntity.getDestVesselCharId() != null) {
            vesselDetails.setStorageDto(VesselStorageCharacteristicsMapper.INSTANCE.mapToStorageDto(faEntity.getDestVesselCharId()));
        }
        vesselDetailsDTOs.add(vesselDetails);
    }
    return vesselDetailsDTOs;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) ArrayList(java.util.ArrayList) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 23 with FishingActivityEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class BaseActivityViewMapper method getRelocations.

public List<RelocationDto> getRelocations(FishingActivityEntity fishingActivityEntity) {
    List<RelocationDto> relocationDtos = new ArrayList<>();
    Set<FishingActivityEntity> relatedActivities = fishingActivityEntity.getAllRelatedFishingActivities();
    for (FishingActivityEntity fishingActivity : relatedActivities) {
        if (fishingActivity.getTypeCode().toUpperCase().equalsIgnoreCase(ActivityViewEnum.RELOCATION.name())) {
            relocationDtos.addAll(FaCatchMapper.INSTANCE.mapToRelocationDtoList(fishingActivity.getFaCatchs()));
        }
    }
    return relocationDtos;
}
Also used : ArrayList(java.util.ArrayList) RelocationDto(eu.europa.ec.fisheries.ers.service.dto.view.RelocationDto) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 24 with FishingActivityEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class CatchEvolutionProgressProcessor method process.

public List<CatchEvolutionProgressDTO> process(List<FishingActivityEntity> fishingActivities) {
    Map<String, Double> speciesCumulatedWeight = new HashMap<>();
    List<CatchEvolutionProgressDTO> catchEvolutionProgressDTOs = new ArrayList<>();
    Collections.sort(fishingActivities, new FishingActivityCalculatedDateComparator());
    int orderId = 1;
    for (FishingActivityEntity fishingActivity : fishingActivities) {
        FishingActivityTypeEnum fishingActivityType = EnumUtils.getEnum(FishingActivityTypeEnum.class, fishingActivity.getTypeCode());
        if (fishingActivityType != null && catchEvolutionProgressRegistry != null && catchEvolutionProgressRegistry.containsHandler(fishingActivityType)) {
            CatchEvolutionProgressHandler catchEvolutionProgressHandler = catchEvolutionProgressRegistry.findHandler(fishingActivityType);
            CatchEvolutionProgressDTO catchEvolutionProgressDTO = catchEvolutionProgressHandler.prepareCatchEvolutionProgressDTO(fishingActivity, speciesCumulatedWeight);
            if (catchEvolutionProgressDTO != null) {
                catchEvolutionProgressDTO.setOrderId(orderId++);
                catchEvolutionProgressDTOs.add(catchEvolutionProgressDTO);
            }
        }
    }
    return catchEvolutionProgressDTOs;
}
Also used : CatchEvolutionProgressDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) FishingActivityTypeEnum(eu.europa.ec.fisheries.ers.fa.utils.FishingActivityTypeEnum)

Example 25 with FishingActivityEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity 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

FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)45 Test (org.junit.Test)17 ArrayList (java.util.ArrayList)14 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)11 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)9 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)8 CatchEvolutionProgressDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CatchEvolutionProgressDTO)5 FishingActivityViewDTO (eu.europa.ec.fisheries.ers.service.dto.view.parent.FishingActivityViewDTO)5 SneakyThrows (lombok.SneakyThrows)5 FishingActivity (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity)5 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)4 HashMap (java.util.HashMap)4 Geometry (com.vividsolutions.jts.geom.Geometry)3 FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)3 FluxLocationEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxLocationEntity)3 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)3 BaseActivityViewMapper (eu.europa.ec.fisheries.ers.service.mapper.view.base.BaseActivityViewMapper)3 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)3 FishingActivitySummary (eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivitySummary)3 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)3