Search in sources :

Example 1 with AssetId

use of eu.europa.ec.fisheries.schema.rules.asset.v1.AssetId in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method processMovement.

@Override
public void processMovement(@Observes @SetMovementEvent ExchangeMessageEvent message) {
    try {
        final TextMessage jmsMessage = message.getJmsMessage();
        final String jmsMessageID = jmsMessage.getJMSMessageID();
        SetMovementReportRequest request = JAXBMarshaller.unmarshallTextMessage(jmsMessage, SetMovementReportRequest.class);
        log.info("[INFO] Processing Movement : {}", request);
        String username;
        SetReportMovementType setRepMovType = request.getRequest();
        if (MovementSourceType.MANUAL.equals(setRepMovType.getMovement().getSource())) {
            // A person has created a position
            username = request.getUsername();
            // Send some response to Movement, if it originated from there (manual movement)
            ProcessedMovementAck response = MovementModuleResponseMapper.mapProcessedMovementAck(eu.europa.ec.fisheries.schema.movement.common.v1.AcknowledgeTypeType.OK, jmsMessageID, "Movement successfully processed");
            producer.sendModuleAckMessage(jmsMessageID, MessageQueue.MOVEMENT_RESPONSE, JAXBMarshaller.marshallJaxBObjectToString(response));
        } else {
            // A plugin has reported a position
            username = setRepMovType.getPluginType().name();
        }
        String pluginName = setRepMovType.getPluginName();
        ServiceResponseType service = exchangeService.getService(pluginName);
        PluginType pluginType = setRepMovType.getPluginType();
        if (validate(setRepMovType, service, jmsMessage)) {
            MovementBaseType baseMovement = setRepMovType.getMovement();
            RawMovementType rawMovement = MovementMapper.getInstance().getMapper().map(baseMovement, RawMovementType.class);
            final AssetId assetId = rawMovement.getAssetId();
            if (assetId != null && assetId.getAssetIdList() != null) {
                assetId.getAssetIdList().addAll(MovementMapper.mapAssetIdList(baseMovement.getAssetId().getAssetIdList()));
            }
            if (baseMovement.getMobileTerminalId() != null && baseMovement.getMobileTerminalId().getMobileTerminalIdList() != null) {
                rawMovement.getMobileTerminal().getMobileTerminalIdList().addAll(MovementMapper.mapMobileTerminalIdList(baseMovement.getMobileTerminalId().getMobileTerminalIdList()));
            }
            rawMovement.setPluginType(pluginType.value());
            rawMovement.setPluginName(pluginName);
            rawMovement.setDateRecieved(setRepMovType.getTimestamp());
            // TODO : Temporary - probably better to change corr id to have the same though the entire flow;
            // TODO : then we can use this to send response to original caller from anywhere needed
            rawMovement.setAckResponseMessageID(jmsMessageID);
            log.info("[INFO] Logging received movement.");
            exchangeLog.log(request, LogType.RECEIVE_MOVEMENT, ExchangeLogStatusTypeType.ISSUED, TypeRefType.MOVEMENT, JAXBMarshaller.marshallJaxBObjectToString(request), true);
            forwardToRules(RulesModuleRequestMapper.createSetMovementReportRequest(PluginTypeMapper.map(pluginType), rawMovement, username), message, service);
            log.info("[INFO] Finished forwarding received movement to rules module.");
        } else {
            log.debug("[ERROR] Validation error. Event sent to plugin {}", message);
        }
    } catch (ExchangeServiceException e) {
        log.error("[ERROR] Couldn't get the Service type for the received message : {} {}", message, e);
    } catch (ExchangeModelMarshallException e) {
        log.error("[ERROR] Couldn't map to SetMovementReportRequest when processing movement from plugin:{} {}", message, e);
    } catch (JMSException e) {
        log.error("[ERROR] Failed to get response queue:{} {}", message, e);
    } catch (RulesModelMapperException e) {
        log.error("[ERROR] Failed to build Rules momvent request:{} {}", message, e);
    } catch (ExchangeLogException e) {
        log.error("[ERROR] Failed to log momvent request : {} {}", message, e);
    }
}
Also used : ServiceResponseType(eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType) MovementBaseType(eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementBaseType) JMSException(javax.jms.JMSException) ProcessedMovementAck(eu.europa.ec.fisheries.schema.movement.module.v1.ProcessedMovementAck) PluginType(eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType) RulesModelMapperException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMapperException) ExchangeServiceException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeServiceException) ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RawMovementType(eu.europa.ec.fisheries.schema.rules.movement.v1.RawMovementType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) SetReportMovementType(eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType) AssetId(eu.europa.ec.fisheries.schema.rules.asset.v1.AssetId) TextMessage(javax.jms.TextMessage) SetMovementReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SetMovementReportRequest)

Example 2 with AssetId

use of eu.europa.ec.fisheries.schema.rules.asset.v1.AssetId in project UVMS-Docker by UnionVMS.

the class MovementHelper method createMovementBatchRequest.

public CreateMovementBatchRequest createMovementBatchRequest(Asset testAsset, MobileTerminalType mobileTerminalType, List<LatLong> route) throws IOException, ClientProtocolException, JsonProcessingException, JsonParseException, JsonMappingException {
    // Date positionTime = new Date(System.currentTimeMillis());
    final CreateMovementBatchRequest createMovementBatchRequest = new CreateMovementBatchRequest();
    AssetId assetId = new AssetId();
    assetId.setAssetType(AssetType.VESSEL);
    assetId.setIdType(AssetIdType.GUID);
    assetId.setValue(testAsset.getAssetId().getGuid());
    MovementActivityType movementActivityType = new MovementActivityType();
    movementActivityType.setMessageId(UUID.randomUUID().toString());
    movementActivityType.setMessageType(MovementActivityTypeType.ANC);
    createMovementBatchRequest.setMethod(MovementModuleMethod.CREATE_BATCH);
    createMovementBatchRequest.setUsername("vms_admin_com");
    for (LatLong latlong : route) {
        MovementBaseType movementBaseType = new MovementBaseType();
        movementBaseType.setAssetId(assetId);
        movementBaseType.setConnectId(mobileTerminalType.getConnectId());
        movementBaseType.setActivity(movementActivityType);
        MovementPoint movementPoint = new MovementPoint();
        movementPoint.setLongitude(latlong.longitude);
        movementPoint.setLatitude(latlong.latitude);
        movementPoint.setAltitude((double) 5);
        movementBaseType.setPosition(movementPoint);
        movementBaseType.setPositionTime(latlong.positionTime);
        movementBaseType.setMovementType(MovementTypeType.POS);
        movementBaseType.setReportedCourse(latlong.bearing);
        movementBaseType.setReportedSpeed(latlong.speed);
        createMovementBatchRequest.getMovement().add(movementBaseType);
    }
    return createMovementBatchRequest;
}
Also used : MovementActivityType(eu.europa.ec.fisheries.schema.movement.v1.MovementActivityType) MovementBaseType(eu.europa.ec.fisheries.schema.movement.v1.MovementBaseType) CreateMovementBatchRequest(eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementBatchRequest) MovementPoint(eu.europa.ec.fisheries.schema.movement.v1.MovementPoint) AssetId(eu.europa.ec.fisheries.schema.movement.asset.v1.AssetId)

Example 3 with AssetId

use of eu.europa.ec.fisheries.schema.rules.asset.v1.AssetId in project UVMS-Docker by UnionVMS.

the class MovementHelper method createMovementRequest.

public CreateMovementRequest createMovementRequest(Asset testAsset, MobileTerminalType mobileTerminalType, LatLong latlong) throws IOException, ClientProtocolException, JsonProcessingException, JsonParseException, JsonMappingException {
    // Date positionTime = new Date(System.currentTimeMillis());
    final CreateMovementRequest createMovementRequest1 = new CreateMovementRequest();
    final MovementBaseType movementBaseType = new MovementBaseType();
    AssetId assetId = new AssetId();
    assetId.setAssetType(AssetType.VESSEL);
    assetId.setIdType(AssetIdType.GUID);
    assetId.setValue(testAsset.getAssetId().getGuid());
    movementBaseType.setAssetId(assetId);
    movementBaseType.setConnectId(mobileTerminalType.getConnectId());
    MovementActivityType movementActivityType = new MovementActivityType();
    movementBaseType.setActivity(movementActivityType);
    movementActivityType.setMessageId(UUID.randomUUID().toString());
    movementActivityType.setMessageType(MovementActivityTypeType.ANC);
    createMovementRequest1.setMovement(movementBaseType);
    createMovementRequest1.setMethod(MovementModuleMethod.CREATE);
    createMovementRequest1.setUsername("vms_admin_com");
    MovementPoint movementPoint = new MovementPoint();
    movementPoint.setLongitude(latlong.longitude);
    movementPoint.setLatitude(latlong.latitude);
    movementPoint.setAltitude((double) 5);
    movementBaseType.setPosition(movementPoint);
    movementBaseType.setPositionTime(latlong.positionTime);
    movementBaseType.setMovementType(MovementTypeType.POS);
    movementBaseType.setReportedCourse(latlong.bearing);
    movementBaseType.setReportedSpeed(latlong.speed);
    return createMovementRequest1;
}
Also used : CreateMovementRequest(eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementRequest) MovementActivityType(eu.europa.ec.fisheries.schema.movement.v1.MovementActivityType) MovementBaseType(eu.europa.ec.fisheries.schema.movement.v1.MovementBaseType) MovementPoint(eu.europa.ec.fisheries.schema.movement.v1.MovementPoint) AssetId(eu.europa.ec.fisheries.schema.movement.asset.v1.AssetId)

Example 4 with AssetId

use of eu.europa.ec.fisheries.schema.rules.asset.v1.AssetId 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)

Aggregations

SetMovementReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SetMovementReportRequest)2 MovementBaseType (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementBaseType)2 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)2 AssetId (eu.europa.ec.fisheries.schema.movement.asset.v1.AssetId)2 MovementActivityType (eu.europa.ec.fisheries.schema.movement.v1.MovementActivityType)2 MovementBaseType (eu.europa.ec.fisheries.schema.movement.v1.MovementBaseType)2 MovementPoint (eu.europa.ec.fisheries.schema.movement.v1.MovementPoint)2 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 MovementPoint (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementPoint)1 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)1 ServiceResponseType (eu.europa.ec.fisheries.schema.exchange.service.v1.ServiceResponseType)1 CreateMovementBatchRequest (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementBatchRequest)1 CreateMovementRequest (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementRequest)1 ProcessedMovementAck (eu.europa.ec.fisheries.schema.movement.module.v1.ProcessedMovementAck)1 AssetId (eu.europa.ec.fisheries.schema.rules.asset.v1.AssetId)1 RawMovementType (eu.europa.ec.fisheries.schema.rules.movement.v1.RawMovementType)1 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)1