use of eu.europa.ec.fisheries.schema.exchange.v1.LogRefType 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.LogRefType 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.LogRefType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method handleProcessedMovement.
// Async response handler for processed movements
@Override
public void handleProcessedMovement(@Observes @HandleProcessedMovementEvent ExchangeMessageEvent message) {
try {
ProcessedMovementResponse request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), ProcessedMovementResponse.class);
log.debug("Received processed movement from Rules:{}", request);
String username;
MovementRefType movementRefType = request.getMovementRefType();
SetReportMovementType orgRequest = request.getOrgRequest();
if (PluginType.MANUAL.equals(orgRequest.getPluginType())) {
username = request.getUsername();
} else {
username = orgRequest.getPluginName();
}
ExchangeLogType log = ExchangeLogMapper.getReceivedMovementExchangeLog(orgRequest, movementRefType.getMovementRefGuid(), movementRefType.getType().value(), username);
ExchangeLogType createdLog = exchangeLog.log(log, username);
LogRefType logTypeRef = createdLog.getTypeRef();
if (logTypeRef != null && logTypeRef.getType() == TypeRefType.POLL) {
String pollGuid = logTypeRef.getRefGuid();
pollEvent.fire(new NotificationMessage("guid", pollGuid));
}
} catch (ExchangeLogException | ExchangeModelMarshallException e) {
log.error(e.getMessage());
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.LogRefType 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.LogRefType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogMapper method getPollExchangeLog.
private static ExchangeLogType getPollExchangeLog(CommandType command) throws ExchangeLogException {
if (command.getPoll() == null) {
throw new ExchangeLogException("No poll");
}
// TODO fix in mobileterminal
SendPollType log = new SendPollType();
log.setType(LogType.SEND_POLL);
log.setDateRecieved(command.getTimestamp());
log.setRecipient(getRecipientOfPoll(command.getPoll().getPollReceiver()));
log.setSenderReceiver("System");
LogRefType logRefType = new LogRefType();
logRefType.setRefGuid(command.getPoll().getPollId());
logRefType.setType(TypeRefType.POLL);
log.setFwdDate(command.getTimestamp());
log.setTypeRef(logRefType);
return log;
}
Aggregations