use of eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException 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);
}
}
use of eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException 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.exception.ExchangeDaoException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogModelBean method getExchangeLogRawXmlByGuid.
@Override
public LogWithRawMsgAndType getExchangeLogRawXmlByGuid(String guid) {
LogWithRawMsgAndType logWrapper = new LogWithRawMsgAndType();
try {
ExchangeLog exchangeLog = logDao.getExchangeLogByGuid(guid);
String rawMsg = exchangeLog.getTypeRefMessage();
TypeRefType type = exchangeLog.getTypeRefType();
logWrapper.setRawMsg(rawMsg);
logWrapper.setType(type);
} catch (ExchangeDaoException e) {
LOG.error("[ERROR] Couldn't find Log with the following GUID : [[" + guid + "]]", e);
}
return logWrapper;
}
use of eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceRegistryModelBean method getPluginSettings.
@Override
public List<SettingType> getPluginSettings(String serviceClassName) throws ExchangeModelException {
LOG.info("Get plugin settings:{}", serviceClassName);
List<SettingType> settings = new ArrayList<>();
try {
List<ServiceSetting> entityList = dao.getServiceSettings(serviceClassName);
for (ServiceSetting entity : entityList) {
settings.add(ServiceMapper.toModel(entity));
}
} catch (ExchangeDaoException e) {
LOG.error("[ Error when getting list. {}] {}", serviceClassName, e.getMessage());
throw new ExchangeModelException("[ Error when getting list. ]");
}
return settings;
}
use of eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException in project UVMS-ExchangeModule-APP by UnionVMS.
the class ServiceRegistryModelBean method updatePluginSettings.
@Override
public ServiceResponseType updatePluginSettings(String serviceClassName, SettingListType settings, String username) throws ExchangeModelException {
LOG.info("Update plugin settings for " + serviceClassName);
Service service = dao.getServiceByServiceClassName(serviceClassName);
if (service != null) {
List<ServiceSetting> newSettings = ServiceMapper.mapSettingsList(service, settings, username);
service.getServiceSettingList().addAll(newSettings);
dao.updateService(service);
return ServiceMapper.toServiceModel(service);
}
throw new ExchangeDaoException("No plugin found when update plugin settings");
}
Aggregations