Search in sources :

Example 1 with MovementRefType

use of eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementRefType in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method handleProcessedMovement.

// Async response handler for processed movements
@Override
public void handleProcessedMovement(@Observes @HandleProcessedMovementEvent ExchangeMessageEvent message) {
    try {
        ProcessedMovementResponse request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), ProcessedMovementResponse.class);
        log.debug("Received processed movement from Rules:{}", request);
        String username;
        MovementRefType movementRefType = request.getMovementRefType();
        SetReportMovementType orgRequest = request.getOrgRequest();
        if (PluginType.MANUAL.equals(orgRequest.getPluginType())) {
            username = request.getUsername();
        } else {
            username = orgRequest.getPluginName();
        }
        ExchangeLogType log = ExchangeLogMapper.getReceivedMovementExchangeLog(orgRequest, movementRefType.getMovementRefGuid(), movementRefType.getType().value(), username);
        ExchangeLogType createdLog = exchangeLog.log(log, username);
        LogRefType logTypeRef = createdLog.getTypeRef();
        if (logTypeRef != null && logTypeRef.getType() == TypeRefType.POLL) {
            String pollGuid = logTypeRef.getRefGuid();
            pollEvent.fire(new NotificationMessage("guid", pollGuid));
        }
    } catch (ExchangeLogException | ExchangeModelMarshallException e) {
        log.error(e.getMessage());
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) MovementRefType(eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementRefType) NotificationMessage(eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) SetReportMovementType(eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType) ProcessedMovementResponse(eu.europa.ec.fisheries.schema.exchange.module.v1.ProcessedMovementResponse)

Aggregations

ProcessedMovementResponse (eu.europa.ec.fisheries.schema.exchange.module.v1.ProcessedMovementResponse)1 MovementRefType (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementRefType)1 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)1 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)1 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)1 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)1 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)1 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)1