Search in sources :

Example 16 with Conclusao

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

the class HibernateConclusaoDAO method remove.

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

Example 17 with Conclusao

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

the class HibernateCertificadoConclusaoDAO method hasCertificadosConclusaoByTurma.

@Override
public boolean hasCertificadosConclusaoByTurma(Long turmaId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Long countCertificadoConclusao = 0L;
        // buscar todas as conclusoes da turma
        @SuppressWarnings("unchecked") List<Conclusao> conclusoes = session.createQuery("from Conclusao conclusao " + "where conclusao.matricula.turma.id=:turmaId " + "and conclusao.comAproveitamento=:aproveitamento").setLong("turmaId", turmaId).setBoolean("aproveitamento", true).list();
        @SuppressWarnings("unused") List<CertificadoConclusao> certificados = new ArrayList<CertificadoConclusao>();
        // loop nas conclusoes pegando as que possuem certificado
        for (Conclusao conclusao : conclusoes) {
            @SuppressWarnings("unchecked") List<CertificadoConclusao> certificadosConclusao = session.createQuery("" + "from CertificadoConclusao c " + "where c.conclusao.id=:conclusaoId ").setLong("conclusaoId", conclusao.getId()).list();
            for (@SuppressWarnings("unused") CertificadoConclusao certificado : certificadosConclusao) {
                countCertificadoConclusao++;
            }
        }
        return countCertificadoConclusao > 0;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateMatriculaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("certificadoConclusao.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CertificadoConclusao(com.tomasio.projects.trainning.model.CertificadoConclusao) HibernateException(org.hibernate.HibernateException) Conclusao(com.tomasio.projects.trainning.model.Conclusao) CertificadoConclusao(com.tomasio.projects.trainning.model.CertificadoConclusao) ArrayList(java.util.ArrayList) Session(org.hibernate.Session)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)17 Conclusao (com.tomasio.projects.trainning.model.Conclusao)17 CertificadoConclusao (com.tomasio.projects.trainning.model.CertificadoConclusao)12 ConclusaoDAO (com.tomasio.projects.trainning.dao.ConclusaoDAO)10 CertificadoConclusaoDAO (com.tomasio.projects.trainning.dao.CertificadoConclusaoDAO)9 CoreException (com.tomasio.projects.trainning.exeption.CoreException)9 Transactional (org.springframework.transaction.annotation.Transactional)9 CertificadoConclusaoDTO (com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO)7 ConclusaoDTO (com.tomasio.projects.trainning.dto.ConclusaoDTO)7 Session (org.hibernate.Session)7 HibernateException (org.hibernate.HibernateException)6 ArrayList (java.util.ArrayList)4 ParseException (java.text.ParseException)3 SimpleDateFormat (java.text.SimpleDateFormat)3 Criteria (org.hibernate.Criteria)2 CursoDAO (com.tomasio.projects.trainning.dao.CursoDAO)1 HibernateConclusaoDAO (com.tomasio.projects.trainning.dao.HibernateConclusaoDAO)1 HibernateCursoDAO (com.tomasio.projects.trainning.dao.HibernateCursoDAO)1 HibernatePessoaDAO (com.tomasio.projects.trainning.dao.HibernatePessoaDAO)1 PessoaDAO (com.tomasio.projects.trainning.dao.PessoaDAO)1