Search in sources :

Example 16 with Matricula

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

the class HibernateMatriculaDAO method findAllInstrutores.

@SuppressWarnings("unchecked")
private List<Matricula> findAllInstrutores(Map<Object, Object> params) throws DAOException {
    Long cursoId = (Long) params.get("cursoId");
    Long turmaId = (Long) params.get("turmaId");
    Long pessoaId = (Long) params.get("pessoaId");
    Session session = sessionFactory.getCurrentSession();
    try {
        Criteria criteria = session.createCriteria(MatriculaInstrutor.class);
        criteria.createAlias("pessoa", "p");
        criteria.createAlias("turma", "t");
        criteria.createAlias("t.curso", "c");
        if (cursoId != null && cursoId > 0L) {
            criteria.add(Restrictions.eq("c.id", cursoId));
        }
        if (turmaId != null && turmaId > 0L) {
            criteria.add(Restrictions.eq("t.id", turmaId));
        }
        if (pessoaId != null && pessoaId > 0L) {
            criteria.add(Restrictions.eq("p.id", pessoaId));
        }
        criteria.addOrder(Order.asc("c.codigo"));
        criteria.addOrder(Order.asc("p.antiguidade"));
        criteria.addOrder(Order.asc("p.nome"));
        List<Matricula> matriculas = criteria.list();
        return matriculas;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateMatriculaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("matriculas.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) Matricula(com.tomasio.projects.trainning.model.Matricula) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session)

Example 17 with Matricula

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

the class ImportTurmasImplEfetivasFromTabelao method recuperarMatriculas.

private void recuperarMatriculas(int codTabelao, TurmaEfetiva turmaCriada, Connection conn) {
    try {
        IndicacaoDAO indicacaoDAO = new HibernateIndicacaoDAO();
        OrganizacaoDAO organizacaoDAO = new HibernateOrganizacaoDAO();
        PessoaDAO pessoaDAO = new HibernatePessoaDAO();
        MatriculaDAO matriculaDAO = new HibernateMatriculaDAO();
        Statement stm = conn.createStatement();
        ResultSet rs = stm.executeQuery("select * from indicacoes where codTabelao=" + codTabelao);
        while (rs.next()) {
            String cpf = rs.getString("cpf");
            boolean matriculado = rs.getBoolean("matriculado");
            ;
            if (!matriculado) {
                continue;
            }
            Pessoa pessoa = ImportHelper.findPessoa(cpf, conn);
            if (pessoa == null) {
                System.out.println("MATRICULA NÃO IMPORTADA: " + turmaCriada.getCurso().getCodigo() + " - " + turmaCriada.getNumeroTurma() + " ->" + cpf);
                continue;
            }
            Matricula matricula = new MatriculaAluno();
            matricula.setTurma(turmaCriada);
            matricula.setPessoa(pessoa);
            matriculaDAO.create(matricula);
        }
    } catch (SQLException ex) {
        Logger.getLogger(ImportTurmasImplEfetivasFromTabelao.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DAOException ex) {
        Logger.getLogger(ImportTurmasImplEfetivasFromTabelao.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : HibernatePessoaDAO(com.tomasio.projects.trainning.dao.HibernatePessoaDAO) PessoaDAO(com.tomasio.projects.trainning.dao.PessoaDAO) Matricula(com.tomasio.projects.trainning.model.Matricula) HibernateOrganizacaoDAO(com.tomasio.projects.trainning.dao.HibernateOrganizacaoDAO) Pessoa(com.tomasio.projects.trainning.model.Pessoa) IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) HibernateIndicacaoDAO(com.tomasio.projects.trainning.dao.HibernateIndicacaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) OrganizacaoDAO(com.tomasio.projects.trainning.dao.OrganizacaoDAO) HibernateOrganizacaoDAO(com.tomasio.projects.trainning.dao.HibernateOrganizacaoDAO) MatriculaAluno(com.tomasio.projects.trainning.model.MatriculaAluno) HibernateMatriculaDAO(com.tomasio.projects.trainning.dao.HibernateMatriculaDAO) HibernateMatriculaDAO(com.tomasio.projects.trainning.dao.HibernateMatriculaDAO) MatriculaDAO(com.tomasio.projects.trainning.dao.MatriculaDAO) HibernateIndicacaoDAO(com.tomasio.projects.trainning.dao.HibernateIndicacaoDAO) HibernatePessoaDAO(com.tomasio.projects.trainning.dao.HibernatePessoaDAO)

Example 18 with Matricula

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

the class HibernateMatriculaDAO method findAllAlunosApresentadosNaoConcluidos.

@SuppressWarnings("unchecked")
@Override
public List<Matricula> findAllAlunosApresentadosNaoConcluidos(Long turmaId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        // busca os matriculados da turma
        List<Matricula> matriculas = session.createQuery("from Matricula matricula where matricula.turma.id=:turma_id order by matricula.pessoa.nome").setLong("turma_id", turmaId).list();
        List<Matricula> result = new ArrayList<Matricula>();
        for (Matricula matricula : matriculas) {
            // verifica se apresentado comparecimento
            Long count = (Long) session.createQuery("select count(*) from  Apresentacao apresentacao " + "where apresentacao.matricula.id=:matricula_id ").setLong("matricula_id", matricula.getId()).uniqueResult();
            if (count > 0) {
                // verifica se já foi feita a conclusão
                Long count2 = (Long) session.createQuery("select count(*) from  Conclusao conclusao " + "where conclusao.matricula.id=:matricula_id ").setLong("matricula_id", matricula.getId()).uniqueResult();
                if (count2 <= 0) {
                    // nao acho conclusão, logo conclusao por fazer, insere na lista
                    result.add(matricula);
                }
            }
        }
        return result;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateMatriculaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("matriculas.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) Matricula(com.tomasio.projects.trainning.model.Matricula) ArrayList(java.util.ArrayList) Session(org.hibernate.Session)

Example 19 with Matricula

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

the class AtividadesEnsinoServiceSimpleImpl method findAllMatriculasAlunosDaOM.

@Override
@Transactional(readOnly = true)
public MatriculaDTO[] findAllMatriculasAlunosDaOM(Long organizacaoId, Date exercicio, String search) {
    MatriculaDAO dao = factory.getMatriculaDAO();
    MatriculaDTO[] matriculasArray = null;
    try {
        List<Matricula> matriculas = dao.findAllAlunosDaOM(organizacaoId, exercicio, search);
        if (matriculas != null) {
            matriculasArray = new MatriculaDTO[matriculas.size()];
            for (int i = 0; i < matriculas.size(); i++) {
                matriculasArray[i] = matriculas.get(i).createDTOWithoutDependencies();
            }
        }
    } 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 matriculasArray;
}
Also used : PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) NotificacaoMatriculaDTO(com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO) MatriculaDTO(com.tomasio.projects.trainning.dto.MatriculaDTO) CancelamentoMatriculaDTO(com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CancelamentoMatriculaDAO(com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO) MatriculaDAO(com.tomasio.projects.trainning.dao.MatriculaDAO) NotificacaoMatriculaDAO(com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) CancelamentoMatricula(com.tomasio.projects.trainning.model.CancelamentoMatricula) Matricula(com.tomasio.projects.trainning.model.Matricula) NotificacaoMatricula(com.tomasio.projects.trainning.model.NotificacaoMatricula) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) 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 20 with Matricula

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

the class AtividadesEnsinoServiceSimpleImpl method findMatriculaByIndicacaoId.

@Override
@Transactional(readOnly = true)
public MatriculaDTO findMatriculaByIndicacaoId(Long indicacaoId) {
    MatriculaDAO dao = factory.getMatriculaDAO();
    Matricula matricula = null;
    try {
        matricula = dao.findByIndicacaoId(indicacaoId);
    } 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());
    }
    if (matricula != null) {
        return matricula.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CancelamentoMatriculaDAO(com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO) MatriculaDAO(com.tomasio.projects.trainning.dao.MatriculaDAO) NotificacaoMatriculaDAO(com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) CancelamentoMatricula(com.tomasio.projects.trainning.model.CancelamentoMatricula) Matricula(com.tomasio.projects.trainning.model.Matricula) NotificacaoMatricula(com.tomasio.projects.trainning.model.NotificacaoMatricula) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Matricula (com.tomasio.projects.trainning.model.Matricula)31 DAOException (com.tomasio.projects.trainning.exception.DAOException)29 MatriculaDAO (com.tomasio.projects.trainning.dao.MatriculaDAO)24 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)22 CancelamentoMatriculaDAO (com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO)21 NotificacaoMatriculaDAO (com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO)21 CancelamentoMatricula (com.tomasio.projects.trainning.model.CancelamentoMatricula)21 NotificacaoMatricula (com.tomasio.projects.trainning.model.NotificacaoMatricula)21 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)21 Transactional (org.springframework.transaction.annotation.Transactional)21 ParseException (java.text.ParseException)19 CoreException (com.tomasio.projects.trainning.exeption.CoreException)18 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)9 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)9 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)8 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)7 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)7 NotificacaoMatriculaDTO (com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO)7 PreMatriculaDTO (com.tomasio.projects.trainning.dto.PreMatriculaDTO)7 Indicacao (com.tomasio.projects.trainning.model.Indicacao)7