Search in sources :

Example 1 with AssetListCriteriaPair

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

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

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

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

the class AssetJMSIT method testGetAssetListByQuery.

@Test
public void testGetAssetListByQuery() throws Exception {
    Asset asset = AssetTestHelper.createTestAsset();
    AssetListQuery assetListQuery = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair = new AssetListCriteriaPair();
    assetListCriteriaPair.setKey(ConfigSearchField.FLAG_STATE);
    assetListCriteriaPair.setValue(asset.getCountryCode());
    assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair);
    List<Asset> assets = AssetJMSHelper.getAssetByAssetListQuery(assetListQuery);
    setDecimalScaleAndNullNotes(assets);
    assertTrue(assets.contains(asset));
}
Also used : AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) Test(org.junit.Test)

Example 5 with AssetListCriteriaPair

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

the class AssetRestIT method getAssetListWithLikeSearchValue_ICCAT_AND_UVI_GFCM.

@Test
public void getAssetListWithLikeSearchValue_ICCAT_AND_UVI_GFCM() throws Exception {
    Asset asset = AssetTestHelper.createDummyAsset(AssetIdType.GUID);
    String theValue = UUID.randomUUID().toString();
    asset.setIccat(theValue);
    asset.setUvi(theValue);
    asset.setGfcm(theValue);
    asset = AssetTestHelper.createAsset(asset);
    AssetListQuery assetListQuery = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair_ICCAT = new AssetListCriteriaPair();
    AssetListCriteriaPair assetListCriteriaPair_UVI = new AssetListCriteriaPair();
    AssetListCriteriaPair assetListCriteriaPair_GFCM = new AssetListCriteriaPair();
    assetListCriteriaPair_ICCAT.setKey(ConfigSearchField.ICCAT);
    assetListCriteriaPair_ICCAT.setValue(theValue);
    assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair_ICCAT);
    assetListCriteriaPair_UVI.setKey(ConfigSearchField.UVI);
    assetListCriteriaPair_UVI.setValue(theValue);
    assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair_UVI);
    assetListCriteriaPair_GFCM.setKey(ConfigSearchField.GFCM);
    assetListCriteriaPair_GFCM.setValue(theValue);
    assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair_GFCM);
    ListAssetResponse assetList = AssetTestHelper.assetListQuery(assetListQuery);
    List<Asset> assets = assetList.getAsset();
    assertTrue(assets.contains(asset));
}
Also used : AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) ListAssetResponse(eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

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