Search in sources :

Example 11 with LogRefType

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

the class ExchangeLogMapper method getSendMovementExchangeLog.

public static ExchangeLogType getSendMovementExchangeLog(SendMovementToPluginType sendReport) throws ExchangeLogException {
    if (sendReport == null) {
        throw new ExchangeLogException("No request");
    }
    SendMovementType log = new SendMovementType();
    log.setDateRecieved(sendReport.getTimestamp());
    log.setType(LogType.SEND_MOVEMENT);
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(sendReport.getMovement().getGuid());
    logRefType.setType(TypeRefType.MOVEMENT);
    log.setTypeRef(logRefType);
    String senderReceiver = getSendMovementSenderReceiver(sendReport);
    log.setSenderReceiver(senderReceiver);
    // TODO send fwdDate, fwdRule and recipient from Rules
    log.setFwdDate(sendReport.getFwdDate());
    log.setFwdRule(sendReport.getFwdRule());
    log.setRecipient(sendReport.getRecipient());
    return log;
}
Also used : ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) SendMovementType(eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType)

Example 12 with LogRefType

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

the class ExchangeLogMapper method getReceivedMovementExchangeLog.

public static ExchangeLogType getReceivedMovementExchangeLog(SetReportMovementType request, String typeRefGuid, String typeRefType, String username) throws ExchangeLogException {
    if (request == null) {
        throw new ExchangeLogException("No request");
    }
    ReceiveMovementType log = new ReceiveMovementType();
    log.setDateRecieved(request.getTimestamp());
    log.setType(LogType.RECEIVE_MOVEMENT);
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(typeRefGuid);
    TypeRefType refType = TypeRefType.UNKNOWN;
    try {
        refType = TypeRefType.fromValue(typeRefType);
    } catch (IllegalArgumentException e) {
        LOG.error("Non existing typeRefType: " + typeRefType);
    }
    logRefType.setType(refType);
    log.setTypeRef(logRefType);
    log.setStatus(ExchangeLogStatusTypeType.SUCCESSFUL);
    log.setSenderReceiver(getSenderReceiver(request.getMovement(), request.getPluginType(), request.getPluginName(), username));
    if (request.getMovement().getSource() != null) {
        log.setSource(request.getMovement().getSource().name());
    } else {
        log.setSource(request.getPluginType().name());
    }
    log.setRecipient(getRecipient(request.getMovement(), request.getPluginType()));
    return log;
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) ReceiveMovementType(eu.europa.ec.fisheries.schema.exchange.v1.ReceiveMovementType)

Example 13 with LogRefType

use of eu.europa.ec.fisheries.schema.exchange.v1.LogRefType 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)

Example 14 with LogRefType

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

the class ExchangeLogServiceBean method log.

@Override
public ExchangeLogType log(ExchangeBaseRequest request, LogType logType, ExchangeLogStatusTypeType status, TypeRefType messageType, String messageText, boolean incoming) throws ExchangeLogException {
    LogRefType ref = new LogRefType();
    ref.setMessage(messageText);
    ref.setRefGuid(request.getMessageGuid());
    ref.setType(messageType);
    ExchangeLogType log = new ExchangeLogType();
    log.setSenderReceiver(request.getSenderOrReceiver());
    log.setDateRecieved(request.getDate());
    log.setType(logType);
    log.setStatus(status);
    log.setIncoming(incoming);
    log.setTypeRef(ref);
    log.setDestination(request.getDestination());
    return log(log, request.getUsername());
}
Also used : ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)

Example 15 with LogRefType

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

the class ExchangeLogMapper method getPollExchangeLog.

private static ExchangeLogType getPollExchangeLog(CommandType command) throws ExchangeLogException {
    if (command.getPoll() == null) {
        throw new ExchangeLogException("No poll");
    }
    // TODO fix in mobileterminal
    SendPollType log = new SendPollType();
    log.setType(LogType.SEND_POLL);
    log.setDateRecieved(command.getTimestamp());
    log.setRecipient(getRecipientOfPoll(command.getPoll().getPollReceiver()));
    log.setSenderReceiver("System");
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(command.getPoll().getPollId());
    logRefType.setType(TypeRefType.POLL);
    log.setFwdDate(command.getTimestamp());
    log.setTypeRef(logRefType);
    return log;
}
Also used : SendPollType(eu.europa.ec.fisheries.schema.exchange.v1.SendPollType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)

Aggregations

LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)18 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)11 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)10 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)10 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)10 Date (java.util.Date)10 Test (org.junit.Test)10 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)5 ReceiveMovementType (eu.europa.ec.fisheries.schema.exchange.v1.ReceiveMovementType)3 SendMovementType (eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType)3 SendPollType (eu.europa.ec.fisheries.schema.exchange.v1.SendPollType)3 SendEmailType (eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType)2 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)2 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 ExchangeLogStatusHistoryType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType)1 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)1 LogType (eu.europa.ec.fisheries.schema.exchange.v1.LogType)1 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)1