Search in sources :

Example 1 with VesselIdentifierSchemeIdEnum

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum in project UVMS-ActivityModule-APP by UnionVMS.

the class VesselDetailsDTO method enrichIdentifiers.

public void enrichIdentifiers(Asset asset) {
    if (asset != null) {
        String ircs = asset.getIrcs();
        String cfr = asset.getCfr();
        String externalMarking = asset.getExternalMarking();
        for (AssetIdentifierDto identifier : vesselIdentifiers) {
            if (isEmpty(identifier.getFaIdentifierId())) {
                VesselIdentifierSchemeIdEnum identifierSchemeId = identifier.getIdentifierSchemeId();
                if (CFR.equals(identifierSchemeId) && !isEmpty(cfr)) {
                    setIdentifier(identifier, cfr);
                } else if (EXT_MARK.equals(identifierSchemeId) && !isEmpty(externalMarking)) {
                    setIdentifier(identifier, externalMarking);
                } else if (IRCS.equals(identifierSchemeId) && !isEmpty(ircs)) {
                    setIdentifier(identifier, ircs);
                }
            }
        }
    }
}
Also used : AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) VesselIdentifierSchemeIdEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum) ToString(lombok.ToString)

Example 2 with VesselIdentifierSchemeIdEnum

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum in project UVMS-ActivityModule-APP by UnionVMS.

the class FaCatchMapper method mapToAssetIdentifiers.

protected List<AssetIdentifierDto> mapToAssetIdentifiers(FaCatchEntity faCatch) {
    List<AssetIdentifierDto> assetIdentifierDtos = new ArrayList<>();
    if (faCatch != null && faCatch.getFishingActivity() != null && CollectionUtils.isNotEmpty(faCatch.getFishingActivity().getVesselTransportMeans())) {
        VesselTransportMeansEntity vesselTransportMeans = faCatch.getFishingActivity().getVesselTransportMeans().iterator().next();
        Map<VesselIdentifierSchemeIdEnum, String> vesselIdentifiers = vesselTransportMeans.getVesselIdentifiersMap();
        // Set IRCS always if present
        if (vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.IRCS) != null) {
            assetIdentifierDtos.add(new AssetIdentifierDto(VesselIdentifierSchemeIdEnum.IRCS, vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.IRCS)));
        }
        if (vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.ICCAT) != null) {
            assetIdentifierDtos.add(new AssetIdentifierDto(VesselIdentifierSchemeIdEnum.ICCAT, vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.ICCAT)));
        } else if (vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.CFR) != null) {
            assetIdentifierDtos.add(new AssetIdentifierDto(VesselIdentifierSchemeIdEnum.CFR, vesselIdentifiers.get(VesselIdentifierSchemeIdEnum.CFR)));
        }
    }
    return assetIdentifierDtos;
}
Also used : AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) VesselTransportMeansEntity(eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity) ArrayList(java.util.ArrayList) VesselIdentifierSchemeIdEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)

Example 3 with VesselIdentifierSchemeIdEnum

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum in project UVMS-ActivityModule-APP by UnionVMS.

the class BaseMapper method mapMdrCodeListToAssetListCriteriaPairList.

public static List<AssetListCriteriaPair> mapMdrCodeListToAssetListCriteriaPairList(Set<AssetIdentifierDto> identifierDtoSet, List<String> vesselIdentifierSchemeList) {
    List<AssetListCriteriaPair> criteriaList = new ArrayList<>();
    if (CollectionUtils.isNotEmpty(identifierDtoSet)) {
        for (AssetIdentifierDto identifierDto : identifierDtoSet) {
            VesselIdentifierSchemeIdEnum identifierSchemeId = identifierDto.getIdentifierSchemeId();
            ConfigSearchField keyFromDto = VesselIdentifierMapper.INSTANCE.map(identifierSchemeId);
            if (null != identifierSchemeId && null != keyFromDto && vesselIdentifierSchemeList.contains(keyFromDto.name())) {
                String identifierId = identifierDto.getFaIdentifierId();
                AssetListCriteriaPair criteriaPair = new AssetListCriteriaPair();
                criteriaPair.setKey(ConfigSearchField.fromValue(identifierSchemeId.name()));
                criteriaPair.setValue(identifierId);
                criteriaList.add(criteriaPair);
            }
        }
    }
    return criteriaList;
}
Also used : ConfigSearchField(eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField) AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) ArrayList(java.util.ArrayList) VesselIdentifierSchemeIdEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)

Example 4 with VesselIdentifierSchemeIdEnum

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum in project UVMS-ActivityModule-APP by UnionVMS.

the class VesselDetailsDTOTest method testEnrichIdentifiers.

@Test
public void testEnrichIdentifiers() throws Exception {
    Asset asset = new Asset();
    asset.setCfr("cfrValueFromAsset");
    AssetIdentifierDto cfr = new AssetIdentifierDto(CFR);
    AssetIdentifierDto ext = new AssetIdentifierDto(EXT_MARK);
    ext.setFaIdentifierId("extMarkingFromActivity");
    AssetIdentifierDto ircs = new AssetIdentifierDto(IRCS);
    ircs.setFaIdentifierId("ircsFromActivity");
    AssetIdentifierDto iccat = new AssetIdentifierDto(ICCAT);
    iccat.setFaIdentifierId("iccat");
    AssetIdentifierDto uvi = new AssetIdentifierDto(UVI);
    Set<AssetIdentifierDto> identifiers = newSet(ircs, cfr, iccat, uvi, ext);
    VesselDetailsDTO dto = builder().vesselIdentifiers(identifiers).build();
    dto.enrichIdentifiers(asset);
    Set<AssetIdentifierDto> vesselIdentifiers = dto.getVesselIdentifiers();
    ImmutableMap<VesselIdentifierSchemeIdEnum, AssetIdentifierDto> map = Maps.uniqueIndex(vesselIdentifiers, new Function<AssetIdentifierDto, VesselIdentifierSchemeIdEnum>() {

        public VesselIdentifierSchemeIdEnum apply(AssetIdentifierDto from) {
            return from.getIdentifierSchemeId();
        }
    });
    AssetIdentifierDto cfr_ = map.get(CFR);
    AssetIdentifierDto ext_ = map.get(EXT_MARK);
    AssetIdentifierDto ircs_ = map.get(IRCS);
    AssetIdentifierDto uvi_ = map.get(UVI);
    AssetIdentifierDto iccat_ = map.get(ICCAT);
    assertTrue(uvi.equals(uvi_));
    assertTrue(ircs.equals(ircs_));
    assertTrue(iccat.equals(iccat_));
}
Also used : AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) VesselDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO) VesselIdentifierSchemeIdEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) BaseUnitilsTest(eu.europa.ec.fisheries.uvms.BaseUnitilsTest) Test(org.junit.Test)

Example 5 with VesselIdentifierSchemeIdEnum

use of eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum in project UVMS-ActivityModule-APP by UnionVMS.

the class BaseMapper method mapToAssetListCriteriaPairList.

public static List<AssetListCriteriaPair> mapToAssetListCriteriaPairList(Set<AssetIdentifierDto> identifierDtoSet) {
    List<AssetListCriteriaPair> criteriaList = new ArrayList<>();
    for (AssetIdentifierDto identifierDto : identifierDtoSet) {
        AssetListCriteriaPair criteriaPair = new AssetListCriteriaPair();
        VesselIdentifierSchemeIdEnum identifierSchemeId = identifierDto.getIdentifierSchemeId();
        ConfigSearchField key = VesselIdentifierMapper.INSTANCE.map(identifierSchemeId);
        String identifierId = identifierDto.getFaIdentifierId();
        if (key != null && identifierId != null) {
            criteriaPair.setKey(key);
            criteriaPair.setValue(identifierId);
            criteriaList.add(criteriaPair);
        }
    }
    return criteriaList;
}
Also used : ConfigSearchField(eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField) AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) ArrayList(java.util.ArrayList) VesselIdentifierSchemeIdEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)

Aggregations

AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)5 VesselIdentifierSchemeIdEnum (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)5 ArrayList (java.util.ArrayList)3 AssetListCriteriaPair (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair)2 ConfigSearchField (eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField)2 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)1 VesselDetailsDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO)1 BaseUnitilsTest (eu.europa.ec.fisheries.uvms.BaseUnitilsTest)1 Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)1 ToString (lombok.ToString)1 Test (org.junit.Test)1