use of eu.europa.ec.fisheries.schema.exchange.v1.PollStatus 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.");
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.PollStatus 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.PollStatus in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventIncomingServiceBean method handleSetPollStatusAcknowledge.
private void handleSetPollStatusAcknowledge(ExchangePluginMethod method, String serviceClassName, AcknowledgeType ack) {
log.debug(method + " was acknowledged in " + serviceClassName);
try {
PollStatus updatedLog = exchangeLog.setPollStatus(ack.getMessageId(), ack.getPollStatus().getPollId(), ack.getPollStatus().getStatus(), serviceClassName);
// Long polling
pollEvent.fire(new NotificationMessage("guid", updatedLog.getPollGuid()));
} catch (ExchangeLogException e) {
log.error(e.getMessage());
}
}
use of eu.europa.ec.fisheries.schema.exchange.v1.PollStatus in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBean method setPollStatus.
@Override
public PollStatus setPollStatus(String jmsCorrelationId, String pollId, ExchangeLogStatusTypeType logStatus, String username) throws ExchangeLogException {
try {
// Remove the message from cache, because legancy implementation
logCache.acknowledged(jmsCorrelationId);
PollStatus pollStatus = new PollStatus();
pollStatus.setPollGuid(pollId);
pollStatus.setStatus(logStatus);
ExchangeLogType exchangeLogType = exchangeLogModel.setPollStatus(pollStatus, username);
pollStatus.setExchangeLogGuid(exchangeLogType.getGuid());
sendAuditLogMessageForUpdatePollStatus(pollId, username);
// For long polling
exchangeLogEvent.fire(new NotificationMessage("guid", pollStatus.getExchangeLogGuid()));
return pollStatus;
} catch (ExchangeModelMapperException e) {
throw new ExchangeLogException("Couldn't update status of exchange log");
} catch (ExchangeModelException e) {
throw new ExchangeLogException("Couldn't update status of exchange log");
}
}
Aggregations