Search in sources :

Example 1 with TypeRefType

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

the class ExchangeEventIncomingServiceBean method logRefIdByTypeExists.

@Override
public void logRefIdByTypeExists(@Observes @LogRefIdByTypeExists ExchangeMessageEvent event) {
    try {
        LogRefIdByTypeExistsRequest request = unMarshallMessage(event.getJmsMessage().getText(), LogRefIdByTypeExistsRequest.class);
        String refGuid = request.getRefGuid();
        List<TypeRefType> refTypes = request.getRefTypes();
        List<ExchangeLogStatusType> exchangeStatusHistoryList = exchangeLogModel.getExchangeLogsStatusHistories(refGuid, refTypes);
        LogRefIdByTypeExistsResponse response = new LogRefIdByTypeExistsResponse();
        if (CollectionUtils.isNotEmpty(exchangeStatusHistoryList)) {
            response.setRefGuid(exchangeStatusHistoryList.get(0).getTypeRef().getRefGuid());
        }
        String responseAsString = JAXBUtils.marshallJaxBObjectToString(response);
        producer.sendModuleResponseMessage(event.getJmsMessage(), responseAsString);
    } catch (ExchangeModelException | JAXBException | JMSException e) {
        fireExchangeFault(event, "Could not un-marshall " + LogRefIdByTypeExistsRequest.class, e);
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) LogRefIdByTypeExistsRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.LogRefIdByTypeExistsRequest) TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) LogRefIdByTypeExistsResponse(eu.europa.ec.fisheries.schema.exchange.module.v1.LogRefIdByTypeExistsResponse) JAXBException(javax.xml.bind.JAXBException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) JMSException(javax.jms.JMSException)

Example 2 with TypeRefType

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

the class ExchangeEventIncomingServiceBean method logIdByTypeExists.

@Override
public void logIdByTypeExists(@Observes @LogIdByTypeExists ExchangeMessageEvent event) {
    try {
        LogIdByTypeExistsRequest request = unMarshallMessage(event.getJmsMessage().getText(), LogIdByTypeExistsRequest.class);
        String messageGuid = request.getMessageGuid();
        TypeRefType refType = request.getRefType();
        ExchangeLogType exchangeLogByGuid = exchangeLogModel.getExchangeLogByGuidAndType(messageGuid, refType);
        LogIdByTypeExistsResponse response = new LogIdByTypeExistsResponse();
        if (exchangeLogByGuid != null) {
            response.setMessageGuid(exchangeLogByGuid.getGuid());
        }
        String responseAsString = JAXBUtils.marshallJaxBObjectToString(response);
        producer.sendModuleResponseMessage(event.getJmsMessage(), responseAsString);
    } catch (ExchangeModelException | JAXBException | JMSException e) {
        fireExchangeFault(event, "Could not un-marshall " + LogRefIdByTypeExistsRequest.class, e);
    }
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) LogIdByTypeExistsResponse(eu.europa.ec.fisheries.schema.exchange.module.v1.LogIdByTypeExistsResponse) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) JAXBException(javax.xml.bind.JAXBException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) JMSException(javax.jms.JMSException) LogIdByTypeExistsRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.LogIdByTypeExistsRequest)

Example 3 with TypeRefType

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

the class ExchangeLogServiceBean method getExchangeStatusHistoryList.

@Override
public List<ExchangeLogStatusType> getExchangeStatusHistoryList(ExchangeLogStatusTypeType status, TypeRefType type, Date from, Date to) throws ExchangeLogException {
    log.info("Get pollstatus list in service layer:{}", status);
    try {
        List<ExchangeLogStatusTypeType> statusList = new ArrayList<>();
        if (status != null) {
            statusList.add(status);
        }
        List<TypeRefType> typeList = new ArrayList<>();
        if (type != null) {
            typeList.add(type);
        }
        ExchangeHistoryListQuery query = new ExchangeHistoryListQuery();
        query.setTypeRefDateFrom(from);
        query.setTypeRefDateTo(to);
        query.getStatus().addAll(statusList);
        query.getType().addAll(typeList);
        List<ExchangeLogStatusType> pollStatusList = exchangeLogModel.getExchangeLogStatusHistoryByQuery(query);
        return pollStatusList;
    } catch (ExchangeModelException e) {
        throw new ExchangeLogException("Couldn't get exchange status history list.");
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ArrayList(java.util.ArrayList) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ExchangeHistoryListQuery(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery)

Example 4 with TypeRefType

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

the class LogMapperTest method toNewEntityWhenLogTypeIsSendEmail.

@Test
public void toNewEntityWhenLogTypeIsSendEmail() throws Exception {
    // data set
    String typeRefGuid = "trg";
    TypeRefType typeRefType = TypeRefType.UNKNOWN;
    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 fwdRule = "fantastic rules and where to find them";
    String recipient = "potter@wb.com";
    SendEmailType input = new SendEmailType();
    input.setType(LogType.SEND_EMAIL);
    input.setTypeRef(logRefType);
    input.setDateRecieved(dateReceived);
    input.setSenderReceiver(senderOrReceiver);
    input.setStatus(status);
    input.setFwdDate(fwdDate);
    input.setFwdRule(fwdRule);
    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(fwdRule, result.getFwdRule());
    assertEquals(recipient, result.getRecipient());
    assertFalse(result.getTransferIncoming());
    assertEquals(LogType.SEND_EMAIL, result.getType());
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) SendEmailType(eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType) 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 5 with TypeRefType

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

the class LogMapperTest method toNewEntityWhenLogTypeIsSendSalesResponse.

@Test
public void toNewEntityWhenLogTypeIsSendSalesResponse() throws Exception {
    // data set
    String typeRefGuid = "trg";
    TypeRefType typeRefType = TypeRefType.SALES_RESPONSE;
    Date dateReceived = new Date();
    String senderOrReceiver = "BEL";
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.SUCCESSFUL;
    String message = "<xml></xml>";
    String destination = "destination";
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(typeRefGuid);
    logRefType.setType(typeRefType);
    logRefType.setMessage(message);
    ExchangeLogType input = new ExchangeLogType();
    input.setType(LogType.SEND_SALES_RESPONSE);
    input.setTypeRef(logRefType);
    input.setDateRecieved(dateReceived);
    input.setSenderReceiver(senderOrReceiver);
    input.setStatus(status);
    input.setIncoming(false);
    input.setDestination(destination);
    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());
    assertFalse(result.getTransferIncoming());
    assertEquals(LogType.SEND_SALES_RESPONSE, result.getType());
    assertEquals(destination, result.getDestination());
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) 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)

Aggregations

TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)16 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)13 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)12 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)10 Date (java.util.Date)10 Test (org.junit.Test)10 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)9 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)5 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)3 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)3 ReceiveMovementType (eu.europa.ec.fisheries.schema.exchange.v1.ReceiveMovementType)2 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)2 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)2 ArrayList (java.util.ArrayList)2 JMSException (javax.jms.JMSException)2 JAXBException (javax.xml.bind.JAXBException)2 LogIdByTypeExistsRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.LogIdByTypeExistsRequest)1 LogIdByTypeExistsResponse (eu.europa.ec.fisheries.schema.exchange.module.v1.LogIdByTypeExistsResponse)1 LogRefIdByTypeExistsRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.LogRefIdByTypeExistsRequest)1 LogRefIdByTypeExistsResponse (eu.europa.ec.fisheries.schema.exchange.module.v1.LogRefIdByTypeExistsResponse)1