Search in sources :

Example 21 with ExchangeLogType

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

the class ExchangeLogModelBean method setPollStatus.

@Override
public ExchangeLogType setPollStatus(PollStatus pollStatus, String username) throws ExchangeModelException {
    ExchangeLogType log = null;
    if (pollStatus == null || pollStatus.getPollGuid() == null) {
        throw new InputArgumentException("No poll id to update status");
    }
    try {
        List<ExchangeLog> exchangeLogByTypesRefAndGuid = logDao.getExchangeLogByTypesRefAndGuid(pollStatus.getPollGuid(), Collections.singletonList(TypeRefType.POLL));
        if (CollectionUtils.isNotEmpty(exchangeLogByTypesRefAndGuid)) {
            List<ExchangeLogStatus> statusList = exchangeLogByTypesRefAndGuid.get(0).getStatusHistory();
            statusList.add(LogMapper.toNewStatusEntity(exchangeLogByTypesRefAndGuid.get(0), pollStatus.getStatus(), username));
            exchangeLogByTypesRefAndGuid.get(0).setStatus(pollStatus.getStatus());
            ExchangeLog retEntity = logDao.updateLog(exchangeLogByTypesRefAndGuid.get(0));
            log = LogMapper.toModel(retEntity);
        }
    } catch (ExchangeDaoException ex) {
        LOG.error("[ Error when set poll status {} {}] {}", pollStatus, username, ex.getMessage());
        throw new ExchangeModelException("Error when update status of Exchange log ");
    }
    return log;
}
Also used : InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)

Example 22 with ExchangeLogType

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

the class ExchangeLogModelBean method getExchangeLogByGuid.

@Override
public ExchangeLogType getExchangeLogByGuid(String guid) throws ExchangeModelException {
    ExchangeLogType exchangeLogType;
    try {
        ExchangeLog exchangeLog = logDao.getExchangeLogByGuid(guid, null);
        exchangeLogType = LogMapper.toModel(exchangeLog);
        // Enriches the "first level logs" with info related to the related logs.
        enrichDtosWithRelatedLogsInfo(Collections.singletonList(exchangeLogType));
    } catch (Exception e) {
        LOG.error("[ Error when getting exchange log by GUID. {}] {}", guid, e.getMessage());
        exchangeLogType = null;
    }
    return exchangeLogType;
}
Also used : ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ParseException(java.text.ParseException) InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ExchangeSearchMapperException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeSearchMapperException) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)

Example 23 with ExchangeLogType

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

the class LogMapper method toModel.

public static ExchangeLogType toModel(ExchangeLog entity) {
    ExchangeLogType model = new ExchangeLogType();
    LogType logType = entity.getType();
    if (logType.equals(LogType.RECEIVE_MOVEMENT)) {
        ReceiveMovementType type = new ReceiveMovementType();
        type.setSource(entity.getSource());
        type.setRecipient(entity.getRecipient());
        logType = LogType.RECEIVE_MOVEMENT;
        model = type;
    } else if (logType.equals(LogType.SEND_MOVEMENT)) {
        SendMovementType type = new SendMovementType();
        type.setFwdDate(entity.getFwdDate());
        type.setFwdRule(entity.getFwdRule());
        type.setRecipient(entity.getRecipient());
        logType = LogType.SEND_MOVEMENT;
        model = type;
    } else if (logType.equals(LogType.SEND_POLL)) {
        SendPollType type = new SendPollType();
        type.setFwdDate(entity.getFwdDate());
        type.setRecipient(entity.getRecipient());
        logType = LogType.SEND_POLL;
        model = type;
    } else if (logType.equals(LogType.SEND_EMAIL)) {
        SendEmailType type = new SendEmailType();
        type.setFwdRule(entity.getFwdRule());
        type.setFwdDate(entity.getFwdDate());
        type.setRecipient(entity.getRecipient());
        logType = LogType.SEND_EMAIL;
        model = type;
    }
    model.setDateRecieved(entity.getDateReceived());
    model.setGuid(entity.getGuid());
    model.setSenderReceiver(entity.getSenderReceiver());
    model.setIncoming(entity.getTransferIncoming());
    model.setStatus(entity.getStatus());
    model.setDestination(entity.getDestination());
    model.setType(logType);
    model.setSource(entity.getSource());
    model.setTypeRefType(entity.getTypeRefType());
    if (entity.getTypeRefType() != null) {
        LogRefType logRefType = new LogRefType();
        logRefType.setRefGuid(entity.getTypeRefGuid());
        logRefType.setType(entity.getTypeRefType());
        logRefType.setMessage(entity.getTypeRefMessage());
        model.setTypeRef(logRefType);
    }
    return model;
}
Also used : SendPollType(eu.europa.ec.fisheries.schema.exchange.v1.SendPollType) SendEmailType(eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) LogType(eu.europa.ec.fisheries.schema.exchange.v1.LogType) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) ReceiveMovementType(eu.europa.ec.fisheries.schema.exchange.v1.ReceiveMovementType) SendMovementType(eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType)

Example 24 with ExchangeLogType

use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType 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 25 with ExchangeLogType

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

Aggregations

ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)43 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)27 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)19 Test (org.junit.Test)19 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)18 Date (java.util.Date)17 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)13 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)9 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)8 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)8 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)5 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)5 JMSException (javax.jms.JMSException)5 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)4 ArrayList (java.util.ArrayList)4 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)3 SendEmailType (eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType)3 SendMovementType (eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType)3 SendPollType (eu.europa.ec.fisheries.schema.exchange.v1.SendPollType)3 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)3