Search in sources :

Example 1 with MobileTerminalId

use of eu.europa.ec.fisheries.schema.exchange.movement.mobileterminal.v1.MobileTerminalId in project UVMS-Docker by UnionVMS.

the class SetMovementReportRequestJmsIT method createSetReportMovementType.

/**
 * Creates the set report movement type.
 *
 * @param testAsset
 *            the test asset
 * @param mobileTerminalType
 *            the mobile terminal type
 * @param createMovementRequest
 *            the create movement request
 * @return the sets the movement report request
 */
private SetMovementReportRequest createSetReportMovementType(Asset testAsset, MobileTerminalType mobileTerminalType, CreateMovementRequest createMovementRequest) {
    final SetMovementReportRequest request = new SetMovementReportRequest();
    request.setUsername("vms_admin_com");
    request.setDate(new Date());
    request.setMethod(ExchangeModuleMethod.SET_MOVEMENT_REPORT);
    request.setPluginType(PluginType.NAF);
    final SetReportMovementType movementType = new SetReportMovementType();
    request.setRequest(movementType);
    movementType.setPluginType(PluginType.NAF);
    movementType.setTimestamp(new Date());
    movementType.setPluginName(mobileTerminalType.getPlugin().getServiceName());
    MovementBaseType movementBaseType = new MovementBaseType();
    movementType.setMovement(movementBaseType);
    MovementActivityType movementActivityType = new MovementActivityType();
    movementBaseType.setActivity(movementActivityType);
    AssetId assetId = new AssetId();
    movementBaseType.setAssetId(assetId);
    assetId.setAssetType(AssetType.VESSEL);
    AssetIdList assetIdList = new AssetIdList();
    {
        assetIdList.setIdType(AssetIdType.GUID);
        assetIdList.setValue(testAsset.getAssetId().getGuid());
        assetId.getAssetIdList().add(assetIdList);
    }
    {
        assetIdList.setIdType(AssetIdType.IRCS);
        assetIdList.setValue(testAsset.getIrcs());
        assetId.getAssetIdList().add(assetIdList);
    }
    {
        assetIdList.setIdType(AssetIdType.CFR);
        assetIdList.setValue(testAsset.getCfr());
        assetId.getAssetIdList().add(assetIdList);
    }
    {
        assetIdList.setIdType(AssetIdType.MMSI);
        assetIdList.setValue(testAsset.getMmsiNo());
        assetId.getAssetIdList().add(assetIdList);
    }
    movementBaseType.setAssetName(testAsset.getName());
    movementBaseType.setComChannelType(MovementComChannelType.NAF);
    movementBaseType.setExternalMarking(testAsset.getExternalMarking());
    movementBaseType.setFlagState(testAsset.getCountryCode());
    movementBaseType.setInternalReferenceNumber(testAsset.getIrcs());
    movementBaseType.setIrcs(testAsset.getIrcs());
    movementBaseType.setMmsi(testAsset.getMmsiNo());
    MobileTerminalId mobileTerminalId = new MobileTerminalId();
    mobileTerminalId.setConnectId(mobileTerminalType.getConnectId());
    mobileTerminalId.setGuid(mobileTerminalType.getMobileTerminalId().getGuid());
    movementBaseType.setMobileTerminalId(mobileTerminalId);
    movementBaseType.setMovementType(MovementTypeType.POS);
    MovementPoint movementPoint = new MovementPoint();
    movementPoint.setLongitude(createMovementRequest.getMovement().getPosition().getLongitude());
    movementPoint.setLatitude(createMovementRequest.getMovement().getPosition().getLatitude());
    movementPoint.setAltitude(createMovementRequest.getMovement().getPosition().getAltitude());
    movementBaseType.setPosition(movementPoint);
    movementBaseType.setPositionTime(new Date());
    movementBaseType.setReportedCourse(1d);
    movementBaseType.setReportedSpeed(1d);
    movementBaseType.setSource(MovementSourceType.INMARSAT_C);
    movementBaseType.setTripNumber(1d);
    return request;
}
Also used : MovementActivityType(eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementActivityType) AssetIdList(eu.europa.ec.fisheries.schema.exchange.movement.asset.v1.AssetIdList) MovementBaseType(eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementBaseType) MovementPoint(eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementPoint) MobileTerminalId(eu.europa.ec.fisheries.schema.exchange.movement.mobileterminal.v1.MobileTerminalId) SetReportMovementType(eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType) AssetId(eu.europa.ec.fisheries.schema.exchange.movement.asset.v1.AssetId) Date(java.util.Date) SetMovementReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SetMovementReportRequest)

Example 2 with MobileTerminalId

use of eu.europa.ec.fisheries.schema.exchange.movement.mobileterminal.v1.MobileTerminalId in project UVMS-Docker by UnionVMS.

the class MobileTerminalTestHelper method createMobileTerminalType.

public static MobileTerminalType createMobileTerminalType() throws IOException, ClientProtocolException, JsonProcessingException, JsonParseException, JsonMappingException {
    MobileTerminalType mobileTerminalRequest = new MobileTerminalType();
    mobileTerminalRequest.setSource(MobileTerminalSource.INTERNAL);
    mobileTerminalRequest.setType("INMARSAT_C");
    List<MobileTerminalAttribute> attributes = mobileTerminalRequest.getAttributes();
    addAttribute(attributes, "SERIAL_NUMBER", AssetTestHelper.generateARandomStringWithMaxLength(10));
    addAttribute(attributes, "SATELLITE_NUMBER", "S" + AssetTestHelper.generateARandomStringWithMaxLength(4));
    addAttribute(attributes, "ANTENNA", "A");
    addAttribute(attributes, "TRANSCEIVER_TYPE", "A");
    addAttribute(attributes, "SOFTWARE_VERSION", "A");
    List<ComChannelType> channels = mobileTerminalRequest.getChannels();
    ComChannelType comChannelType = new ComChannelType();
    channels.add(comChannelType);
    comChannelType.setGuid(UUID.randomUUID().toString());
    comChannelType.setName("VMS");
    addChannelAttribute(comChannelType, "FREQUENCY_GRACE_PERIOD", "54000");
    addChannelAttribute(comChannelType, "MEMBER_NUMBER", "100");
    addChannelAttribute(comChannelType, "FREQUENCY_EXPECTED", "7200");
    addChannelAttribute(comChannelType, "FREQUENCY_IN_PORT", "10800");
    addChannelAttribute(comChannelType, "LES_DESCRIPTION", "Thrane&Thrane");
    addChannelAttribute(comChannelType, "DNID", "1" + AssetTestHelper.generateARandomStringWithMaxLength(3));
    addChannelAttribute(comChannelType, "INSTALLED_BY", "Mike Great");
    addChannelCapability(comChannelType, "POLLABLE", true);
    addChannelCapability(comChannelType, "CONFIGURABLE", true);
    addChannelCapability(comChannelType, "DEFAULT_REPORTING", true);
    Plugin plugin = new Plugin();
    plugin.setServiceName("eu.europa.ec.fisheries.uvms.plugins.inmarsat");
    plugin.setLabelName("Thrane&Thrane");
    plugin.setSatelliteType("INMARSAT_C");
    plugin.setInactive(false);
    mobileTerminalRequest.setPlugin(plugin);
    final HttpResponse response = Request.Post(getBaseUrl() + "mobileterminal/rest/mobileterminal").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(mobileTerminalRequest).getBytes()).execute().returnResponse();
    Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
    Map<String, Object> assetMap = (Map<String, Object>) dataMap.get("mobileTerminalId");
    assertNotNull(assetMap);
    String mobileTerminalGuid = (String) assetMap.get("guid");
    assertNotNull(mobileTerminalGuid);
    ArrayList channelsList = (ArrayList) dataMap.get("channels");
    assertNotNull(channelsList);
    Map<String, Object> channelMap = (Map<String, Object>) channelsList.get(0);
    assertNotNull(channelMap);
    String channelGuid = (String) channelMap.get("guid");
    comChannelType.setGuid(channelGuid);
    mobileTerminalRequest.setId((Integer) dataMap.get("id"));
    MobileTerminalId mobileTerminalId = new MobileTerminalId();
    mobileTerminalId.setGuid(mobileTerminalGuid);
    mobileTerminalRequest.setMobileTerminalId(mobileTerminalId);
    return mobileTerminalRequest;
}
Also used : ComChannelType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.ComChannelType) ArrayList(java.util.ArrayList) HttpResponse(org.apache.http.HttpResponse) MobileTerminalId(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalId) MobileTerminalAttribute(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAttribute) MobileTerminalType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType) Map(java.util.Map) Plugin(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.Plugin)

Aggregations

SetMovementReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetMovementReportRequest)1 AssetId (eu.europa.ec.fisheries.schema.exchange.movement.asset.v1.AssetId)1 AssetIdList (eu.europa.ec.fisheries.schema.exchange.movement.asset.v1.AssetIdList)1 MobileTerminalId (eu.europa.ec.fisheries.schema.exchange.movement.mobileterminal.v1.MobileTerminalId)1 MovementActivityType (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementActivityType)1 MovementBaseType (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementBaseType)1 MovementPoint (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementPoint)1 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)1 ComChannelType (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.ComChannelType)1 MobileTerminalAttribute (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalAttribute)1 MobileTerminalId (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalId)1 MobileTerminalType (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType)1 Plugin (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.Plugin)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Map (java.util.Map)1 HttpResponse (org.apache.http.HttpResponse)1