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