Search in sources :

Example 1 with CertificadoConclusao

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

the class AtividadesEnsinoServiceSimpleImpl method findAllCertificadosConclusaoByConclusao.

@Override
@Transactional(readOnly = true)
public CertificadoConclusaoDTO[] findAllCertificadosConclusaoByConclusao(Long conclusaoId) {
    CertificadoConclusaoDAO dao = factory.getCertificadoConclusaoDAO();
    CertificadoConclusaoDTO[] certificadosArray = null;
    try {
        List<CertificadoConclusao> certificados = dao.findAllCertificadosConclusaoByConclusao(conclusaoId);
        if (certificados != null) {
            certificadosArray = new CertificadoConclusaoDTO[certificados.size()];
            for (int i = 0; i < certificados.size(); i++) {
                certificadosArray[i] = certificados.get(i).createDTO();
            }
        }
    } catch (DAOException ex) {
        ex.printStackTrace();
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
    }
    return certificadosArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CertificadoConclusaoDTO(com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO) CertificadoConclusao(com.tomasio.projects.trainning.model.CertificadoConclusao) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CertificadoConclusaoDAO(com.tomasio.projects.trainning.dao.CertificadoConclusaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with CertificadoConclusao

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

the class AtividadesEnsinoServiceSimpleImpl method createCertificadoConclusao.

@Override
@Transactional
public void createCertificadoConclusao(CertificadoConclusaoDTO certificadoConclusao) {
    CertificadoConclusaoDAO dao = factory.getCertificadoConclusaoDAO();
    Long id = null;
    CertificadoConclusao _certificadoConclusao = null;
    // cria um registro na tabela CancelamentoMatricula
    if (certificadoConclusao != null) {
        _certificadoConclusao = new CertificadoConclusao(certificadoConclusao);
    }
    try {
        id = dao.create(_certificadoConclusao);
    } catch (DAOException ex) {
        ex.printStackTrace();
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
    // throw new CoreException(ex.getMessage());
    }
// return id;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CertificadoConclusao(com.tomasio.projects.trainning.model.CertificadoConclusao) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CertificadoConclusaoDAO(com.tomasio.projects.trainning.dao.CertificadoConclusaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with CertificadoConclusao

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

the class HibernateCertificadoConclusaoDAO method findAllCertificadosConclusaoByTurma.

@Override
public List<CertificadoConclusao> findAllCertificadosConclusaoByTurma(Long turmaId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        // 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();
        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 (CertificadoConclusao certificado : certificadosConclusao) {
                certificados.add(certificado);
            }
        }
        return certificados;
    } catch (HibernateException ex) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        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)

Example 4 with CertificadoConclusao

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

the class HibernateCertificadoConclusaoDAO method findAllCertificadosConclusaoByPessoa.

@Override
public List<CertificadoConclusao> findAllCertificadosConclusaoByPessoa(Long pessoaId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        // buscar todas as conclusões de uma pessoa
        @SuppressWarnings("unchecked") List<Conclusao> conclusoes = session.createQuery("" + "from Conclusao c " + "where c.pessoa.id=:pessoaId ").setLong("pessoaId", pessoaId).list();
        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 (CertificadoConclusao certificado : certificadosConclusao) {
                certificados.add(certificado);
            }
        }
        return certificados;
    } catch (HibernateException ex) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex);
        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)

Example 5 with CertificadoConclusao

use of com.tomasio.projects.trainning.model.CertificadoConclusao 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)6 CertificadoConclusao (com.tomasio.projects.trainning.model.CertificadoConclusao)6 HibernateException (org.hibernate.HibernateException)4 Session (org.hibernate.Session)4 Conclusao (com.tomasio.projects.trainning.model.Conclusao)3 ArrayList (java.util.ArrayList)3 CertificadoConclusaoDAO (com.tomasio.projects.trainning.dao.CertificadoConclusaoDAO)2 CoreException (com.tomasio.projects.trainning.exeption.CoreException)2 ParseException (java.text.ParseException)2 Transactional (org.springframework.transaction.annotation.Transactional)2 CertificadoConclusaoDTO (com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO)1