Search in sources :

Example 31 with FishingActivityEntity

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

the class ActivityServiceBean method getFishingActivityForView.

/**
 * Gets a FishingActivityEntity with a certain activityId and maps it to a FishingActivityViewDTO representation layer POJO.
 *
 * @param activityId
 * @param datasets
 * @return
 * @throws ServiceException
 */
@Override
public FishingActivityViewDTO getFishingActivityForView(Integer activityId, String tripId, List<Dataset> datasets, ActivityViewEnum view) throws ServiceException {
    Geometry geom = getRestrictedAreaGeometry(datasets);
    FishingActivityEntity activityEntity = fishingActivityDao.getFishingActivityById(activityId, geom);
    if (activityEntity == null)
        throw new ServiceException("Could not find FishingActivityEntity for the given id:" + activityId);
    log.debug("FishingActivityEntity fetched from database with id:" + activityEntity.getId());
    FishingActivityViewDTO fishingActivityViewDTO = ActivityViewMapperFactory.getMapperForView(view).mapFaEntityToFaDto(activityEntity);
    fishingActivityViewDTO.setTripDetails(fishingTripServiceBean.getTripWidgetDto(activityEntity, tripId));
    log.debug("fishingActivityView generated after mapping is :" + fishingActivityViewDTO);
    addPortDescriptions(fishingActivityViewDTO, "LOCATION");
    fishingActivityViewDTO.setTripDetails(fishingTripServiceBean.getTripWidgetDto(activityEntity, tripId));
    fishingActivityViewDTO.setHistory(getActivityHistoryDto(activityEntity));
    log.debug("fishingActivityView generated after mapping is :" + fishingActivityViewDTO);
    return fishingActivityViewDTO;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) FishingActivityViewDTO(eu.europa.ec.fisheries.ers.service.dto.view.parent.FishingActivityViewDTO) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 32 with FishingActivityEntity

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

the class FishingActivityDao method getFishingActivityById.

/**
 * Returns a FishingActivityEntity with joined tables depending on the view (ARRIVAL, DEPARTURE, etc..).
 *
 * @param activityId
 * @param geom
 * @return
 */
public FishingActivityEntity getFishingActivityById(Integer activityId, Geometry geom) {
    String s = fillQueryConditions(geom);
    Query typedQuery = getEntityManager().createQuery(s);
    typedQuery.setParameter("fishingActivityId", activityId);
    if (geom != null) {
        typedQuery.setParameter("area", geom);
    }
    List<FishingActivityEntity> resultList = typedQuery.getResultList();
    if (CollectionUtils.isEmpty(resultList)) {
        return null;
    }
    return resultList.get(0);
}
Also used : Query(javax.persistence.Query) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 33 with FishingActivityEntity

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

the class ActivityDataUtil method getFishingActivityEntity.

public static FishingActivityEntity getFishingActivityEntity(String typeCode, String typeCodeListId, Date occurence, String reasonCode, String reasonCodeListId, FaReportDocumentEntity faReportDocumentEntity, FishingActivityEntity relatedfishingActivityEntity) {
    FishingActivityEntity fishingActivityEntity = new FishingActivityEntity();
    fishingActivityEntity.setTypeCode(typeCode);
    fishingActivityEntity.setTypeCodeListid(typeCodeListId);
    fishingActivityEntity.setOccurence(occurence);
    fishingActivityEntity.setReasonCode(reasonCode);
    fishingActivityEntity.setReasonCodeListId(reasonCodeListId);
    fishingActivityEntity.setFaReportDocument(faReportDocumentEntity);
    fishingActivityEntity.setRelatedFishingActivity(relatedfishingActivityEntity);
    return fishingActivityEntity;
}
Also used : FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 34 with FishingActivityEntity

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

the class MapperUtil method getFishingActivityEntityList.

public static List<FishingActivityEntity> getFishingActivityEntityList() {
    FishingTripEntity entity = new FishingTripEntity();
    FluxReportDocumentEntity fluxReportDocumentEntity1 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT1", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID1", "flux1");
    FluxReportDocumentEntity fluxReportDocumentEntity2 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT2", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID2", "flux2");
    FluxReportDocumentEntity fluxReportDocumentEntity3 = ActivityDataUtil.getFluxReportDocumentEntity("FLUX_REPORT_DOCUMENT3", null, DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "PURPOSE", "PURPOSE_CODE_LIST", null, "OWNER_FLUX_ID3", "flux3");
    VesselTransportMeansEntity vesselTransportMeansEntity1 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup1", null);
    VesselTransportMeansEntity vesselTransportMeansEntity2 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup2", null);
    VesselTransportMeansEntity vesselTransportMeansEntity3 = ActivityDataUtil.getVesselTransportMeansEntity("PAIR_FISHING_PARTNER", "FA_VESSEL_ROLE", "vesselGroup3", null);
    FaReportDocumentEntity faReportDocumentEntity1 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2016-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity1, vesselTransportMeansEntity1, "new");
    FaReportDocumentEntity faReportDocumentEntity2 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2015-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity2, vesselTransportMeansEntity2, "new");
    FaReportDocumentEntity faReportDocumentEntity3 = ActivityDataUtil.getFaReportDocumentEntity("Declaration", "FLUX_FA_REPORT_TYPE", DateUtils.parseToUTCDate("2015-06-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), fluxReportDocumentEntity3, vesselTransportMeansEntity3, "new");
    FishingActivityEntity fishingActivityEntity1 = ActivityDataUtil.getFishingActivityEntity("DEPARTURE", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity1, null);
    FishingActivityEntity fishingActivityEntity2 = ActivityDataUtil.getFishingActivityEntity("ARRIVAL", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity2, null);
    FishingActivityEntity fishingActivityEntity3 = ActivityDataUtil.getFishingActivityEntity("LANDING", "FLUX_FA_TYPE", DateUtils.parseToUTCDate("2014-05-27 07:47:31", "yyyy-MM-dd HH:mm:ss"), "FISHING", "FIS", faReportDocumentEntity3, null);
    List<FishingActivityEntity> fishingActivityEntityList = new ArrayList<>();
    fishingActivityEntityList.add(fishingActivityEntity1);
    fishingActivityEntityList.add(fishingActivityEntity2);
    fishingActivityEntityList.add(fishingActivityEntity3);
    return fishingActivityEntityList;
}
Also used : FishingTripEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripEntity) VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FluxReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity) ArrayList(java.util.ArrayList) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 35 with FishingActivityEntity

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

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