Search in sources :

Example 16 with AssetListCriteriaPair

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

the class FishingTripServiceBean method enrichWithAssetsModuleDataIfNeeded.

// need confirmation for removal of this method
private void enrichWithAssetsModuleDataIfNeeded(VesselDetailsDTO vesselDetailsDTO) {
    if (vesselDetailsDTO != null && vesselDetailsDTO.hasEmptyIdentifierValues()) {
        try {
            Set<AssetIdentifierDto> vesselIdentifiers = vesselDetailsDTO.getVesselIdentifiers();
            List<AssetListCriteriaPair> assetListCriteriaPairs = BaseMapper.mapToAssetListCriteriaPairList(vesselIdentifiers);
            AssetListCriteria criteria = new AssetListCriteria();
            criteria.getCriterias().addAll(assetListCriteriaPairs);
            AssetListQuery query = new AssetListQuery();
            query.setAssetSearchCriteria(criteria);
            List<Asset> assetList = assetModuleService.getAssetListResponse(query);
            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) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) AssetListCriteria(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteria)

Example 17 with AssetListCriteriaPair

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

AssetListCriteriaPair (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair)17 AssetListQuery (eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery)13 Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)12 Test (org.junit.Test)12 AbstractRestServiceTest (eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)9 ListAssetResponse (eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse)8 AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)6 ConfigSearchField (eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField)4 ArrayList (java.util.ArrayList)4 BaseUnitilsTest (eu.europa.ec.fisheries.uvms.BaseUnitilsTest)2 VesselIdentifierSchemeIdEnum (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 AssetListCriteria (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteria)2 AssetListPagination (eu.europa.ec.fisheries.wsdl.asset.types.AssetListPagination)1 BigInteger (java.math.BigInteger)1 HttpResponse (org.apache.http.HttpResponse)1