Search in sources :

Example 11 with Indicacao

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

the class AtividadesEnsinoServiceSimpleImpl method createPreMatricula.

@Override
@Transactional
public Long createPreMatricula(PreMatriculaDTO preMatricula) {
    PreMatriculaDAO preMatriculaDAO = factory.getPreMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    PreMatricula _preMatricula = null;
    if (preMatricula instanceof PreMatriculaAlunoDTO) {
        _preMatricula = new PreMatriculaAluno((PreMatriculaAlunoDTO) preMatricula);
    } else {
        _preMatricula = new PreMatriculaInstrutor((PreMatriculaInstrutorDTO) preMatricula);
    }
    Long id = null;
    try {
        Indicacao _indicacao = _preMatricula.getIndicacao();
        TurmaEfetiva _turma = _preMatricula.getTurma();
        id = preMatriculaDAO.create(_preMatricula);
        _indicacao.setPreMatriculado(true);
        _turma.setPreAtivado(true);
        indicacaoDAO.update(_indicacao);
        turmaDAO.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());
    }
    return id;
}
Also used : StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) Indicacao(com.tomasio.projects.trainning.model.Indicacao) PreMatriculaAluno(com.tomasio.projects.trainning.model.PreMatriculaAluno) PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) PreMatriculaInstrutor(com.tomasio.projects.trainning.model.PreMatriculaInstrutor) PreMatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with Indicacao

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

the class AtividadesEnsinoServiceSimpleImpl method removePreMatricula.

@Override
@Transactional
public void removePreMatricula(Long preMatriculaId) {
    PreMatriculaDAO preMatriculaDAO = factory.getPreMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    try {
        PreMatricula preMatricula = preMatriculaDAO.find(preMatriculaId);
        Indicacao indicacao = preMatricula.getIndicacao();
        TurmaEfetiva turma = preMatricula.getTurma();
        preMatriculaDAO.remove(preMatriculaId);
        indicacao.setPreMatriculado(false);
        indicacaoDAO.update(indicacao);
        if (hasPreMatriculas(turma.getId())) {
            turma.setPreAtivado(true);
        } else {
            turma.setPreAtivado(false);
        }
        turmaDAO.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 : IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) 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) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) Indicacao(com.tomasio.projects.trainning.model.Indicacao) 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) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with Indicacao

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

the class AtividadesEnsinoServiceSimpleImpl method alertaDeIndicacao.

@Override
@Transactional(readOnly = true)
public void alertaDeIndicacao(IndicacaoDTO indicacao, String chamada) {
    IndicacaoDAO dao = factory.getIndicacaoDAO();
    Indicacao _indicacao = null;
    if (indicacao != null) {
        // if (indicacao instanceof IndicacaoAlunoDTO) {
        _indicacao = new IndicacaoAluno((IndicacaoAlunoDTO) indicacao);
    // } else {
    // _indicacao = new IndicacaoInstrutor((IndicacaoInstrutorDTO) indicacao);
    // }
    }
    try {
        dao.alertaDeIndicacao(_indicacao, chamada);
    } catch (DAOException ex) {
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
    }
}
Also used : IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) IndicacaoAlunoDTO(com.tomasio.projects.trainning.dto.IndicacaoAlunoDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) IndicacaoAluno(com.tomasio.projects.trainning.model.IndicacaoAluno) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Indicacao(com.tomasio.projects.trainning.model.Indicacao) 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 14 with Indicacao

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

the class HibernateIndicacaoDAO method remove.

@Override
public void remove(Long id) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    Indicacao indicacao = find(id);
    try {
        session.delete(indicacao);
    } catch (HibernateException e) {
        Logger.getLogger(HibernateIndicacaoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException("Erro ao remover Indicacao!");
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) Indicacao(com.tomasio.projects.trainning.model.Indicacao) Session(org.hibernate.Session)

Example 15 with Indicacao

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

the class HibernateIndicacaoDAO method findAllAlunos.

@SuppressWarnings("unchecked")
@Override
public List<IndicacaoAluno> findAllAlunos(Long turmaId, Long organizacaoId, Long pessoaId, Date exercicio) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Criteria criteria = session.createCriteria(IndicacaoAluno.class);
        criteria.createAlias("turma", "t");
        if (turmaId != null) {
            criteria = criteria.add(Restrictions.eq("turma.id", turmaId));
        }
        if (organizacaoId != null) {
            criteria = criteria.add(Restrictions.eq("organizacao.id", organizacaoId));
        }
        if (pessoaId != null) {
            criteria = criteria.add(Restrictions.eq("pessoa.id", pessoaId));
        }
        if (exercicio != null) {
            SimpleDateFormat df = new SimpleDateFormat("yyyy");
            try {
                exercicio = df.parse(df.format(exercicio));
            } catch (ParseException ex) {
                Logger.getLogger(HibernateIndicacaoDAO.class.getName()).log(Level.SEVERE, null, ex);
            }
            criteria = criteria.add(Restrictions.eq("t.exercicio", exercicio));
        }
        List<IndicacaoAluno> indicacoes = criteria.list();
        for (Indicacao indicacao : indicacoes) {
            indicacao = proccessIndicacao(indicacao, session);
        }
        return indicacoes;
    } catch (HibernateException e) {
        Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("indicacoes.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) IndicacaoAluno(com.tomasio.projects.trainning.model.IndicacaoAluno) HibernateException(org.hibernate.HibernateException) Indicacao(com.tomasio.projects.trainning.model.Indicacao) Criteria(org.hibernate.Criteria) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Session(org.hibernate.Session)

Aggregations

Indicacao (com.tomasio.projects.trainning.model.Indicacao)25 DAOException (com.tomasio.projects.trainning.exception.DAOException)23 ParseException (java.text.ParseException)21 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)20 Transactional (org.springframework.transaction.annotation.Transactional)19 CoreException (com.tomasio.projects.trainning.exeption.CoreException)18 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)11 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)10 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)10 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)10 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)10 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 Matricula (com.tomasio.projects.trainning.model.Matricula)7 NotificacaoMatricula (com.tomasio.projects.trainning.model.NotificacaoMatricula)7 IndicacaoAluno (com.tomasio.projects.trainning.model.IndicacaoAluno)5 HibernateException (org.hibernate.HibernateException)5 Session (org.hibernate.Session)5