Search in sources :

Example 16 with Indicacao

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

the class HibernateIndicacaoDAO method findAllIndicacoesInstrutorByPessoaId.

@SuppressWarnings("unchecked")
@Override
public List<Indicacao> findAllIndicacoesInstrutorByPessoaId(Long pessoaId, Date exercicio) throws DAOException {
    SimpleDateFormat df = new SimpleDateFormat("yyyy");
    if (exercicio == null) {
        throw new IllegalArgumentException("Parâmetro exercício não pode ser nulo");
    }
    try {
        exercicio = df.parse(df.format(exercicio));
    } catch (ParseException ex) {
        Logger.getLogger(HibernateIndicacaoDAO.class.getName()).log(Level.SEVERE, null, ex);
    }
    Session session = sessionFactory.getCurrentSession();
    try {
        List<Indicacao> indicacoes = session.createQuery("from IndicacaoInstrutor indicacao " + "where indicacao.turma.id in (select turma.id from TurmaEfetiva turma where turma.exercicio = :exercicio) " + "and indicacao.pessoa.id = :pessoaId " + "order by indicacao.id").setDate("exercicio", exercicio).setLong("pessoaId", pessoaId).list();
        for (Indicacao indicacao : indicacoes) {
            indicacao = proccessIndicacao(indicacao, session);
        }
        return indicacoes;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateIndicacaoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("indicacoes.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) Indicacao(com.tomasio.projects.trainning.model.Indicacao) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Session(org.hibernate.Session)

Example 17 with Indicacao

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

the class HibernateIndicacaoDAO method find.

@Override
public Indicacao find(Long id) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        Indicacao indicacao = (Indicacao) session.get(Indicacao.class, id);
        indicacao = proccessIndicacao(indicacao, session);
        return indicacao;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateIndicacaoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("indicacoes.find.unique.error"));
    }
}
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 18 with Indicacao

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

the class HibernateIndicacaoDAO method findAllIndicacoesAlunoByPessoaId.

@SuppressWarnings("unchecked")
@Override
public List<Indicacao> findAllIndicacoesAlunoByPessoaId(Long pessoaId, Date exercicio) throws DAOException {
    SimpleDateFormat df = new SimpleDateFormat("yyyy");
    if (exercicio == null) {
        throw new IllegalArgumentException("Parâmetro exercício não pode ser nulo");
    }
    try {
        exercicio = df.parse(df.format(exercicio));
    } catch (ParseException ex) {
        Logger.getLogger(HibernateIndicacaoDAO.class.getName()).log(Level.SEVERE, null, ex);
    }
    Session session = sessionFactory.getCurrentSession();
    try {
        List<Indicacao> indicacoes = session.createQuery("from IndicacaoAluno indicacao " + "where indicacao.turma.id in (select turma.id from TurmaEfetiva turma where turma.exercicio = :exercicio) " + "and indicacao.pessoa.id = :pessoaId " + "order by indicacao.id ").setDate("exercicio", exercicio).setLong("pessoaId", pessoaId).list();
        for (Indicacao indicacao : indicacoes) {
            indicacao = proccessIndicacao(indicacao, session);
        }
        return indicacoes;
    } catch (HibernateException e) {
        Logger.getLogger(HibernateIndicacaoDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("indicacoes.find.list.error"));
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) Indicacao(com.tomasio.projects.trainning.model.Indicacao) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Session(org.hibernate.Session)

Example 19 with Indicacao

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

the class AtividadesEnsinoServiceSimpleImpl method travaDeIndicacao.

@Override
@Transactional(readOnly = true)
public void travaDeIndicacao(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.travaDeIndicacao(_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 20 with Indicacao

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

the class AtividadesEnsinoServiceSimpleImpl method createMatricula.

@Override
@Transactional
public Long createMatricula(MatriculaDTO matricula) {
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    Matricula _matricula = null;
    if (matricula != null) {
        if (matricula instanceof MatriculaAlunoDTO) {
            _matricula = new MatriculaAluno((MatriculaAlunoDTO) matricula);
        } else {
            _matricula = new MatriculaInstrutor((MatriculaInstrutorDTO) matricula);
        }
    }
    Long id = null;
    try {
        Indicacao _indicacao = _matricula.getIndicacao();
        TurmaEfetiva _turma = _matricula.getTurma();
        id = matriculaDAO.create(_matricula);
        _indicacao.setMatriculado(true);
        _turma.setAtivado(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 : MatriculaInstrutor(com.tomasio.projects.trainning.model.MatriculaInstrutor) PreMatriculaInstrutor(com.tomasio.projects.trainning.model.PreMatriculaInstrutor) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) CancelamentoMatricula(com.tomasio.projects.trainning.model.CancelamentoMatricula) Matricula(com.tomasio.projects.trainning.model.Matricula) NotificacaoMatricula(com.tomasio.projects.trainning.model.NotificacaoMatricula) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) Indicacao(com.tomasio.projects.trainning.model.Indicacao) PreMatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO) MatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.MatriculaInstrutorDTO) 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) PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) MatriculaAlunoDTO(com.tomasio.projects.trainning.dto.MatriculaAlunoDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) PreMatriculaAluno(com.tomasio.projects.trainning.model.PreMatriculaAluno) MatriculaAluno(com.tomasio.projects.trainning.model.MatriculaAluno) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CancelamentoMatriculaDAO(com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO) MatriculaDAO(com.tomasio.projects.trainning.dao.MatriculaDAO) NotificacaoMatriculaDAO(com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

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