Search in sources :

Example 1 with ConfigSearchField

use of eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField 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 2 with ConfigSearchField

use of eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField 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 3 with ConfigSearchField

use of eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField 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)

Example 4 with ConfigSearchField

use of eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField in project UVMS-ActivityModule-APP by UnionVMS.

the class BaseMapperTest method testmapMdrCodeListToAssetListCriteriaPairList.

@Test
public void testmapMdrCodeListToAssetListCriteriaPairList() {
    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<String> mdrCodeList = new ArrayList<String>();
    mdrCodeList.add("CFR");
    mdrCodeList.add("IRCS");
    mdrCodeList.add("EXT_MARK");
    mdrCodeList.add("UVI");
    mdrCodeList.add("ICCAT");
    mdrCodeList.add("GFCM");
    List<AssetListCriteriaPair> pairs = BaseMapper.mapMdrCodeListToAssetListCriteriaPairList(identifierDtos, mdrCodeList);
    ImmutableMap<ConfigSearchField, AssetListCriteriaPair> map = Maps.uniqueIndex(pairs, new Function<AssetListCriteriaPair, ConfigSearchField>() {

        public ConfigSearchField apply(AssetListCriteriaPair from) {
            return from.getKey();
        }
    });
    assertEquals(2, map.size());
    AssetListCriteriaPair cfrPair = map.get(ConfigSearchField.CFR);
    assertEquals(ConfigSearchField.CFR, cfrPair.getKey());
    assertEquals("cfrValue", cfrPair.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) ArrayList(java.util.ArrayList) BaseUnitilsTest(eu.europa.ec.fisheries.uvms.BaseUnitilsTest) Test(org.junit.Test)

Aggregations

AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)4 AssetListCriteriaPair (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair)4 ConfigSearchField (eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField)4 ArrayList (java.util.ArrayList)3 BaseUnitilsTest (eu.europa.ec.fisheries.uvms.BaseUnitilsTest)2 VesselIdentifierSchemeIdEnum (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)2 Test (org.junit.Test)2