Search in sources :

Example 1 with ExchangeSearchField

use of eu.europa.ec.fisheries.uvms.exchange.search.ExchangeSearchField in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogDaoBean method getExchangeLogListPaginated.

@Override
public List<ExchangeLog> getExchangeLogListPaginated(Integer page, Integer listSize, String sql, List<SearchValue> searchKeyValues) throws ExchangeDaoException {
    try {
        LOG.debug("SQL QUERY IN LIST PAGINATED: " + sql);
        TypedQuery<ExchangeLog> query = em.createQuery(sql, ExchangeLog.class);
        HashMap<ExchangeSearchField, List<SearchValue>> orderedValues = SearchFieldMapper.combineSearchFields(searchKeyValues);
        setQueryParameters(query, orderedValues);
        query.setFirstResult(listSize * (page - 1));
        query.setMaxResults(listSize);
        return query.getResultList();
    } catch (IllegalArgumentException e) {
        LOG.error("[ Error getting exchangelog list paginated ] {}", e.getMessage());
        throw new ExchangeDaoException("[ Error when getting list ] ");
    } catch (Exception e) {
        LOG.error("[ Error getting exchangelog list paginated ]  {}", e.getMessage());
        throw new ExchangeDaoException("[ Error when getting list ] ");
    }
}
Also used : ExchangeSearchField(eu.europa.ec.fisheries.uvms.exchange.search.ExchangeSearchField) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) ArrayList(java.util.ArrayList) List(java.util.List) NoResultException(javax.persistence.NoResultException) NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) PersistenceException(javax.persistence.PersistenceException) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)

Aggregations

ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)1 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)1 NoEntityFoundException (eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException)1 ExchangeSearchField (eu.europa.ec.fisheries.uvms.exchange.search.ExchangeSearchField)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 NoResultException (javax.persistence.NoResultException)1 PersistenceException (javax.persistence.PersistenceException)1