use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogModelBean method setPollStatus.
@Override
public ExchangeLogType setPollStatus(PollStatus pollStatus, String username) throws ExchangeModelException {
ExchangeLogType log = null;
if (pollStatus == null || pollStatus.getPollGuid() == null) {
throw new InputArgumentException("No poll id to update status");
}
try {
List<ExchangeLog> exchangeLogByTypesRefAndGuid = logDao.getExchangeLogByTypesRefAndGuid(pollStatus.getPollGuid(), Collections.singletonList(TypeRefType.POLL));
if (CollectionUtils.isNotEmpty(exchangeLogByTypesRefAndGuid)) {
List<ExchangeLogStatus> statusList = exchangeLogByTypesRefAndGuid.get(0).getStatusHistory();
statusList.add(LogMapper.toNewStatusEntity(exchangeLogByTypesRefAndGuid.get(0), pollStatus.getStatus(), username));
exchangeLogByTypesRefAndGuid.get(0).setStatus(pollStatus.getStatus());
ExchangeLog retEntity = logDao.updateLog(exchangeLogByTypesRefAndGuid.get(0));
log = LogMapper.toModel(retEntity);
}
} catch (ExchangeDaoException ex) {
LOG.error("[ Error when set poll status {} {}] {}", pollStatus, username, ex.getMessage());
throw new ExchangeModelException("Error when update status of Exchange log ");
}
return log;
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogModelBean method getExchangeLogByGuid.
@Override
public ExchangeLogType getExchangeLogByGuid(String guid) throws ExchangeModelException {
ExchangeLogType exchangeLogType;
try {
ExchangeLog exchangeLog = logDao.getExchangeLogByGuid(guid, null);
exchangeLogType = LogMapper.toModel(exchangeLog);
// Enriches the "first level logs" with info related to the related logs.
enrichDtosWithRelatedLogsInfo(Collections.singletonList(exchangeLogType));
} 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.ExchangeLogType 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;
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogMapper method getSendMovementExchangeLog.
public static ExchangeLogType getSendMovementExchangeLog(SendMovementToPluginType sendReport) throws ExchangeLogException {
if (sendReport == null) {
throw new ExchangeLogException("No request");
}
SendMovementType log = new SendMovementType();
log.setDateRecieved(sendReport.getTimestamp());
log.setType(LogType.SEND_MOVEMENT);
LogRefType logRefType = new LogRefType();
logRefType.setRefGuid(sendReport.getMovement().getGuid());
logRefType.setType(TypeRefType.MOVEMENT);
log.setTypeRef(logRefType);
String senderReceiver = getSendMovementSenderReceiver(sendReport);
log.setSenderReceiver(senderReceiver);
// TODO send fwdDate, fwdRule and recipient from Rules
log.setFwdDate(sendReport.getFwdDate());
log.setFwdRule(sendReport.getFwdRule());
log.setRecipient(sendReport.getRecipient());
return log;
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType 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;
}
Aggregations