Search in sources :

Example 11 with FishingTripIdentifierEntity

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

the class FluxMessageServiceBean method setTripStartAndEndDateForFishingTrip.

private void setTripStartAndEndDateForFishingTrip(FishingTripEntity fishingTripEntity) {
    Set<FishingTripIdentifierEntity> identifierEntities = fishingTripEntity.getFishingTripIdentifiers();
    if (CollectionUtils.isEmpty(identifierEntities))
        return;
    for (FishingTripIdentifierEntity tripIdentifierEntity : identifierEntities) {
        try {
            List<FishingActivityEntity> fishingActivityEntityList = fishingTripService.getAllFishingActivitiesForTrip(tripIdentifierEntity.getTripId());
            if (CollectionUtils.isNotEmpty(fishingActivityEntityList)) {
                // Calculate trip start date
                FishingActivityEntity firstFishingActivity = fishingActivityEntityList.get(0);
                tripIdentifierEntity.setCalculatedTripStartDate(firstFishingActivity.getCalculatedStartTime());
                // calculate trip end date
                Date calculatedTripEndDate;
                int totalActivities = fishingActivityEntityList.size();
                if (totalActivities > 1) {
                    calculatedTripEndDate = fishingActivityEntityList.get(totalActivities - 1).getCalculatedStartTime();
                } else {
                    calculatedTripEndDate = firstFishingActivity.getCalculatedStartTime();
                }
                tripIdentifierEntity.setCalculatedTripEndDate(calculatedTripEndDate);
            }
        } catch (Exception e) {
            log.error("Error while trying to calculate FishingTrip start and end Date", e);
        }
    }
}
Also used : FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) Date(java.util.Date) ParseException(com.vividsolutions.jts.io.ParseException) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 12 with FishingTripIdentifierEntity

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

the class ActivityServiceBean method addToIdsList.

private void addToIdsList(List<FaIdsListWithTripIdMap> responseList, FishingActivityEntity faEntity) {
    Set<FishingTripIdentifierEntity> fishingTripIdentifiers = faEntity.getFishingTrips().iterator().next().getFishingTripIdentifiers();
    List<FishingActivityWithIdentifiers> faIdentifiers = mapToActivityIdsAndType(faEntity.getFishingActivityIdentifiers(), faEntity.getTypeCode());
    for (FishingTripIdentifierEntity tripIdentifEntity : fishingTripIdentifiers) {
        FaIdsListWithTripIdMap existingActWithIdentifiers = getElementWithTripId(responseList, tripIdentifEntity.getTripId());
        if (null != existingActWithIdentifiers) {
            existingActWithIdentifiers.getFaIdentifierLists().addAll(faIdentifiers);
        } else {
            responseList.add(new FaIdsListWithTripIdMap(tripIdentifEntity.getTripId(), tripIdentifEntity.getTripSchemeId(), faIdentifiers));
        }
    }
}
Also used : FaIdsListWithTripIdMap(eu.europa.ec.fisheries.uvms.activity.model.schemas.FaIdsListWithTripIdMap) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) FishingActivityWithIdentifiers(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingActivityWithIdentifiers)

Example 13 with FishingTripIdentifierEntity

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

the class FishingTripIdentifierDao method getCurrentTrip.

public FishingTripIdentifierEntity getCurrentTrip(String vesselId, String vesselSchemeId) {
    TypedQuery query = getEntityManager().createNamedQuery(FishingTripIdentifierEntity.FIND_CURRENT_TRIP, FishingTripIdentifierEntity.class);
    query.setParameter(VESSEL_ID, vesselId);
    query.setParameter(VESSEL_SCHEME_ID, vesselSchemeId);
    query.setMaxResults(1);
    List<FishingTripIdentifierEntity> fishingTripIdentifies = query.getResultList();
    if (CollectionUtils.isNotEmpty(fishingTripIdentifies)) {
        return fishingTripIdentifies.get(0);
    } else {
        return null;
    }
}
Also used : TypedQuery(javax.persistence.TypedQuery) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)

Example 14 with FishingTripIdentifierEntity

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

the class ActivityDataUtil method getFishingTripIdentifierEntity.

public static FishingTripIdentifierEntity getFishingTripIdentifierEntity(FishingTripEntity fishingTripEntity, String tripId, String tripSchemeId) {
    FishingTripIdentifierEntity fishingTripIdentifierEntity = new FishingTripIdentifierEntity();
    fishingTripIdentifierEntity.setFishingTrip(fishingTripEntity);
    fishingTripIdentifierEntity.setTripId(tripId);
    fishingTripIdentifierEntity.setTripSchemeId(tripSchemeId);
    try {
        fishingTripIdentifierEntity.setCalculatedTripEndDate(new SimpleDateFormat("dd/MM/yyyy").parse("12/01/2016"));
        fishingTripIdentifierEntity.setCalculatedTripStartDate(new SimpleDateFormat("dd/MM/yyyy").parse("12/01/2013"));
    } catch (ParseException e) {
        e.printStackTrace();
    }
    return fishingTripIdentifierEntity;
}
Also used : ParseException(java.text.ParseException) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) SimpleDateFormat(java.text.SimpleDateFormat)

Example 15 with FishingTripIdentifierEntity

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

the class ActivityServiceBeanTest method mockFishActEntities.

private List<FishingActivityEntity> mockFishActEntities() {
    final FishingActivityEntity fishAct = new FishingActivityEntity();
    FishingActivityIdentifierEntity ident = new FishingActivityIdentifierEntity();
    ident.setFaIdentifierId("faId");
    ident.setFaIdentifierSchemeId("faSchemeId");
    Set<FishingActivityIdentifierEntity> fishIdentList = new HashSet<>();
    fishIdentList.add(ident);
    Set<FishingTripEntity> fishTrips = new HashSet<>();
    FishingTripEntity fishTrip = new FishingTripEntity();
    Set<FishingTripIdentifierEntity> fishingTripIdentifiers = new HashSet<>();
    FishingTripIdentifierEntity tripident = new FishingTripIdentifierEntity();
    tripident.setTripId("tripId");
    tripident.setTripSchemeId("tripSchemeId");
    fishingTripIdentifiers.add(tripident);
    fishTrips.add(fishTrip);
    fishTrip.setTypeCode("someTripCode");
    fishTrip.setFishingActivity(fishAct);
    fishTrip.setFishingTripIdentifiers(fishingTripIdentifiers);
    fishAct.setFishingActivityIdentifiers(fishIdentList);
    fishAct.setTypeCode("faTypeCode");
    fishAct.setFishingTrips(fishTrips);
    return new ArrayList<FishingActivityEntity>() {

        {
            add(fishAct);
        }
    };
}
Also used : FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) ArrayList(java.util.ArrayList) FishingActivityIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityIdentifierEntity) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity) HashSet(java.util.HashSet)

Aggregations

FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)18 ArrayList (java.util.ArrayList)5 FishingTripEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity)4 CronologyTripDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO)4 SneakyThrows (lombok.SneakyThrows)4 Test (org.junit.Test)4 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)3 VesselIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity)3 HashSet (java.util.HashSet)3 LinkedHashSet (java.util.LinkedHashSet)3 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)2 TripOverviewDto (eu.europa.ec.fisheries.ers.service.dto.view.TripOverviewDto)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 ParseException (com.vividsolutions.jts.io.ParseException)1 FaCatchEntity (eu.europa.ec.fisheries.ers.fa.entities.FaCatchEntity)1 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)1 FishingActivityIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityIdentifierEntity)1 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)1 SizeDistributionEntity (eu.europa.ec.fisheries.ers.fa.entities.SizeDistributionEntity)1 FishingActivityTypeDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.FishingActivityTypeDTO)1