use of eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException 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 ");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException in project UVMS-ExchangeModule-APP by UnionVMS.
the class UnsentModelBean method createMessage.
@Override
public String createMessage(UnsentMessageType message, String username) throws ExchangeModelException {
if (message == null) {
throw new InputArgumentException("No message to create");
}
try {
UnsentMessage entity = UnsentMessageMapper.toEntity(message, username);
UnsentMessage persistedEntity = dao.create(entity);
UnsentMessageType model = UnsentMessageMapper.toModel(persistedEntity);
return model.getMessageId();
} catch (ExchangeDaoException ex) {
LOG.error("[ Error when creating unsent message ] {}", ex.getMessage());
throw new ExchangeModelException("Error when creating unsent message ");
}
}
use of eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException in project UVMS-ExchangeModule-APP by UnionVMS.
the class UnsentModelBean method removeMessage.
@Override
public String removeMessage(String unsentMessageId) throws ExchangeModelException {
if (unsentMessageId == null) {
throw new InputArgumentException("No message to remove");
}
try {
UnsentMessage entity = dao.getByGuid(unsentMessageId);
if (entity != null) {
String guid = entity.getGuid();
dao.remove(entity);
return guid;
} else {
LOG.error("[ Error when removing unsent message ]");
throw new ExchangeModelException("Error when removing unsent message ");
}
} catch (ExchangeDaoException ex) {
LOG.error("[ Error when creating unsent message ] {}", ex.getMessage());
throw new ExchangeModelException("Error when creating unsent message ");
}
}
Aggregations