Search in sources :

Example 1 with ExchangeHistoryListQuery

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.");
    }
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ArrayList(java.util.ArrayList) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) ExchangeHistoryListQuery(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery)

Example 2 with ExchangeHistoryListQuery

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 ");
    }
}
Also used : InputArgumentException(eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ExchangeModelException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException) HashSet(java.util.HashSet)

Aggregations

ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)2 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)2 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)2 ArrayList (java.util.ArrayList)2 ExchangeHistoryListQuery (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery)1 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)1 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)1 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)1 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)1 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)1 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1