Search in sources :

Example 1 with AssetIdentifierDto

use of eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto 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 2 with AssetIdentifierDto

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

the class BaseMapperTest method testMapToAssetListCriteriaPairList.

@Test
public void testMapToAssetListCriteriaPairList() {
    AssetIdentifierDto cfr = new AssetIdentifierDto(CFR);
    cfr.setFaIdentifierId("cfrValue");
    AssetIdentifierDto gfmc = new AssetIdentifierDto(GFCM);
    AssetIdentifierDto ext = new AssetIdentifierDto(EXT_MARK);
    ext.setFaIdentifierId("extValue");
    AssetIdentifierDto ircs = new AssetIdentifierDto(IRCS);
    ircs.setFaIdentifierId("ircsValue");
    AssetIdentifierDto uvi = new AssetIdentifierDto(UVI);
    Set<AssetIdentifierDto> identifierDtos = newSet(cfr, gfmc, ext, ircs, uvi);
    List<AssetListCriteriaPair> pairs = BaseMapper.mapToAssetListCriteriaPairList(identifierDtos);
    ImmutableMap<ConfigSearchField, AssetListCriteriaPair> map = Maps.uniqueIndex(pairs, new Function<AssetListCriteriaPair, ConfigSearchField>() {

        public ConfigSearchField apply(AssetListCriteriaPair from) {
            return from.getKey();
        }
    });
    assertEquals(3, map.size());
    AssetListCriteriaPair cfrPair = map.get(ConfigSearchField.CFR);
    assertEquals(ConfigSearchField.CFR, cfrPair.getKey());
    assertEquals("cfrValue", cfrPair.getValue());
    AssetListCriteriaPair extPair = map.get(ConfigSearchField.EXTERNAL_MARKING);
    assertEquals(ConfigSearchField.EXTERNAL_MARKING, extPair.getKey());
    assertEquals("extValue", extPair.getValue());
    AssetListCriteriaPair ircsPair = map.get(ConfigSearchField.IRCS);
    assertEquals(ConfigSearchField.IRCS, ircsPair.getKey());
    assertEquals("ircsValue", ircsPair.getValue());
}
Also used : ConfigSearchField(eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField) AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) BaseUnitilsTest(eu.europa.ec.fisheries.uvms.BaseUnitilsTest) Test(org.junit.Test)

Example 3 with AssetIdentifierDto

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

the class FishingTripServiceBean method getMdrCodesEnrichWithAssetsModuleDataIfNeeded.

// To process MDR code list and compare with  database:vesselTransportMeansDao and then enrich with asset module
private void getMdrCodesEnrichWithAssetsModuleDataIfNeeded(VesselDetailsDTO vesselDetailsDTO) {
    final String ACRONYM = "FLUX_VESSEL_ID_TYPE";
    final String filter = "*";
    final List<String> columnsList = new ArrayList<String>();
    Integer nrOfResults = 9999999;
    if (vesselDetailsDTO != null) {
        List<String> codeList = null;
        try {
            codeList = mdrModuleService.getAcronymFromMdr(ACRONYM, filter, columnsList, nrOfResults, "code").get("code");
            Set<AssetIdentifierDto> vesselIdentifiers = vesselDetailsDTO.getVesselIdentifiers();
            List<AssetListCriteriaPair> assetListCriteriaPairs = BaseMapper.mapMdrCodeListToAssetListCriteriaPairList(vesselIdentifiers, codeList);
            log.info("Asset Criteria Pair List size is :" + assetListCriteriaPairs.size());
            log.info("Got code list of size from mdr:" + codeList.size());
            if (null != assetListCriteriaPairs && !CollectionUtils.isEmpty(assetListCriteriaPairs)) {
                AssetListCriteria criteria = new AssetListCriteria();
                // need to set this
                criteria.setIsDynamic(false);
                criteria.getCriterias().addAll(assetListCriteriaPairs);
                AssetListQuery query = new AssetListQuery();
                AssetListPagination assetListPagination = new AssetListPagination();
                // need to set this
                assetListPagination.setPage(1);
                // need to set this
                assetListPagination.setListSize(1000);
                query.setPagination(assetListPagination);
                query.setAssetSearchCriteria(criteria);
                List<Asset> assetList = assetModuleService.getAssetListResponse(query);
                if (null != assetList && !CollectionUtils.isEmpty(assetList)) {
                    vesselDetailsDTO.enrichIdentifiers(assetList.get(0));
                }
            }
        } catch (ServiceException e) {
            log.error("Error while trying to send message to Assets module.", e);
        }
    }
}
Also used : AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) ArrayList(java.util.ArrayList) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) AssetListPagination(eu.europa.ec.fisheries.wsdl.asset.types.AssetListPagination) BigInteger(java.math.BigInteger) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) AssetListCriteria(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteria)

Example 4 with AssetIdentifierDto

use of eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto 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 5 with AssetIdentifierDto

use of eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto 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)

Aggregations

AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)10 AssetListCriteriaPair (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair)6 VesselIdentifierSchemeIdEnum (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)5 ArrayList (java.util.ArrayList)5 BaseUnitilsTest (eu.europa.ec.fisheries.uvms.BaseUnitilsTest)4 ConfigSearchField (eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField)4 Test (org.junit.Test)4 Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)3 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 AssetListCriteria (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteria)2 AssetListQuery (eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery)2 VesselIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselIdentifierEntity)1 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)1 VesselDetailsDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO)1 AssetListPagination (eu.europa.ec.fisheries.wsdl.asset.types.AssetListPagination)1 BigInteger (java.math.BigInteger)1 ToString (lombok.ToString)1