Search in sources :

Example 1 with Asset

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

the class ExchangeEventOutgoingServiceBean method getSetUnsentMessageTypePropertiesForPoll.

private List<UnsentMessageTypeProperty> getSetUnsentMessageTypePropertiesForPoll(CommandType commandType) throws ExchangeLogException {
    List<UnsentMessageTypeProperty> properties = new ArrayList<>();
    if (commandType.getPoll() != null) {
        String connectId = ExchangeLogMapper.getConnectId(commandType.getPoll());
        Asset asset = getAsset(connectId);
        properties = ExchangeLogMapper.getPropertiesForPoll(commandType.getPoll(), asset.getName());
    } else if (commandType.getEmail() != null) {
        properties = ExchangeLogMapper.getPropertiesForEmail(commandType.getEmail());
    }
    return properties;
}
Also used : ArrayList(java.util.ArrayList) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) UnsentMessageTypeProperty(eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageTypeProperty)

Example 2 with Asset

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

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

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

the class FluxMessageReceiverBeanIT method postRequestTypeRequestSuccessTest.

/**
 * Post request type request success test.
 *
 * @throws Exception the exception
 */
@Test
@Ignore
public void postRequestTypeRequestSuccessTest() throws Exception {
    Asset testAsset = AssetTestHelper.createTestAsset();
    MobileTerminalType mobileTerminalType = MobileTerminalTestHelper.createMobileTerminalType();
    MobileTerminalTestHelper.assignMobileTerminal(testAsset, mobileTerminalType);
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(new Date());
    BridgeConnectorPortType bridgeConnectorPortType = createBridgeConnector();
    RequestType requestType = new RequestType();
    FLUXVesselPositionMessage fLUXVesselPositionMessage = new FLUXVesselPositionMessage();
    VesselTransportMeansType vesselTransportMeansType = new VesselTransportMeansType();
    IDType cfrId = new IDType();
    cfrId.setSchemeID("CFR");
    cfrId.setValue(testAsset.getCfr());
    vesselTransportMeansType.getIDS().add(cfrId);
    IDType ircsId = new IDType();
    ircsId.setSchemeID("IRCS");
    ircsId.setValue(testAsset.getIrcs());
    vesselTransportMeansType.getIDS().add(ircsId);
    // IDType extMarkingId = new IDType();
    // extMarkingId.setSchemeID("EXT_MARKING");
    // extMarkingId.setValue(testAsset.getExternalMarking());
    // vesselTransportMeansType.getIDS().add(extMarkingId);
    VesselCountryType vesselCountry = new VesselCountryType();
    IDType countryId = new IDType();
    countryId.setValue("SWE");
    vesselCountry.setID(countryId);
    vesselTransportMeansType.setRegistrationVesselCountry(vesselCountry);
    VesselPositionEventType vesselPositionEventType = new VesselPositionEventType();
    MeasureType measureType = new MeasureType();
    measureType.setValue(new BigDecimal(282));
    vesselPositionEventType.setCourseValueMeasure(measureType);
    DateTimeType posDateTime = new DateTimeType();
    posDateTime.setDateTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
    vesselPositionEventType.setObtainedOccurrenceDateTime(posDateTime);
    VesselGeographicalCoordinateType cordinates = new VesselGeographicalCoordinateType();
    MeasureType longitude = new MeasureType();
    longitude.setValue(new BigDecimal(21.5740000000));
    cordinates.setLongitudeMeasure(longitude);
    MeasureType latitude = new MeasureType();
    latitude.setValue(new BigDecimal(59.6480000000));
    cordinates.setLatitudeMeasure(latitude);
    vesselPositionEventType.setSpecifiedVesselGeographicalCoordinate(cordinates);
    MeasureType speedValue = new MeasureType();
    speedValue.setValue(new BigDecimal(7.5));
    vesselPositionEventType.setSpeedValueMeasure(speedValue);
    CodeType typeCodeValue = new CodeType();
    typeCodeValue.setValue("POS");
    vesselPositionEventType.setTypeCode(typeCodeValue);
    vesselTransportMeansType.getSpecifiedVesselPositionEvents().add(vesselPositionEventType);
    fLUXVesselPositionMessage.setVesselTransportMeans(vesselTransportMeansType);
    FLUXReportDocumentType fluxReportDocumentType = new FLUXReportDocumentType();
    DateTimeType dateTimeType = new DateTimeType();
    dateTimeType.setDateTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
    fluxReportDocumentType.setCreationDateTime(dateTimeType);
    FLUXPartyType fLUXPartyType = new FLUXPartyType();
    fLUXPartyType.getIDS().add(countryId);
    fluxReportDocumentType.setOwnerFLUXParty(fLUXPartyType);
    TextType textType = new TextType();
    fluxReportDocumentType.setPurpose(textType);
    CodeType purposeCode = new CodeType();
    purposeCode.setValue("9");
    fluxReportDocumentType.setPurposeCode(purposeCode);
    IDType idType = new IDType();
    fluxReportDocumentType.setReferencedID(idType);
    CodeType typeCode = new CodeType();
    fluxReportDocumentType.setTypeCode(typeCode);
    fLUXVesselPositionMessage.setFLUXReportDocument(fluxReportDocumentType);
    requestType.setAny(createAnyElement(fLUXVesselPositionMessage));
    requestType.setAD("SWE");
    requestType.setAR(true);
    requestType.setDF("df");
    requestType.setON("on");
    requestType.setTO(1234);
    requestType.setTODT(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
    ResponseType responseType = bridgeConnectorPortType.post(requestType);
    assertNotNull(responseType);
    assertEquals("OK", responseType.getStatus());
    Thread.sleep(7500);
    List<String> connectIds = new ArrayList<>();
    connectIds.add(testAsset.getEventHistory().getEventId());
    final HttpResponse response = Request.Post(getBaseUrl() + "movement/rest/movement/latest").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(connectIds).getBytes()).execute().returnResponse();
    List dataList = checkSuccessResponseReturnType(response, List.class);
    assertEquals("Expect one position in movement db", 1, dataList.size());
}
Also used : ArrayList(java.util.ArrayList) MeasureType(un.unece.uncefact.data.standard.unqualifieddatatype._18.MeasureType) FLUXReportDocumentType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.FLUXReportDocumentType) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._18.IDType) BridgeConnectorPortType(xeu.bridge_connector.wsdl.v1.BridgeConnectorPortType) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) ArrayList(java.util.ArrayList) List(java.util.List) MobileTerminalType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType) VesselCountryType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselCountryType) FLUXVesselPositionMessage(un.unece.uncefact.data.standard.fluxvesselpositionmessage._4.FLUXVesselPositionMessage) VesselGeographicalCoordinateType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselGeographicalCoordinateType) GregorianCalendar(java.util.GregorianCalendar) VesselPositionEventType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselPositionEventType) HttpResponse(org.apache.http.HttpResponse) VesselTransportMeansType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselTransportMeansType) FLUXPartyType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.FLUXPartyType) Date(java.util.Date) BigDecimal(java.math.BigDecimal) TextType(un.unece.uncefact.data.standard.unqualifieddatatype._18.TextType) ResponseType(xeu.bridge_connector.v1.ResponseType) DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._18.DateTimeType) CodeType(un.unece.uncefact.data.standard.unqualifieddatatype._18.CodeType) RequestType(xeu.bridge_connector.v1.RequestType) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 5 with Asset

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

the class PollRestIT method inactivateProgramPollTest.

/**
 * Inactivate program poll test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void inactivateProgramPollTest() throws Exception {
    Asset testAsset = AssetTestHelper.createTestAsset();
    Map<String, Object> programPollDataMap = MobileTerminalTestHelper.createPoll_Helper(testAsset);
    ArrayList sendPolls = (ArrayList) programPollDataMap.get("sentPolls");
    String uid = (String) sendPolls.get(0);
    // start it
    {
        final HttpResponse response = Request.Put(getBaseUrl() + "mobileterminal/rest/poll/start/" + uid).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
        Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
    }
    // inactivate it
    final HttpResponse response = Request.Put(getBaseUrl() + "mobileterminal/rest/poll/inactivate/" + uid).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
    ArrayList values = (ArrayList) dataMap.get("value");
    assertNotNull(values);
    assertTrue(values.size() == 10);
}
Also used : ArrayList(java.util.ArrayList) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) HttpResponse(org.apache.http.HttpResponse) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)61 Test (org.junit.Test)54 AbstractRestServiceTest (eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)38 MobileTerminalType (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType)15 ArrayList (java.util.ArrayList)14 HttpResponse (org.apache.http.HttpResponse)14 AssetListQuery (eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery)13 AssetListCriteriaPair (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair)12 CreateMovementRequest (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementRequest)11 CreateMovementResponse (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementResponse)9 ListAssetResponse (eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse)8 Date (java.util.Date)5 AssetGroup (eu.europa.ec.fisheries.wsdl.asset.group.AssetGroup)4 AssetGroupSearchField (eu.europa.ec.fisheries.wsdl.asset.group.AssetGroupSearchField)4 Map (java.util.Map)4 AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)3 List (java.util.List)3 VesselDetailsDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 LatLong (eu.europa.ec.fisheries.uvms.docker.validation.movement.LatLong)2