Search in sources :

Example 1 with MatriculaInstrutor

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

the class AtividadesEnsinoServiceSimpleImpl method updateMatricula.

@Override
@Transactional
public void updateMatricula(MatriculaDTO matricula) {
    MatriculaDAO dao = factory.getMatriculaDAO();
    Matricula _matricula = null;
    if (matricula != null) {
        if (matricula instanceof MatriculaAlunoDTO) {
            _matricula = new MatriculaAluno((MatriculaAlunoDTO) matricula);
        } else {
            _matricula = new MatriculaInstrutor((MatriculaInstrutorDTO) matricula);
        }
    }
    try {
        dao.update(_matricula);
    } 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 : PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) MatriculaAlunoDTO(com.tomasio.projects.trainning.dto.MatriculaAlunoDTO) MatriculaInstrutor(com.tomasio.projects.trainning.model.MatriculaInstrutor) PreMatriculaInstrutor(com.tomasio.projects.trainning.model.PreMatriculaInstrutor) 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) 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) 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with MatriculaInstrutor

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

the class AtividadesEnsinoServiceSimpleImpl method createMatricula.

@Override
@Transactional
public void createMatricula(MatriculaDTO[] matriculas) {
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    List<Matricula> matriculasList = new ArrayList<Matricula>();
    List<Indicacao> indicacoesList = new ArrayList<Indicacao>();
    Set<TurmaEfetiva> turmasList = new HashSet<TurmaEfetiva>();
    for (MatriculaDTO matricula : matriculas) {
        Matricula _matricula = null;
        if (matricula != null) {
            if (matricula instanceof MatriculaAlunoDTO) {
                _matricula = new MatriculaAluno((MatriculaAlunoDTO) matricula);
            } else {
                _matricula = new MatriculaInstrutor((MatriculaInstrutorDTO) matricula);
            }
        }
        matriculasList.add(_matricula);
        indicacoesList.add(_matricula.getIndicacao());
        turmasList.add(_matricula.getTurma());
    }
    try {
        matriculaDAO.create(matriculasList);
        for (Indicacao indicacao : indicacoesList) {
            indicacao.setMatriculado(true);
            indicacaoDAO.update(indicacao);
        }
        for (TurmaEfetiva turmaEfetiva : turmasList) {
            turmaEfetiva.setAtivado(true);
            turmaDAO.update(turmaEfetiva);
        }
    } 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 : PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) NotificacaoMatriculaDTO(com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO) MatriculaDTO(com.tomasio.projects.trainning.dto.MatriculaDTO) CancelamentoMatriculaDTO(com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO) 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) ArrayList(java.util.ArrayList) 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) HashSet(java.util.HashSet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with MatriculaInstrutor

use of com.tomasio.projects.trainning.model.MatriculaInstrutor 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)

Example 4 with MatriculaInstrutor

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

the class ImportTurmasImplEfetivasFromTabelao method recuperarInstrutores.

private void recuperarInstrutores(int codTabelao, TurmaEfetiva turmaCriada, Connection conn) {
    try {
        IndicacaoDAO indicacaoDAO = new HibernateIndicacaoDAO();
        OrganizacaoDAO organizacaoDAO = new HibernateOrganizacaoDAO();
        PessoaDAO pessoaDAO = new HibernatePessoaDAO();
        MatriculaDAO matriculaDAO = new HibernateMatriculaDAO();
        Statement stm = conn.createStatement();
        ResultSet rs = stm.executeQuery("select * from instrutores where codTabelao=" + codTabelao);
        while (rs.next()) {
            String local = rs.getString("LOCATUAL");
            String cpf = rs.getString("cpf");
            String codInstrutor = rs.getString("codInstrutores");
            List<Periodo> periodos = periodosInstrutor(codInstrutor, conn);
            // local = "DECEA";
            Organizacao organizacao = organizacaoDAO.findBySigla("DECEA");
            Pessoa pessoa = ImportHelper.findPessoa(cpf, conn);
            if (pessoa == null) {
                System.out.println("INSTRUTOR NÃO IMPORTADO: " + turmaCriada.getCurso().getCodigo() + " - " + turmaCriada.getNumeroTurma() + " ->" + cpf);
                continue;
            }
            for (Periodo periodo : periodos) {
                if ((organizacao != null) && (pessoa != null)) {
                    IndicacaoInstrutor indicacao = new IndicacaoInstrutor();
                    MatriculaInstrutor matricula = new MatriculaInstrutor();
                    indicacao.setDataCriacao(new Date());
                    indicacao.setOrganizacao(organizacao);
                    indicacao.setPeriodo(periodo);
                    indicacao.setPessoa(pessoa);
                    indicacao.setTurma(turmaCriada);
                    Long indicacaoId = indicacaoDAO.create(indicacao);
                    matricula.setIndicacao(indicacaoDAO.find(indicacaoId));
                    matricula.setPessoa(pessoa);
                    matricula.setTurma(turmaCriada);
                    matriculaDAO.create(matricula);
                }
            }
        }
    } catch (SQLException ex) {
        Logger.getLogger(ImportTurmasImplEfetivasFromTabelao.class.getName()).log(Level.SEVERE, null, ex);
    } catch (DAOException ex) {
        Logger.getLogger(ImportTurmasImplEfetivasFromTabelao.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : MatriculaInstrutor(com.tomasio.projects.trainning.model.MatriculaInstrutor) HibernatePessoaDAO(com.tomasio.projects.trainning.dao.HibernatePessoaDAO) PessoaDAO(com.tomasio.projects.trainning.dao.PessoaDAO) HibernateOrganizacaoDAO(com.tomasio.projects.trainning.dao.HibernateOrganizacaoDAO) IndicacaoInstrutor(com.tomasio.projects.trainning.model.IndicacaoInstrutor) Periodo(com.tomasio.projects.trainning.model.Periodo) Date(java.util.Date) Pessoa(com.tomasio.projects.trainning.model.Pessoa) IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) HibernateIndicacaoDAO(com.tomasio.projects.trainning.dao.HibernateIndicacaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) OrganizacaoDAO(com.tomasio.projects.trainning.dao.OrganizacaoDAO) HibernateOrganizacaoDAO(com.tomasio.projects.trainning.dao.HibernateOrganizacaoDAO) HibernateMatriculaDAO(com.tomasio.projects.trainning.dao.HibernateMatriculaDAO) Organizacao(com.tomasio.projects.trainning.model.Organizacao) HibernateMatriculaDAO(com.tomasio.projects.trainning.dao.HibernateMatriculaDAO) MatriculaDAO(com.tomasio.projects.trainning.dao.MatriculaDAO) HibernateIndicacaoDAO(com.tomasio.projects.trainning.dao.HibernateIndicacaoDAO) HibernatePessoaDAO(com.tomasio.projects.trainning.dao.HibernatePessoaDAO)

Aggregations

MatriculaDAO (com.tomasio.projects.trainning.dao.MatriculaDAO)4 DAOException (com.tomasio.projects.trainning.exception.DAOException)4 MatriculaInstrutor (com.tomasio.projects.trainning.model.MatriculaInstrutor)4 CancelamentoMatriculaDAO (com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO)3 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)3 NotificacaoMatriculaDAO (com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO)3 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)3 MatriculaAlunoDTO (com.tomasio.projects.trainning.dto.MatriculaAlunoDTO)3 MatriculaInstrutorDTO (com.tomasio.projects.trainning.dto.MatriculaInstrutorDTO)3 PreMatriculaAlunoDTO (com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO)3 PreMatriculaInstrutorDTO (com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO)3 CoreException (com.tomasio.projects.trainning.exeption.CoreException)3 CancelamentoMatricula (com.tomasio.projects.trainning.model.CancelamentoMatricula)3 Matricula (com.tomasio.projects.trainning.model.Matricula)3 MatriculaAluno (com.tomasio.projects.trainning.model.MatriculaAluno)3 NotificacaoMatricula (com.tomasio.projects.trainning.model.NotificacaoMatricula)3 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)3 PreMatriculaAluno (com.tomasio.projects.trainning.model.PreMatriculaAluno)3 PreMatriculaInstrutor (com.tomasio.projects.trainning.model.PreMatriculaInstrutor)3 ParseException (java.text.ParseException)3