Search in sources :

Example 21 with ExchangeLogStatusTypeType

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

the class ExchangeLogServiceBean method setPollStatus.

@Override
public PollStatus setPollStatus(String jmsCorrelationId, String pollId, ExchangeLogStatusTypeType logStatus, String username) throws ExchangeLogException {
    try {
        // Remove the message from cache, because legancy implementation
        logCache.acknowledged(jmsCorrelationId);
        PollStatus pollStatus = new PollStatus();
        pollStatus.setPollGuid(pollId);
        pollStatus.setStatus(logStatus);
        ExchangeLogType exchangeLogType = exchangeLogModel.setPollStatus(pollStatus, username);
        pollStatus.setExchangeLogGuid(exchangeLogType.getGuid());
        sendAuditLogMessageForUpdatePollStatus(pollId, username);
        // For long polling
        exchangeLogEvent.fire(new NotificationMessage("guid", pollStatus.getExchangeLogGuid()));
        return pollStatus;
    } catch (ExchangeModelMapperException e) {
        throw new ExchangeLogException("Couldn't update status of exchange log");
    } catch (ExchangeModelException e) {
        throw new ExchangeLogException("Couldn't update status of exchange log");
    }
}
Also used : PollStatus(eu.europa.ec.fisheries.schema.exchange.v1.PollStatus) ExchangeModelMapperException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMapperException) 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) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 22 with ExchangeLogStatusTypeType

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

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

the class ExchangeLogServiceBean method updateStatus.

@Override
public ExchangeLogType updateStatus(String pluginMessageId, ExchangeLogStatusTypeType logStatus, String username) throws ExchangeLogException {
    try {
        String logGuid = logCache.acknowledged(pluginMessageId);
        ExchangeLogStatusType exchangeLogStatusType = createExchangeLogStatusType(logStatus, logGuid);
        ExchangeLogType updatedLog = exchangeLogModel.updateExchangeLogStatus(exchangeLogStatusType, username);
        sendAuditLogMessageForUpdateExchangeLog(updatedLog.getGuid(), username);
        // For long polling
        exchangeLogEvent.fire(new NotificationMessage("guid", updatedLog.getGuid()));
        return updatedLog;
    } catch (ExchangeModelException e) {
        throw new ExchangeLogException("Couldn't update status of exchange log", e);
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) 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) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)

Example 24 with ExchangeLogStatusTypeType

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

the class LogMapperTest method toNewEntityWhenLogTypeIsReceiveSalesReportAndUsernameIsNull.

@Test
public void toNewEntityWhenLogTypeIsReceiveSalesReportAndUsernameIsNull() throws Exception {
    // data set
    Date dateReceived = new Date();
    String senderOrReceiver = "BEL";
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.SUCCESSFUL;
    String destination = "destination";
    ExchangeLogType input = new ExchangeLogType();
    input.setType(LogType.RECEIVE_SALES_REPORT);
    input.setDateRecieved(dateReceived);
    input.setSenderReceiver(senderOrReceiver);
    input.setStatus(status);
    input.setIncoming(true);
    input.setDestination(destination);
    // execute
    ExchangeLog result = LogMapper.toNewEntity(input, null);
    // assert
    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("SYSTEM", result.getStatusHistory().get(0).getUpdatedBy());
    assertNotNull(result.getStatusHistory().get(0).getUpdateTime());
    assertEquals("SYSTEM", result.getUpdatedBy());
    assertNotNull(result.getUpdateTime());
    assertTrue(result.getTransferIncoming());
    assertEquals(LogType.RECEIVE_SALES_REPORT, result.getType());
    assertEquals(destination, result.getDestination());
}
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 25 with ExchangeLogStatusTypeType

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

the class LogMapperTest method toNewEntityWhenLogTypeIsReceiveSalesReportAndTypeRefIsNotFilledIn.

@Test
public void toNewEntityWhenLogTypeIsReceiveSalesReportAndTypeRefIsNotFilledIn() throws Exception {
    // data set
    Date dateReceived = new Date();
    String senderOrReceiver = "BEL";
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.SUCCESSFUL;
    String destination = "destination";
    ExchangeLogType input = new ExchangeLogType();
    input.setType(LogType.RECEIVE_SALES_REPORT);
    input.setDateRecieved(dateReceived);
    input.setSenderReceiver(senderOrReceiver);
    input.setStatus(status);
    input.setIncoming(true);
    input.setDestination(destination);
    String username = "stainii";
    // execute
    ExchangeLog result = LogMapper.toNewEntity(input, username);
    // assert
    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());
    assertTrue(result.getTransferIncoming());
    assertEquals(LogType.RECEIVE_SALES_REPORT, result.getType());
    assertEquals(destination, result.getDestination());
}
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)

Aggregations

ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)27 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)21 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)21 Test (org.junit.Test)21 Date (java.util.Date)20 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)11 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)10 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)7 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)4 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)3 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)3 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)3 ArrayList (java.util.ArrayList)3 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)2 SendSalesReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesReportRequest)1 SendSalesResponseRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesResponseRequest)1 UpdateLogStatusRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.UpdateLogStatusRequest)1 ExchangeHistoryListQuery (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery)1 ExchangeLogStatusHistoryType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType)1 PollStatus (eu.europa.ec.fisheries.schema.exchange.v1.PollStatus)1