Search in sources :

Example 1 with VesselIdentifierEntity

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

the class FishingTripServiceBean method getCronologyOfFishingTrip.

/**
 * {@inheritDoc}
 */
@Override
public CronologyTripDTO getCronologyOfFishingTrip(String tripId, Integer count) throws ServiceException {
    // Find the latest Vessel for the Trip for finding the trip of that vessel
    List<VesselIdentifierEntity> latestVesselIdentifiers = vesselIdentifierDao.getLatestVesselIdByTrip(tripId);
    CronologyTripDTO cronologyTripDTO = new CronologyTripDTO();
    cronologyTripDTO.setCurrentTrip(getCurrentTrip(latestVesselIdentifiers));
    cronologyTripDTO.setSelectedTrip(tripId);
    List<String> previousTrips = new ArrayList<>(getPreviousTrips(tripId, count, latestVesselIdentifiers));
    List<String> nextTrips = new ArrayList<>(getNextTrips(tripId, count, latestVesselIdentifiers));
    Map<String, Integer> countMap = calculateTripCounts(count, previousTrips.size(), nextTrips.size());
    log.info("Number of previous record to find : " + countMap.get(PREVIOUS));
    log.info("Number of next record to find : " + countMap.get(NEXT));
    cronologyTripDTO.setPreviousTrips(previousTrips.subList(previousTrips.size() - countMap.get(PREVIOUS), previousTrips.size()));
    cronologyTripDTO.setNextTrips(nextTrips.subList(0, countMap.get(NEXT)));
    return cronologyTripDTO;
}
Also used : BigInteger(java.math.BigInteger) VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) ArrayList(java.util.ArrayList) CronologyTripDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO)

Example 2 with VesselIdentifierEntity

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

the class FishingTripServiceBean method getPreviousTrips.

private Set<String> getPreviousTrips(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.getPreviousTrips(vesselIdentifier.getVesselIdentifierId(), vesselIdentifier.getVesselIdentifierSchemeId(), tripId, limit);
            for (FishingTripIdentifierEntity identifiers : identifierEntities) {
                tripIds.add(identifiers.getTripId());
            }
        }
    }
    log.debug("Previous 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)

Example 3 with VesselIdentifierEntity

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

the class VesselIdentifierMapperTest method testMapToIdentifierDtoSet.

@Test
public void testMapToIdentifierDtoSet() {
    VesselIdentifierEntity entity = builder().vesselIdentifierSchemeId("CFR").vesselIdentifierId("schemeId").build();
    Set<AssetIdentifierDto> identifierDtos = INSTANCE.mapToIdentifierDotSet(asSet(entity));
    assertEquals(1, identifierDtos.size());
    assertEquals("schemeId", identifierDtos.iterator().next().getFaIdentifierId());
    assertEquals(VesselIdentifierSchemeIdEnum.CFR, identifierDtos.iterator().next().getIdentifierSchemeId());
}
Also used : AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) BaseUnitilsTest(eu.europa.ec.fisheries.uvms.BaseUnitilsTest) Test(org.junit.Test)

Example 4 with VesselIdentifierEntity

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

the class FishingTripIdWithGeometryMapper method getVesselIdListsForFishingActivity.

protected List<VesselIdentifierType> getVesselIdListsForFishingActivity(List<FishingActivityEntity> fishingActivities) {
    if (CollectionUtils.isEmpty(fishingActivities) || fishingActivities.get(fishingActivities.size() - 1) == null || fishingActivities.get(fishingActivities.size() - 1).getFaReportDocument() == null || fishingActivities.get(fishingActivities.size() - 1).getFaReportDocument().getVesselTransportMeans() == null) {
        return Collections.emptyList();
    }
    int totalFishingActivityCount = fishingActivities.size();
    FishingActivityEntity fishingActivityEntity = fishingActivities.get(totalFishingActivityCount - 1);
    Set<VesselTransportMeansEntity> vesselTransportMeansEntityList = fishingActivityEntity.getFaReportDocument().getVesselTransportMeans();
    if (CollectionUtils.isEmpty(vesselTransportMeansEntityList) || CollectionUtils.isEmpty(vesselTransportMeansEntityList.iterator().next().getVesselIdentifiers())) {
        return Collections.emptyList();
    }
    Set<VesselIdentifierEntity> vesselIdentifierEntities = vesselTransportMeansEntityList.iterator().next().getVesselIdentifiers();
    List<VesselIdentifierType> vesselIdentifierTypes = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(vesselIdentifierEntities)) {
        for (VesselIdentifierEntity vesselIdentifierEntity : vesselIdentifierEntities) {
            VesselIdentifierType vesselIdentifierType = new VesselIdentifierType();
            vesselIdentifierType.setKey(VesselIdentifierSchemeIdEnum.valueOf(vesselIdentifierEntity.getVesselIdentifierSchemeId()));
            vesselIdentifierType.setValue(vesselIdentifierEntity.getVesselIdentifierId());
            vesselIdentifierTypes.add(vesselIdentifierType);
        }
    }
    return vesselIdentifierTypes;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) VesselIdentifierType(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierType) VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity) ArrayList(java.util.ArrayList) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 5 with VesselIdentifierEntity

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

the class AssetModuleServiceBean method createAssetListQuery.

private AssetListQuery createAssetListQuery(Collection<VesselIdentifierEntity> vesselIdentifiers) {
    AssetListQuery assetListQuery = new AssetListQuery();
    // Set asset list criteria
    AssetListCriteria assetListCriteria = new AssetListCriteria();
    for (VesselIdentifierEntity identifier : vesselIdentifiers) {
        VesselTypeAssetQueryEnum queryEnum = VesselTypeAssetQueryEnum.getVesselTypeAssetQueryEnum(identifier.getVesselIdentifierSchemeId());
        if (queryEnum != null && queryEnum.getConfigSearchField() != null && StringUtils.isNotEmpty(identifier.getVesselIdentifierId())) {
            AssetListCriteriaPair criteriaPair = new AssetListCriteriaPair();
            criteriaPair.setKey(queryEnum.getConfigSearchField());
            criteriaPair.setValue(identifier.getVesselIdentifierId());
            assetListCriteria.getCriterias().add(criteriaPair);
        } else {
            log.warn("For Identifier : '" + identifier.getVesselIdentifierSchemeId() + "' it was not found the counterpart in the VesselTypeAssetQueryEnum.");
        }
    }
    // DO not know why
    assetListCriteria.setIsDynamic(false);
    assetListQuery.setAssetSearchCriteria(assetListCriteria);
    // Set asset pagination
    AssetListPagination pagination = new AssetListPagination();
    pagination.setPage(1);
    pagination.setListSize(1000);
    assetListQuery.setPagination(pagination);
    return assetListQuery;
}
Also used : VesselTypeAssetQueryEnum(eu.europa.ec.fisheries.ers.fa.utils.VesselTypeAssetQueryEnum) VesselIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity)

Aggregations

VesselIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity)14 ArrayList (java.util.ArrayList)4 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 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 VesselIdentifierType (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierType)1 BigInteger (java.math.BigInteger)1 HashMap (java.util.HashMap)1 VesselTransportMeans (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.VesselTransportMeans)1