Search in sources :

Example 1 with SolicitacaoPlamens

use of com.tomasio.projects.trainning.model.SolicitacaoPlamens in project trainning by fernandotomasio.

the class HibernateSolicitacaoPlamensDAO method create.

@Override
public Long create(SolicitacaoPlamensDTO solicitacao) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        SolicitacaoPlamens _solicitacao = new SolicitacaoPlamens(solicitacao);
        Long solicitacaoId = (Long) session.save(_solicitacao);
        return solicitacaoId;
    } catch (HibernateException e) {
        Logger.getLogger(TreinamentoSolicitadoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("solicitacoes.create.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) SolicitacaoPlamens(com.tomasio.projects.trainning.model.SolicitacaoPlamens) Session(org.hibernate.Session)

Example 2 with SolicitacaoPlamens

use of com.tomasio.projects.trainning.model.SolicitacaoPlamens in project trainning by fernandotomasio.

the class HibernateSolicitacaoPlamensDAO method findAll.

@SuppressWarnings("unchecked")
@Override
public List<SolicitacaoPlamensDTO> findAll(int ano, Long organizacaoProponenteId, Long organizacaoSolicitanteId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Criteria criteria = session.createCriteria(SolicitacaoPlamens.class);
        if (ano > 0) {
            criteria.add(Restrictions.eq("ano", ano));
        }
        if (organizacaoProponenteId != null && organizacaoProponenteId > 0L) {
            criteria.add(Restrictions.eq("organizacaoProponente.id", organizacaoProponenteId));
        }
        if (organizacaoSolicitanteId != null && organizacaoSolicitanteId > 0L) {
            criteria.add(Restrictions.eq("organizacaoSolicitante.id", organizacaoSolicitanteId));
        }
        criteria.addOrder(Order.asc("organizacaoSolicitante.id"));
        criteria.addOrder(Order.asc("prioridade"));
        List<SolicitacaoPlamens> solicitacoes = criteria.list();
        List<SolicitacaoPlamensDTO> dto = new ArrayList<SolicitacaoPlamensDTO>();
        for (SolicitacaoPlamens solicitacao : solicitacoes) {
            dto.add(solicitacao.createDTO());
        }
        return dto;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateTreinamentoSolicitadoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("solicitacoes.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) SolicitacaoPlamensDTO(com.tomasio.projects.trainning.dto.SolicitacaoPlamensDTO) HibernateException(org.hibernate.HibernateException) ArrayList(java.util.ArrayList) SolicitacaoPlamens(com.tomasio.projects.trainning.model.SolicitacaoPlamens) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 3 with SolicitacaoPlamens

use of com.tomasio.projects.trainning.model.SolicitacaoPlamens in project trainning by fernandotomasio.

the class HibernateSolicitacaoPlamensDAO method update.

@Override
public void update(SolicitacaoPlamensDTO solicitacao) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    SolicitacaoPlamens _solicitacao = new SolicitacaoPlamens(solicitacao);
    try {
        session.update(_solicitacao);
    } catch (HibernateException e) {
        Logger.getLogger(HibernateTreinamentoSolicitadoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("solicitacoes.update.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) SolicitacaoPlamens(com.tomasio.projects.trainning.model.SolicitacaoPlamens) Session(org.hibernate.Session)

Example 4 with SolicitacaoPlamens

use of com.tomasio.projects.trainning.model.SolicitacaoPlamens in project trainning by fernandotomasio.

the class HibernateSolicitacaoPlamensDAO method remove.

@Override
public void remove(Long id) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        SolicitacaoPlamens solicitacao = (SolicitacaoPlamens) session.get(SolicitacaoPlamens.class, id);
        session.delete(solicitacao);
    } catch (HibernateException e) {
        Logger.getLogger(HibernateTreinamentoSolicitadoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("solicitacoes.remove.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) SolicitacaoPlamens(com.tomasio.projects.trainning.model.SolicitacaoPlamens) Session(org.hibernate.Session)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)4 SolicitacaoPlamens (com.tomasio.projects.trainning.model.SolicitacaoPlamens)4 HibernateException (org.hibernate.HibernateException)4 Session (org.hibernate.Session)4 SolicitacaoPlamensDTO (com.tomasio.projects.trainning.dto.SolicitacaoPlamensDTO)1 ArrayList (java.util.ArrayList)1 Criteria (org.hibernate.Criteria)1