Search in sources :

Example 11 with TypeRefType

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

the class ExchangeLogModelBean method getExchangeLogByGuidAndType.

@Override
public ExchangeLogType getExchangeLogByGuidAndType(String guid, TypeRefType typeRefType) throws ExchangeModelException {
    ExchangeLogType exchangeLogType;
    try {
        ExchangeLog exchangeLogByGuid = logDao.getExchangeLogByGuid(guid, typeRefType);
        exchangeLogType = LogMapper.toModel(exchangeLogByGuid);
    } 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 12 with TypeRefType

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

Example 13 with TypeRefType

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

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

the class ExchangeToRulesSyncMsgBean method getValidationFromRules.

public ExchangeLogWithValidationResults getValidationFromRules(String guid, TypeRefType type) {
    if (StringUtils.isEmpty(guid)) {
        return new ExchangeLogWithValidationResults();
    }
    ExchangeLogWithValidationResults resp = new ExchangeLogWithValidationResults();
    try {
        String getValidationsByGuidRequest = RulesModuleRequestMapper.createGetValidationsByGuidRequest(guid, type == null ? null : type.name());
        String correlationId = exchangeProducerBean.sendRulesMessage(getValidationsByGuidRequest);
        TextMessage validationRespMsg = exchangeConsumerBean.getMessage(correlationId, TextMessage.class);
        ValidationMessageTypeResponse validTypeRespFromRules = JAXBMarshaller.unmarshallTextMessage(validationRespMsg, ValidationMessageTypeResponse.class);
        List<ValidationMessageType> validationsListResponse = validTypeRespFromRules.getValidationsListResponse();
        if (CollectionUtils.isNotEmpty(validationsListResponse)) {
            for (ValidationMessageType validMsgFromRules : validationsListResponse) {
                resp.getValidationList().add(mapToLogValidationResult(validMsgFromRules));
            }
        }
    } catch (ConfigMessageException | MessageException | RulesModelMarshallException | ExchangeModelMarshallException e) {
        log.error("Error while trying to get Validation Results for RawMessage GUID from Rules!", e);
    }
    return resp;
}
Also used : ConfigMessageException(eu.europa.ec.fisheries.uvms.config.exception.ConfigMessageException) ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RulesModelMarshallException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException) MessageException(eu.europa.ec.fisheries.uvms.commons.message.api.MessageException) ConfigMessageException(eu.europa.ec.fisheries.uvms.config.exception.ConfigMessageException) ValidationMessageTypeResponse(eu.europa.ec.fisheries.schema.rules.rule.v1.ValidationMessageTypeResponse) ValidationMessageType(eu.europa.ec.fisheries.schema.rules.rule.v1.ValidationMessageType) ExchangeLogWithValidationResults(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogWithValidationResults) TextMessage(javax.jms.TextMessage)

Example 15 with TypeRefType

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

the class ExchangeLogModelBean method getExchangeLogStatusHistoryByQuery.

@Override
public List<ExchangeLogStatusType> getExchangeLogStatusHistoryByQuery(ExchangeHistoryListQuery query) throws ExchangeModelException {
    if (query == null) {
        throw new InputArgumentException("Exchange status list query is null");
    }
    try {
        List<ExchangeLogStatusType> logStatusHistoryList = new ArrayList<>();
        String sql = SearchFieldMapper.createSearchSql(query);
        List<ExchangeLogStatus> logList = logDao.getExchangeLogStatusHistory(sql, query);
        Set<String> uniqueExchangeLogGuid = new HashSet<>();
        Map<String, TypeRefType> logTypeMap = new HashMap<>();
        for (ExchangeLogStatus log : logList) {
            uniqueExchangeLogGuid.add(log.getLog().getGuid());
            logTypeMap.put(log.getLog().getGuid(), log.getLog().getTypeRefType());
        }
        // TODO not two db-calls?
        for (String guid : uniqueExchangeLogGuid) {
            ExchangeLog log = logDao.getExchangeLogByGuid(guid);
            ExchangeLogStatusType statusType = LogMapper.toStatusModel(log);
            logStatusHistoryList.add(statusType);
        }
        return logStatusHistoryList;
    } catch (ExchangeDaoException e) {
        LOG.error("[ Error when get Exchange log status history {}] {} ", query, e.getMessage());
        throw new ExchangeModelException("Error when get Exchange log status history ");
    }
}
Also used : InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) HashSet(java.util.HashSet)

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