Search in sources :

Example 1 with SendPollType

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

the class LogMapperTest method toModelWhenEntityIsPollLog.

@Test
public void toModelWhenEntityIsPollLog() {
    Date dateReceived = new Date();
    String guid = "Paradise";
    String senderReceiver = "Chris Martin";
    boolean incoming = true;
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.PROBABLY_TRANSMITTED;
    Date fwdDate = new Date();
    String recipient = "Viva la vida";
    ExchangeLog entity = new ExchangeLog();
    entity.setDateReceived(dateReceived);
    entity.setGuid(guid);
    entity.setSenderReceiver(senderReceiver);
    entity.setTransferIncoming(incoming);
    entity.setStatus(status);
    entity.setFwdDate(fwdDate);
    entity.setRecipient(recipient);
    entity.setType(LogType.SEND_POLL);
    ExchangeLogType model = LogMapper.toModel(entity);
    assertEquals(LogType.SEND_POLL, model.getType());
    assertEquals(dateReceived, model.getDateRecieved());
    assertEquals(guid, model.getGuid());
    assertEquals(senderReceiver, model.getSenderReceiver());
    assertEquals(incoming, model.isIncoming());
    assertEquals(status, model.getStatus());
    assertEquals(fwdDate, ((SendPollType) model).getFwdDate());
    assertEquals(recipient, ((SendPollType) model).getRecipient());
}
Also used : ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) Date(java.util.Date) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) Test(org.junit.Test)

Example 2 with SendPollType

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

the class LogMapperTest method toNewEntityWhenLogTypeIsSendPoll.

@Test
public void toNewEntityWhenLogTypeIsSendPoll() throws Exception {
    // data set
    String typeRefGuid = "trg";
    TypeRefType typeRefType = TypeRefType.POLL;
    Date dateReceived = new Date();
    String senderOrReceiver = "BEL";
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.SUCCESSFUL;
    String message = "<xml></xml>";
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(typeRefGuid);
    logRefType.setType(typeRefType);
    logRefType.setMessage(message);
    Date fwdDate = new Date();
    String recipient = "potter@wb.com";
    SendPollType input = new SendPollType();
    input.setType(LogType.SEND_POLL);
    input.setTypeRef(logRefType);
    input.setDateRecieved(dateReceived);
    input.setSenderReceiver(senderOrReceiver);
    input.setStatus(status);
    input.setFwdDate(fwdDate);
    input.setRecipient(recipient);
    String username = "stainii";
    // execute
    ExchangeLog result = LogMapper.toNewEntity(input, username);
    // assert
    assertEquals(typeRefGuid, result.getTypeRefGuid());
    assertEquals(typeRefType, result.getTypeRefType());
    assertEquals(dateReceived, result.getDateReceived());
    assertEquals(senderOrReceiver, result.getSenderReceiver());
    assertEquals(status, result.getStatus());
    assertEquals(1, result.getStatusHistory().size());
    assertEquals(result, result.getStatusHistory().get(0).getLog());
    assertEquals(status, result.getStatusHistory().get(0).getStatus());
    assertNotNull(result.getStatusHistory().get(0).getStatusTimestamp());
    assertEquals(username, result.getStatusHistory().get(0).getUpdatedBy());
    assertNotNull(result.getStatusHistory().get(0).getUpdateTime());
    assertEquals(username, result.getUpdatedBy());
    assertNotNull(result.getUpdateTime());
    assertEquals(fwdDate, result.getFwdDate());
    assertEquals(recipient, result.getRecipient());
    assertFalse(result.getTransferIncoming());
    assertEquals(LogType.SEND_POLL, result.getType());
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) SendPollType(eu.europa.ec.fisheries.schema.exchange.v1.SendPollType) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) Date(java.util.Date) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) Test(org.junit.Test)

Example 3 with SendPollType

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

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

Example 5 with SendPollType

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

the class LogMapper method toSendPollEntity.

private static ExchangeLog toSendPollEntity(ExchangeLogType log) {
    SendPollType type = (SendPollType) log;
    ExchangeLog entity = new ExchangeLog();
    entity.setTransferIncoming(false);
    entity.setRecipient(type.getRecipient());
    entity.setFwdDate(type.getFwdDate());
    return entity;
}
Also used : SendPollType(eu.europa.ec.fisheries.schema.exchange.v1.SendPollType) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)

Aggregations

SendPollType (eu.europa.ec.fisheries.schema.exchange.v1.SendPollType)4 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)3 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)3 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)2 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)2 Date (java.util.Date)2 Test (org.junit.Test)2 LogType (eu.europa.ec.fisheries.schema.exchange.v1.LogType)1 ReceiveMovementType (eu.europa.ec.fisheries.schema.exchange.v1.ReceiveMovementType)1 SendEmailType (eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType)1 SendMovementType (eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType)1 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)1 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)1