Search in sources :

Example 36 with TurmaEfetiva

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

the class HibernateTurmaDAO method find.

@Override
public Turma find(Long id) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Turma turma = (Turma) session.get(Turma.class, id);
        if (turma instanceof TurmaEfetiva) {
            TurmaEfetiva turmaEfetiva = (TurmaEfetiva) turma;
            fillTurmaEfetiva(session, turmaEfetiva);
        }
        return turma;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateTurmaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("turmas.find.unique.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) Turma(com.tomasio.projects.trainning.model.Turma) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) HibernateException(org.hibernate.HibernateException) Session(org.hibernate.Session)

Example 37 with TurmaEfetiva

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

the class HibernateTurmaDAO method findAllTurmasEfetivasNotCancelOfResponsavelOrResponsavelApresentacao.

@Override
public List<TurmaEfetiva> findAllTurmasEfetivasNotCancelOfResponsavelOrResponsavelApresentacao(Date exercicio, Long organizacaoId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    SimpleDateFormat df = new SimpleDateFormat("yyyy");
    try {
        exercicio = df.parse(df.format(exercicio));
    } catch (ParseException ex) {
        Logger.getLogger(HibernateTurmaDAO.class.getName()).log(Level.SEVERE, null, ex);
    }
    try {
        // selecionar todas turmas da organizacao no ano
        @SuppressWarnings("unchecked") List<TurmaEfetiva> turmas = session.createQuery("from TurmaEfetiva t " + "where t.exercicio = :exercicio " + "and (t.responsavelId = :organizacaoId1 or t.responsavelApresentacaoId = :organizacaoId2)" + "and t.cancelado = false").setLong("organizacaoId1", organizacaoId).setLong("organizacaoId2", organizacaoId).setDate("exercicio", exercicio).list();
        Collections.sort(turmas, new TurmaEfetivaSort());
        return turmas;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateTurmaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("turmas.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) TurmaEfetivaSort(com.tomasio.projects.trainning.sort.TurmaEfetivaSort) HibernateException(org.hibernate.HibernateException) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Session(org.hibernate.Session)

Aggregations

TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)37 DAOException (com.tomasio.projects.trainning.exception.DAOException)33 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)32 ParseException (java.text.ParseException)27 Transactional (org.springframework.transaction.annotation.Transactional)23 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)22 CoreException (com.tomasio.projects.trainning.exeption.CoreException)16 SimpleDateFormat (java.text.SimpleDateFormat)14 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)12 Session (org.hibernate.Session)11 Indicacao (com.tomasio.projects.trainning.model.Indicacao)10 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)9 TurmaEfetivaDTO (com.tomasio.projects.trainning.dto.TurmaEfetivaDTO)9 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)9 Matricula (com.tomasio.projects.trainning.model.Matricula)8 HibernateException (org.hibernate.HibernateException)8 CancelamentoMatriculaDAO (com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO)7 MatriculaDAO (com.tomasio.projects.trainning.dao.MatriculaDAO)7 NotificacaoMatriculaDAO (com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO)7 CancelamentoMatricula (com.tomasio.projects.trainning.model.CancelamentoMatricula)7