Search in sources :

Example 6 with VesselDetailsDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO 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;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) ArrayList(java.util.ArrayList) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 7 with VesselDetailsDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityRelocationViewMapper method mapFaEntityToFaDto.

@Override
public FishingActivityViewDTO mapFaEntityToFaDto(FishingActivityEntity faEntity) {
    FishingActivityViewDTO viewDTO = new FishingActivityViewDTO();
    if (faEntity != null) {
        viewDTO.setActivityDetails(mapActivityDetails(faEntity));
        viewDTO.setLocations(mapFromFluxLocation(faEntity.getFluxLocations()));
        viewDTO.setReportDetails(getReportDocsFromEntity(faEntity.getFaReportDocument()));
        viewDTO.setCatches(mapCatchesToGroupDto(faEntity));
        viewDTO.setProcessingProducts(getProcessingProductsByFaCatches(faEntity.getFaCatchs()));
        viewDTO.setVesselDetails(VesselTransportMeansMapper.INSTANCE.map(faEntity.getVesselTransportMeans()));
        if (CollectionUtils.isNotEmpty(viewDTO.getVesselDetails())) {
            for (VesselDetailsDTO detailsDTO : viewDTO.getVesselDetails()) {
                detailsDTO.setStorageDto(VesselStorageCharacteristicsMapper.INSTANCE.mapToStorageDto(faEntity.getDestVesselCharId()));
            }
        }
    }
    return viewDTO;
}
Also used : VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) FishingActivityViewDTO(eu.europa.ec.fisheries.ers.service.dto.view.parent.FishingActivityViewDTO)

Example 8 with VesselDetailsDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityTranshipmentViewMapper 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 || CollectionUtils.isEmpty(faEntity.getVesselTransportMeans()))
        return null;
    List<VesselDetailsDTO> vesselDetailsDTOs = new ArrayList<>();
    Set<VesselTransportMeansEntity> entities = faEntity.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;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) ArrayList(java.util.ArrayList)

Example 9 with VesselDetailsDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripServiceBean method getVesselDetailsForFishingTrip.

@Override
public VesselDetailsDTO getVesselDetailsForFishingTrip(final String fishingTripId) throws ServiceException {
    if (fishingTripId == null) {
        throw new IllegalArgumentException("PARAMETER CANNOT BE NULL");
    }
    VesselDetailsDTO detailsDTO = null;
    try {
        VesselTransportMeansEntity latestVesselByTripId = vesselTransportMeansDao.findLatestVesselByTripId(fishingTripId);
        if (latestVesselByTripId != null) {
            FishingActivityEntity parent = latestVesselByTripId.getFishingActivity();
            detailsDTO = getVesselDetailsDTO(latestVesselByTripId, parent);
        }
    } catch (ServiceException e) {
        throw new ServiceException(e.getMessage(), e);
    }
    return detailsDTO;
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) FishingActivityEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)

Example 10 with VesselDetailsDTO

use of eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityServiceBeanTest method testEnrichVesselDetailsAndContactPartiesForFishingTrip.

@Test
@SneakyThrows
public void testEnrichVesselDetailsAndContactPartiesForFishingTrip() {
    Map<String, List<String>> returnMap = new HashMap<>();
    returnMap.put("code", new ArrayList<String>());
    when(vesselTransportMeansDao.findLatestVesselByTripId(Mockito.anyString())).thenReturn(new VesselTransportMeansEntity());
    when(mdrModuleServiceBean.getAcronymFromMdr("FLUX_VESSEL_ID_TYPE", "*", new ArrayList<String>(), 9999999, "code")).thenReturn(returnMap);
    List<Asset> listAssetResponse = new ArrayList<>();
    Asset asset = new Asset();
    asset.setCfr("UPDATED_CFR");
    asset.setIrcs("UPDATED_IRCS");
    asset.setImo("UPDATED_IMO");
    asset.setName("name");
    listAssetResponse.add(asset);
    when(assetModule.getAssetListResponse(Mockito.any(AssetListQuery.class))).thenReturn(listAssetResponse);
    VesselDetailsDTO vesselDetailsDTO = fishingTripService.getVesselDetailsForFishingTrip("NOR-TRP-20160517234053706");
    assertNotNull(vesselDetailsDTO);
}
Also used : VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

VesselDetailsDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO)10 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)4 HashMap (java.util.HashMap)3 List (java.util.List)3 SneakyThrows (lombok.SneakyThrows)3 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)2 Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)2 VesselStorageCharacteristicsEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselStorageCharacteristicsEntity)1 AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)1 FishingActivityViewDTO (eu.europa.ec.fisheries.ers.service.dto.view.parent.FishingActivityViewDTO)1 BaseUnitilsTest (eu.europa.ec.fisheries.uvms.BaseUnitilsTest)1 VesselIdentifierSchemeIdEnum (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)1 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)1 AssetListQuery (eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery)1 Nullable (org.jetbrains.annotations.Nullable)1