use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogServiceBean method createExchangeLogStatusType.
private ExchangeLogStatusType createExchangeLogStatusType(ExchangeLogStatusTypeType logStatus, String logGuid) {
ExchangeLogStatusType exchangeLogStatusType = new ExchangeLogStatusType();
exchangeLogStatusType.setGuid(logGuid);
ArrayList statusHistoryList = new ArrayList();
ExchangeLogStatusHistoryType statusHistory = new ExchangeLogStatusHistoryType();
statusHistory.setStatus(logStatus);
statusHistoryList.add(statusHistory);
exchangeLogStatusType.getHistory().addAll(statusHistoryList);
return exchangeLogStatusType;
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType in project UVMS-ExchangeModule-APP by UnionVMS.
the class LogMapper method toStatusModel.
public static ExchangeLogStatusType toStatusModel(ExchangeLog exchangeLog) {
ExchangeLogStatusType model = new ExchangeLogStatusType();
if (exchangeLog.getType().equals(LogType.SEND_POLL)) {
model.setIdentifier(exchangeLog.getRecipient());
}
model.setGuid(exchangeLog.getGuid());
if (exchangeLog.getTypeRefType() != null) {
LogRefType logRefType = new LogRefType();
logRefType.setRefGuid(exchangeLog.getTypeRefGuid());
logRefType.setType(exchangeLog.getTypeRefType());
logRefType.setMessage(exchangeLog.getTypeRefMessage());
model.setTypeRef(logRefType);
}
if (exchangeLog.getStatusHistory() != null) {
List<ExchangeLogStatusHistoryType> historyModelList = new ArrayList<>();
for (ExchangeLogStatus history : exchangeLog.getStatusHistory()) {
ExchangeLogStatusHistoryType historyModel = new ExchangeLogStatusHistoryType();
historyModel.setStatus(history.getStatus());
historyModel.setTimestamp(history.getStatusTimestamp());
historyModelList.add(historyModel);
}
model.getHistory().addAll(historyModelList);
}
return model;
}
use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogModelBean method updateExchangeLogStatus.
@Override
public ExchangeLogType updateExchangeLogStatus(ExchangeLogStatusType status, String username) throws ExchangeModelException {
if (status == null || status.getGuid() == null || status.getGuid().isEmpty()) {
throw new InputArgumentException("No exchange log to update status");
}
if (status.getHistory() == null || status.getHistory().isEmpty() || status.getHistory().size() != 1) {
throw new InputArgumentException("Non valid status to update to");
}
try {
ExchangeLogStatusHistoryType updateStatus = status.getHistory().get(0);
ExchangeLog exchangeLog = logDao.getExchangeLogByGuid(status.getGuid());
List<ExchangeLogStatus> statusList = exchangeLog.getStatusHistory();
statusList.add(LogMapper.toNewStatusEntity(exchangeLog, updateStatus.getStatus(), username));
exchangeLog.setStatus(updateStatus.getStatus());
ExchangeLog retEntity = logDao.updateLog(exchangeLog);
ExchangeLogType retType = LogMapper.toModel(retEntity);
return retType;
} catch (ExchangeDaoException ex) {
LOG.error("[ Error when update status of Exchange log {} {}] {}", status, username, ex.getMessage());
throw new ExchangeModelException("Error when update status of Exchange log", ex);
}
}
Aggregations