Search in sources :

Example 6 with TurmaEfetivaSort

use of com.tomasio.projects.trainning.sort.TurmaEfetivaSort 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

DAOException (com.tomasio.projects.trainning.exception.DAOException)6 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)6 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)6 TurmaEfetivaSort (com.tomasio.projects.trainning.sort.TurmaEfetivaSort)6 ParseException (java.text.ParseException)6 SimpleDateFormat (java.text.SimpleDateFormat)6 HibernateException (org.hibernate.HibernateException)6 Session (org.hibernate.Session)6 Date (java.util.Date)1 Criteria (org.hibernate.Criteria)1 Disjunction (org.hibernate.criterion.Disjunction)1