Search in sources :

Example 6 with ExchangeDaoException

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

the class ExchangeLogDaoBean method getExchangeLogByTypesRefAndGuid.

@Override
public List<ExchangeLog> getExchangeLogByTypesRefAndGuid(String typeRefGuid, List<TypeRefType> types) throws ExchangeDaoException {
    try {
        TypedQuery<ExchangeLog> namedQuery = em.createNamedQuery(ExchangeConstants.LOG_BY_TYPE_REF_AND_GUID, ExchangeLog.class);
        namedQuery.setParameter("typeRefGuid", typeRefGuid);
        namedQuery.setParameter("typeRefTypes", types);
        return namedQuery.getResultList();
    } catch (NoResultException e) {
        LOG.error("[ Error when getting entity by type ref ID. ] {}", e.getMessage());
        throw new NoEntityFoundException("[ Error when getting entity by type ref ID. ]");
    } catch (Exception e) {
        LOG.error("[ Error when getting entity by type ref ID. ] {}", e.getMessage());
        throw new ExchangeDaoException("[ Error when getting entity by type ref ID. ] ");
    }
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException) NoResultException(javax.persistence.NoResultException) 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)

Example 7 with ExchangeDaoException

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

the class ExchangeLogDaoBean method updateLog.

@Override
public ExchangeLog updateLog(ExchangeLog entity) throws ExchangeDaoException {
    try {
        em.merge(entity);
        em.flush();
        return entity;
    } catch (Exception e) {
        LOG.error("[ Error when updating entity ] {}", e.getMessage());
        throw new ExchangeDaoException("[ Error when updating entity ]", e);
    }
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) 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)

Example 8 with ExchangeDaoException

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

the class ExchangeLogDaoBean method getExchangeLogStatusHistory.

@Override
public List<ExchangeLogStatus> getExchangeLogStatusHistory(String sql, ExchangeHistoryListQuery searchQuery) throws ExchangeDaoException {
    try {
        LOG.debug("SQL query for status history " + sql);
        TypedQuery<ExchangeLogStatus> query = em.createQuery(sql, ExchangeLogStatus.class);
        if (searchQuery.getStatus() != null && !searchQuery.getStatus().isEmpty()) {
            query.setParameter("status", searchQuery.getStatus());
        }
        if (searchQuery.getType() != null && !searchQuery.getType().isEmpty()) {
            query.setParameter("type", searchQuery.getType());
        }
        if (searchQuery.getTypeRefDateFrom() != null) {
            Date from = searchQuery.getTypeRefDateFrom();
            query.setParameter("from", from);
        }
        if (searchQuery.getTypeRefDateTo() != null) {
            Date to = searchQuery.getTypeRefDateTo();
            query.setParameter("to", to);
        }
        return query.getResultList();
    } catch (IllegalArgumentException e) {
        LOG.error("[ Error getting exchangelog status list ] " + e.getMessage());
        throw new ExchangeDaoException("[ Error when getting search list ] ");
    } catch (Exception e) {
        LOG.error("[ Error getting exchangelog status list " + e.getMessage());
        throw new ExchangeDaoException("[ Error when getting search list ] ");
    }
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) Date(java.util.Date) 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) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)

Example 9 with ExchangeDaoException

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

the class ServiceRegistryDaoBean method updateService.

// updateService
@Override
public Service updateService(Service entity) throws ExchangeDaoException {
    try {
        em.merge(entity);
        em.flush();
        return entity;
    } catch (IllegalArgumentException e) {
        LOG.error("[ Error when updating entity ] {}", e.getMessage());
        throw new ExchangeDaoException("[ Error when updating entity ]");
    } catch (Exception e) {
        LOG.error("[ Error when updating entity ] {}", e.getMessage());
        throw new ExchangeDaoException("[ Error when updating entity ]");
    }
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) EntityExistsException(javax.persistence.EntityExistsException) NoResultException(javax.persistence.NoResultException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException)

Example 10 with ExchangeDaoException

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

the class ServiceRegistryDaoBean method getServicesByTypes.

@Override
public List<Service> getServicesByTypes(List<PluginType> pluginTypes) throws ExchangeDaoException {
    try {
        TypedQuery<Service> query = em.createNamedQuery(ExchangeConstants.SERVICE_FIND_BY_TYPES, Service.class);
        query.setParameter("types", pluginTypes);
        return query.getResultList();
    } catch (IllegalArgumentException e) {
        LOG.error("[ Error when getting service list by types ] {}", e.getMessage());
        throw new ExchangeDaoException("[ Error when getting service list by types ] ");
    } catch (Exception e) {
        LOG.error("[ Error when getting service list by types ] {}", e.getMessage());
        throw new ExchangeDaoException("[ Error when getting service list by types] ");
    }
}
Also used : ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) Service(eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service) EntityExistsException(javax.persistence.EntityExistsException) NoResultException(javax.persistence.NoResultException) ExchangeDaoException(eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException) NoEntityFoundException(eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException)

Aggregations

ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)22 NoEntityFoundException (eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException)10 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)10 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)9 NoResultException (javax.persistence.NoResultException)9 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)8 ArrayList (java.util.ArrayList)6 PersistenceException (javax.persistence.PersistenceException)5 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)4 EntityExistsException (javax.persistence.EntityExistsException)4 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)3 Service (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.Service)3 ServiceSetting (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceSetting)3 UnsentMessage (eu.europa.ec.fisheries.uvms.exchange.entity.unsent.UnsentMessage)3 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)2 UnsentMessageType (eu.europa.ec.fisheries.schema.exchange.v1.UnsentMessageType)2 ServiceCapability (eu.europa.ec.fisheries.uvms.exchange.entity.serviceregistry.ServiceCapability)2 ExchangeLogStatusHistoryType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType)1 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)1 LogWithRawMsgAndType (eu.europa.ec.fisheries.schema.exchange.v1.LogWithRawMsgAndType)1