Search in sources :

Example 41 with IndicacaoDAO

use of com.tomasio.projects.trainning.dao.IndicacaoDAO in project trainning by fernandotomasio.

the class ImportIndicacoesToPreMatricula method execute.

@Override
public void execute() {
    IndicacaoDAO indicacaoDAO = new HibernateIndicacaoDAO();
    PreMatriculaDAO preMatriculaDAO = new HibernatePreMatriculaDAO();
    Map<Long, List<IndicacaoAluno>> indicacoesAlunosMap = new HashMap<Long, List<IndicacaoAluno>>();
    Map<Long, List<IndicacaoInstrutor>> indicacoesInstrutoresMap = new HashMap<Long, List<IndicacaoInstrutor>>();
    int i = 0;
    try {
        List<PreMatricula> preMatriculas = preMatriculaDAO.findAll();
        for (PreMatricula preMatricula : preMatriculas) {
            Long turmaId = preMatricula.getTurma().getId();
            System.out.print(++i + " - ");
            if (preMatricula instanceof PreMatriculaAluno) {
                List<IndicacaoAluno> indicacoesAlunos = indicacoesAlunosMap.get(turmaId);
                if (indicacoesAlunos == null) {
                    indicacoesAlunos = indicacaoDAO.findAllAlunos(turmaId);
                    indicacoesAlunosMap.put(turmaId, indicacoesAlunos);
                }
                for (IndicacaoAluno indicacaoAluno : indicacoesAlunos) {
                    if (preMatricula.getPessoa().getId().equals(indicacaoAluno.getPessoa().getId())) {
                        preMatricula.setIndicacao(indicacaoAluno);
                        preMatriculaDAO.update(preMatricula);
                    }
                }
            } else {
                List<IndicacaoInstrutor> indicacoesInstrutores = indicacoesInstrutoresMap.get(turmaId);
                if (indicacoesInstrutores == null) {
                    indicacoesInstrutores = indicacaoDAO.findAllInstrutores(turmaId);
                    indicacoesInstrutoresMap.put(turmaId, indicacoesInstrutores);
                }
                for (IndicacaoInstrutor indicacaoInstrutor : indicacoesInstrutores) {
                    if (preMatricula.getPessoa().getId().equals(indicacaoInstrutor.getPessoa().getId())) {
                        preMatricula.setIndicacao(indicacaoInstrutor);
                        preMatriculaDAO.update(preMatricula);
                    }
                }
            }
            System.out.println("");
        }
        System.out.println(preMatriculas.size());
    } catch (DAOException ex) {
        Logger.getLogger(ImportIndicacoesToPreMatricula.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : HashMap(java.util.HashMap) HibernatePreMatriculaDAO(com.tomasio.projects.trainning.dao.HibernatePreMatriculaDAO) PreMatriculaAluno(com.tomasio.projects.trainning.model.PreMatriculaAluno) IndicacaoInstrutor(com.tomasio.projects.trainning.model.IndicacaoInstrutor) IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) HibernateIndicacaoDAO(com.tomasio.projects.trainning.dao.HibernateIndicacaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) IndicacaoAluno(com.tomasio.projects.trainning.model.IndicacaoAluno) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) HibernateIndicacaoDAO(com.tomasio.projects.trainning.dao.HibernateIndicacaoDAO) List(java.util.List) HibernatePreMatriculaDAO(com.tomasio.projects.trainning.dao.HibernatePreMatriculaDAO) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO)

Example 42 with IndicacaoDAO

use of com.tomasio.projects.trainning.dao.IndicacaoDAO in project trainning by fernandotomasio.

the class ImportIndicacoesToMatricula method execute.

@Override
public void execute() {
    IndicacaoDAO indicacaoDAO = new HibernateIndicacaoDAO();
    MatriculaDAO matriculaDAO = new HibernateMatriculaDAO();
    PreMatriculaDAO preMatriculaDAO = new HibernatePreMatriculaDAO();
    Map<Long, List<IndicacaoAluno>> indicacoesAlunosMap = new HashMap<Long, List<IndicacaoAluno>>();
    Map<Long, List<IndicacaoInstrutor>> indicacoesInstrutoresMap = new HashMap<Long, List<IndicacaoInstrutor>>();
    int i = 0;
    try {
        List<Matricula> matriculas = matriculaDAO.findAll();
        for (Matricula matricula : matriculas) {
            Long turmaId = matricula.getTurma().getId();
            System.out.print(++i + " - ");
            if (matricula instanceof MatriculaAluno) {
                List<IndicacaoAluno> indicacoesAlunos = indicacoesAlunosMap.get(turmaId);
                if (indicacoesAlunos == null) {
                    indicacoesAlunos = indicacaoDAO.findAllAlunos(turmaId);
                    indicacoesAlunosMap.put(turmaId, indicacoesAlunos);
                }
                for (IndicacaoAluno indicacaoAluno : indicacoesAlunos) {
                    if (matricula.getPessoa().getId().equals(indicacaoAluno.getPessoa().getId())) {
                        matricula.setIndicacao(indicacaoAluno);
                        matriculaDAO.update(matricula);
                    }
                }
            } else {
                List<IndicacaoInstrutor> indicacoesInstrutores = indicacoesInstrutoresMap.get(turmaId);
                if (indicacoesInstrutores == null) {
                    indicacoesInstrutores = indicacaoDAO.findAllInstrutores(turmaId);
                    indicacoesInstrutoresMap.put(turmaId, indicacoesInstrutores);
                }
                for (IndicacaoInstrutor indicacaoInstrutor : indicacoesInstrutores) {
                    if (matricula.getPessoa().getId().equals(indicacaoInstrutor.getPessoa().getId())) {
                        matricula.setIndicacao(indicacaoInstrutor);
                        matriculaDAO.update(matricula);
                    }
                }
            }
            System.out.println("");
        }
        System.out.println(matriculas.size());
    } catch (DAOException ex) {
        Logger.getLogger(ImportIndicacoesToMatricula.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : HashMap(java.util.HashMap) Matricula(com.tomasio.projects.trainning.model.Matricula) HibernatePreMatriculaDAO(com.tomasio.projects.trainning.dao.HibernatePreMatriculaDAO) IndicacaoInstrutor(com.tomasio.projects.trainning.model.IndicacaoInstrutor) IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) HibernateIndicacaoDAO(com.tomasio.projects.trainning.dao.HibernateIndicacaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) IndicacaoAluno(com.tomasio.projects.trainning.model.IndicacaoAluno) MatriculaAluno(com.tomasio.projects.trainning.model.MatriculaAluno) HibernateMatriculaDAO(com.tomasio.projects.trainning.dao.HibernateMatriculaDAO) HibernateMatriculaDAO(com.tomasio.projects.trainning.dao.HibernateMatriculaDAO) MatriculaDAO(com.tomasio.projects.trainning.dao.MatriculaDAO) HibernatePreMatriculaDAO(com.tomasio.projects.trainning.dao.HibernatePreMatriculaDAO) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) HibernateIndicacaoDAO(com.tomasio.projects.trainning.dao.HibernateIndicacaoDAO) List(java.util.List) HibernatePreMatriculaDAO(com.tomasio.projects.trainning.dao.HibernatePreMatriculaDAO) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO)

Aggregations

IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)42 DAOException (com.tomasio.projects.trainning.exception.DAOException)39 Transactional (org.springframework.transaction.annotation.Transactional)33 ParseException (java.text.ParseException)32 CoreException (com.tomasio.projects.trainning.exeption.CoreException)30 Indicacao (com.tomasio.projects.trainning.model.Indicacao)20 IndicacaoAluno (com.tomasio.projects.trainning.model.IndicacaoAluno)15 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)13 MatriculaDAO (com.tomasio.projects.trainning.dao.MatriculaDAO)12 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)12 IndicacaoAlunoDTO (com.tomasio.projects.trainning.dto.IndicacaoAlunoDTO)12 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)12 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)12 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)11 Matricula (com.tomasio.projects.trainning.model.Matricula)9 HibernateIndicacaoDAO (com.tomasio.projects.trainning.dao.HibernateIndicacaoDAO)8 OrganizacaoDAO (com.tomasio.projects.trainning.dao.OrganizacaoDAO)8 IndicacaoInstrutor (com.tomasio.projects.trainning.model.IndicacaoInstrutor)8 CancelamentoMatriculaDAO (com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO)7 NotificacaoMatriculaDAO (com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO)7