Search in sources :

Example 21 with TurmaPlanejadaDTO

use of com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO in project trainning by fernandotomasio.

the class HibernateTurmaDAO method findAllTurmasPlanejadas.

@Override
public List<TurmaPlanejadaDTO> findAllTurmasPlanejadas(Long planejamentoId, Long planoId, Long cursoId, Long responsavelId) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Criteria criteria = session.createCriteria(TurmaPlanejada.class);
        criteria.createAlias("itemPlanejamento", "item");
        criteria.createAlias("curso", "c");
        if (planejamentoId != null && planejamentoId > 0L) {
            criteria.add(Restrictions.eq("item.planejamento.id", planejamentoId));
        }
        if (cursoId != null && cursoId > 0L) {
            criteria.add(Restrictions.eq("curso.id", cursoId));
        }
        if (responsavelId != null && responsavelId > 0L) {
            criteria.add(Restrictions.eq("responsavelId", responsavelId));
        }
        if (planoId != null && planoId > 0L) {
            criteria.add(Restrictions.eq("c.plano.id", planoId));
        }
        criteria.addOrder(Order.asc("numeroTurma"));
        @SuppressWarnings("unchecked") List<TurmaPlanejada> turmas = criteria.list();
        List<TurmaPlanejadaDTO> dto = new ArrayList<TurmaPlanejadaDTO>();
        for (TurmaPlanejada turma : turmas) {
            dto.add(turma.createDTOWithoutDependencies());
        }
        return dto;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateTurmaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("turmas.find.list.error"));
    }
}
Also used : TurmaPlanejada(com.tomasio.projects.trainning.model.TurmaPlanejada) DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) ArrayList(java.util.ArrayList) Criteria(org.hibernate.Criteria) Session(org.hibernate.Session) TurmaPlanejadaDTO(com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO)

Aggregations

TurmaPlanejadaDTO (com.tomasio.projects.trainning.dto.TurmaPlanejadaDTO)21 FaseDTO (com.tomasio.projects.trainning.dto.FaseDTO)11 HashMap (java.util.HashMap)9 ArrayList (java.util.ArrayList)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)6 ItemPlanejamentoDTO (com.tomasio.projects.trainning.dto.ItemPlanejamentoDTO)6 StripItemPlanejamentoDTO (com.tomasio.projects.trainning.dto.StripItemPlanejamentoDTO)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Calendar (java.util.Calendar)5 List (java.util.List)5 DistribuicaoDTO (com.tomasio.projects.trainning.dto.DistribuicaoDTO)4 FolhaRostoDTO (com.tomasio.projects.trainning.dto.FolhaRostoDTO)4 Map (java.util.Map)4 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)4 AnotacaoDTO (com.tomasio.projects.trainning.dto.AnotacaoDTO)3 TreinamentoPlanejadoDTO (com.tomasio.projects.trainning.dto.TreinamentoPlanejadoDTO)3 TurmaDTO (com.tomasio.projects.trainning.dto.TurmaDTO)3 TurmaEfetivaDTO (com.tomasio.projects.trainning.dto.TurmaEfetivaDTO)3 ParseException (java.text.ParseException)3