Search in sources :

Example 31 with TurmaEfetiva

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

the class AtividadesEnsinoServiceSimpleImpl method updateTurmaEfetiva.

@Override
@Transactional
public void updateTurmaEfetiva(TurmaEfetivaDTO turma) {
    TurmaEfetiva _turma = new TurmaEfetiva(turma);
    TurmaDAO dao = factory.getTurmaDAO();
    try {
        dao.update(_turma);
    } 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());
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) CoreException(com.tomasio.projects.trainning.exeption.CoreException) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) 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 32 with TurmaEfetiva

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

the class PlanningServiceSimpleImpl method findAllTurmasEfetivas.

@Override
@Transactional(readOnly = true)
public TurmaEfetivaDTO[] findAllTurmasEfetivas(Date exercicio, Long planoId, Long cursoId, Long responsavelId, Long organizacaoGestoraId, StatusTurmaEfetiva status) {
    TurmaDAO dao = factory.getTurmaDAO();
    TurmaEfetivaDTO[] turmasArray = null;
    try {
        List<TurmaEfetiva> turmas = dao.findAllTurmasEfetivas(exercicio, planoId, cursoId, responsavelId, organizacaoGestoraId, status);
        if (turmas != null) {
            turmasArray = new TurmaEfetivaDTO[turmas.size()];
            for (int i = 0; i < turmas.size(); i++) {
                turmasArray[i] = turmas.get(i).createDTOWithoutDependencies();
            }
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return turmasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 33 with TurmaEfetiva

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

the class HibernateTurmaDAO method findAllTurmasEfetivasNotCancel.

@Override
public List<TurmaEfetiva> findAllTurmasEfetivasNotCancel(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 = :organizacaoId " + "and t.cancelado = false").setLong("organizacaoId", 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)

Example 34 with TurmaEfetiva

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

the class HibernateTurmaDAO method findAllTurmasEfetivas.

private List<TurmaEfetiva> findAllTurmasEfetivas(Map<Object, Object> params) throws DAOException {
    Date exercicio = (Date) params.get("exercicio");
    Long cursoId = (Long) params.get("cursoId");
    Long responsavelId = (Long) params.get("responsavelId");
    Long organizacaoGestoraId = (Long) params.get("organizacaoGestoraId");
    Long planoId = (Long) params.get("planoId");
    String searchTerm = (String) params.get("searchTerm");
    params.get("status");
    Integer pageNumber = (Integer) params.get("pageNumber");
    Integer pageSize = (Integer) params.get("pageSize");
    SimpleDateFormat dfYear = new SimpleDateFormat("yyyy");
    Session session = sessionFactory.getCurrentSession();
    if (exercicio != null) {
        try {
            exercicio = dfYear.parse(dfYear.format(exercicio));
        } catch (ParseException ex) {
            Logger.getLogger(HibernateTurmaDAO.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    try {
        Criteria criteria = session.createCriteria(TurmaEfetiva.class);
        criteria.createAlias("curso", "c");
        if (exercicio != null) {
            criteria.add(Restrictions.eq("exercicio", exercicio));
        }
        if (cursoId != null && cursoId > 0L) {
            criteria.add(Restrictions.eq("c.id", cursoId));
        }
        if (responsavelId != null && responsavelId > 0L) {
            criteria.add(Restrictions.eq("responsavelId", responsavelId));
        }
        if (organizacaoGestoraId != null && organizacaoGestoraId > 0L) {
            criteria.add(Restrictions.eq("organizacaoGestoraId", organizacaoGestoraId));
        }
        if (planoId != null && planoId > 0L) {
            criteria.createAlias("c.plano", "plano");
            criteria.add(Restrictions.eq("plano.id", planoId));
        }
        if (searchTerm != null) {
            Disjunction or = Restrictions.disjunction();
            or.add(Restrictions.ilike("c.codigo", "%" + searchTerm + "%")).add(Restrictions.ilike("c.descricao", "%" + searchTerm + "%"));
            criteria.add(or);
        }
        criteria.addOrder(Order.asc("c.codigo"));
        criteria.addOrder(Order.asc("numeroTurma"));
        if (pageNumber != null && pageSize != null) {
            criteria.setFirstResult(pageNumber);
            criteria.setMaxResults(pageSize);
        }
        @SuppressWarnings("unchecked") List<TurmaEfetiva> turmas = criteria.list();
        for (TurmaEfetiva turmaEfetiva : turmas) {
            fillTurmaEfetiva(session, turmaEfetiva);
        }
        // for (TurmaEfetiva turma : turmas) {
        // System.out.println( turma.getId() + " - " + turma.getOrganizacaoGestoraId() + "- " +turma.getDataInicio() + " - "+ turma.getDataTermino());
        // }
        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 : 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) Criteria(org.hibernate.Criteria) Date(java.util.Date) DAOException(com.tomasio.projects.trainning.exception.DAOException) Disjunction(org.hibernate.criterion.Disjunction) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Session(org.hibernate.Session)

Example 35 with TurmaEfetiva

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

the class HibernateTurmaDAO method findAllTurmasEfetivasWithIndicacoesPendentes.

@Override
public List<TurmaEfetiva> findAllTurmasEfetivasWithIndicacoesPendentes(Date exercicio, List<Long> organizacoesIds) 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 {
        @SuppressWarnings("unchecked") List<TurmaEfetiva> turmas2 = session.createQuery("select distinct indicacao.turma from IndicacaoAluno indicacao " + "where indicacao.turma.exercicio >= :exercicio " + "and indicacao.organizacao.id in :organizacoesIds " + "and indicacao.turma.cancelado = false " + "and indicacao.matriculado = false " + "and indicacao.preMatriculado = false " + "and indicacao.turma.ativado = false " + "and indicacao.turma.preAtivado = false").setParameterList("organizacoesIds", organizacoesIds).setDate("exercicio", exercicio).list();
        ;
        // APÓS A COLOCAÇÃO DO CAMPO ATIVADO EM TURMA, OTMIZAR ESTA QUERY ADICIONANDO 'and indicacao.t.ativado = false and indicacao.t.preAtivado=false'
        // List<TurmaEfetiva> turmas = session.createQuery(
        // "select distinct t from TurmaEfetiva t join t.indicacoes i "
        // + "where t.exercicio >= :exercicio and i.organizacao.id in (:organizacoesIds) "
        // + "and t.id not in (select distinct t2.id from TurmaEfetiva t2 join t2.matriculas where t2.id=t.id) "
        // + "and t.cancelado = false "
        // + "and t.id not in (select distinct t3.id from TurmaEfetiva t3 join t3.preMatriculas where t3.id=t.id)")
        // .setParameterList("organizacoesIds", organizacoesIds)
        // .setDate("exercicio", exercicio)
        // .list();
        Collections.sort(turmas2, new TurmaEfetivaSort());
        return turmas2;
    } 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