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;
}
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;
}
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());
}
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;
}
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 ");
}
}
Aggregations