use of eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery 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.ExchangeHistoryListQuery 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 ");
}
}
Aggregations