Search in sources :

Example 6 with VesselIdentifierEntity

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

the class ActivityEntityToModelMapper method mapIDs.

private void mapIDs(VesselTransportMeans vesselTransportMeans, Set<VesselIdentifierEntity> vesselIdentifiers) {
    if (CollectionUtils.isNotEmpty(vesselIdentifiers)) {
        List<IDType> idTypeList = new ArrayList<>();
        for (VesselIdentifierEntity vesselIdentifierEntity : vesselIdentifiers) {
            IDType idType = new IDType();
            idType.setValue(vesselIdentifierEntity.getVesselIdentifierId());
            idType.setSchemeID(vesselIdentifierEntity.getVesselIdentifierSchemeId());
            idTypeList.add(idType);
        }
        vesselTransportMeans.setIDS(idTypeList);
    }
}
Also used : VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) ArrayList(java.util.ArrayList) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType)

Example 7 with VesselIdentifierEntity

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

the class FishingActivityMapper method getVesselIdType.

protected Map<String, String> getVesselIdType(FishingActivityEntity entity) {
    if (entity == null || entity.getFaReportDocument() == null || entity.getFaReportDocument().getVesselTransportMeans() == null || CollectionUtils.isEmpty(entity.getFaReportDocument().getVesselTransportMeans()) || CollectionUtils.isEmpty(entity.getFaReportDocument().getVesselTransportMeans().iterator().next().getVesselIdentifiers())) {
        return Collections.emptyMap();
    }
    Map<String, String> vesselTransportIdList = new HashMap<>();
    /*
            We can assume that FaReportDocument will always have only one VesselTransportMeans.One to many relation is artificially created
         */
    Set<VesselIdentifierEntity> identifierList = entity.getFaReportDocument().getVesselTransportMeans().iterator().next().getVesselIdentifiers();
    for (VesselIdentifierEntity identity : identifierList) {
        vesselTransportIdList.put(identity.getVesselIdentifierSchemeId(), identity.getVesselIdentifierId());
    }
    return vesselTransportIdList;
}
Also used : VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) HashMap(java.util.HashMap)

Example 8 with VesselIdentifierEntity

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

the class FishingActivityMapper method getVesselIdentifierTypeList.

protected List<VesselIdentifierType> getVesselIdentifierTypeList(FishingActivityEntity entity) {
    if (entity == null || entity.getFaReportDocument() == null || entity.getFaReportDocument().getVesselTransportMeans() == null || CollectionUtils.isEmpty(entity.getFaReportDocument().getVesselTransportMeans()) || CollectionUtils.isEmpty(entity.getFaReportDocument().getVesselTransportMeans().iterator().next().getVesselIdentifiers())) {
        return Collections.emptyList();
    }
    List<VesselIdentifierType> identifiers = new ArrayList<>();
    Set<VesselIdentifierEntity> identifierList = entity.getFaReportDocument().getVesselTransportMeans().iterator().next().getVesselIdentifiers();
    for (VesselIdentifierEntity identity : identifierList) {
        identifiers.add(new VesselIdentifierType(VesselIdentifierSchemeIdEnum.valueOf(identity.getVesselIdentifierSchemeId()), identity.getVesselIdentifierId()));
    }
    return identifiers;
}
Also used : VesselIdentifierType(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierType) VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) ArrayList(java.util.ArrayList)

Example 9 with VesselIdentifierEntity

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

the class VesselTransportMeansMapper method mapToVesselIdentifierEntities.

protected Set<VesselIdentifierEntity> mapToVesselIdentifierEntities(List<IDType> idTypes, VesselTransportMeansEntity vesselTransportMeansEntity) {
    if (idTypes == null || idTypes.isEmpty()) {
        return Collections.emptySet();
    }
    Set<VesselIdentifierEntity> vesselIdentifierEntities = new HashSet<>();
    for (IDType idType : idTypes) {
        VesselIdentifierEntity vesselIdentifierEntity = VesselTransportMeansMapper.INSTANCE.mapToVesselIdentifierEntity(idType);
        vesselIdentifierEntity.setVesselTransportMeans(vesselTransportMeansEntity);
        vesselIdentifierEntities.add(vesselIdentifierEntity);
    }
    return vesselIdentifierEntities;
}
Also used : VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType) HashSet(java.util.HashSet)

Example 10 with VesselIdentifierEntity

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

the class FishingTripServiceBean method getNextTrips.

private Set<String> getNextTrips(String tripId, Integer limit, List<VesselIdentifierEntity> vesselIdentifiers) {
    Set<String> tripIds = new LinkedHashSet<>();
    if (vesselIdentifiers != null && !vesselIdentifiers.isEmpty()) {
        for (VesselIdentifierEntity vesselIdentifier : vesselIdentifiers) {
            // FIXME
            List<FishingTripIdentifierEntity> identifierEntities = fishingTripIdentifierDao.getNextTrips(vesselIdentifier.getVesselIdentifierId(), vesselIdentifier.getVesselIdentifierSchemeId(), tripId, limit);
            for (FishingTripIdentifierEntity identifiers : identifierEntities) {
                tripIds.add(identifiers.getTripId());
            }
        }
    }
    log.debug("Next Trips : " + tripIds);
    return tripIds;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)

Aggregations

VesselIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity)15 ArrayList (java.util.ArrayList)5 FishingTripIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity)3 Test (org.junit.Test)3 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)2 BaseUnitilsTest (eu.europa.ec.fisheries.uvms.BaseUnitilsTest)2 VesselIdentifierType (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierType)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 IDType (un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType)2 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)1 VesselTypeAssetQueryEnum (eu.europa.ec.fisheries.ers.fa.utils.VesselTypeAssetQueryEnum)1 AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)1 CronologyTripDTO (eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO)1 BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 VesselTransportMeans (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.VesselTransportMeans)1