Search in sources :

Example 51 with ExchangeLogType

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

the class LogMapper method toNewEntity.

public static ExchangeLog toNewEntity(ExchangeLogType log, String username) {
    ExchangeLog entity = new ExchangeLog();
    switch(log.getType()) {
        case RECEIVE_MOVEMENT:
            entity = toReceiveMovementEntity(log);
            break;
        case SEND_MOVEMENT:
            entity = toSendMovementEntity(log);
            break;
        case SEND_POLL:
            entity = toSendPollEntity(log);
            break;
        case SEND_EMAIL:
            entity = toSendEmailEntity(log);
            break;
        case RECEIVE_FLUX_RESPONSE_MSG:
        case RCV_FLUX_FA_REPORT_MSG:
        case RECEIVE_FA_QUERY_MSG:
        case SEND_FA_QUERY_MSG:
        case SEND_FLUX_FA_REPORT_MSG:
        case SEND_FLUX_RESPONSE_MSG:
            entity.setSource(FLUX);
            break;
    }
    if (username == null) {
        username = "SYSTEM";
    }
    if (log.getTypeRef() != null) {
        entity.setTypeRefGuid(log.getTypeRef().getRefGuid());
        entity.setTypeRefType(log.getTypeRef().getType());
        entity.setTypeRefMessage(log.getTypeRef().getMessage());
    }
    entity.setDateReceived(log.getDateRecieved());
    entity.setSenderReceiver(log.getSenderReceiver());
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.ISSUED;
    if (log.getStatus() != null) {
        status = log.getStatus();
    }
    List<ExchangeLogStatus> statusHistory = new ArrayList<>();
    ExchangeLogStatus statusLog = new ExchangeLogStatus();
    statusLog.setLog(entity);
    statusLog.setStatus(status);
    statusLog.setStatusTimestamp(DateUtils.nowUTC().toDate());
    statusLog.setUpdatedBy(username);
    statusLog.setUpdateTime(DateUtils.nowUTC().toDate());
    statusHistory.add(statusLog);
    entity.setStatus(status);
    if (entity.getTransferIncoming() == null) {
        entity.setTransferIncoming(log.isIncoming());
    }
    entity.setStatusHistory(statusHistory);
    entity.setUpdatedBy(username);
    entity.setUpdateTime(DateUtils.nowUTC().toDate());
    entity.setType(log.getType());
    entity.setDestination(log.getDestination());
    return entity;
}
Also used : ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ArrayList(java.util.ArrayList) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)

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