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"));
}
}
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"));
}
}
Aggregations