Search in sources :

Example 6 with TurmaEfetiva

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

the class AtividadesEnsinoServiceSimpleImpl method searchTurmasEfetivas.

@Override
@Transactional(readOnly = true)
public TurmaEfetivaDTO[] searchTurmasEfetivas(Date exercicio, Long planoId, Long cursoId, Long responsavelId, Long organizacaoGestoraId, String term) {
    TurmaDAO dao = factory.getTurmaDAO();
    TurmaEfetivaDTO[] turmasArray = null;
    try {
        List<TurmaEfetiva> turmas = dao.searchTurmasEfetivas(exercicio, planoId, cursoId, responsavelId, organizacaoGestoraId, term);
        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) {
        ex.printStackTrace();
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
    }
    return turmasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) TurmaEfetivaDTO(com.tomasio.projects.trainning.dto.TurmaEfetivaDTO) 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 7 with TurmaEfetiva

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

the class AtividadesEnsinoServiceSimpleImpl method removeMatricula.

@Override
@Transactional
public void removeMatricula(Long matriculaId) {
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    try {
        Matricula matricula = matriculaDAO.find(matriculaId);
        Indicacao indicacao = indicacaoDAO.find(matricula.getIndicacao().getId());
        indicacao.setMatriculado(false);
        matriculaDAO.remove(matriculaId);
        indicacaoDAO.update(indicacao);
        TurmaEfetiva turma = (TurmaEfetiva) turmaDAO.find(matricula.getTurma().getId());
        // VERIFICAR SE AINDA HÁ ALGUMA MATRICULA
        if (hasMatriculas(turma.getId())) {
            turma.setAtivado(true);
        } else {
            turma.setAtivado(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) 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) 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with TurmaEfetiva

use of com.tomasio.projects.trainning.model.TurmaEfetiva 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 9 with TurmaEfetiva

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

the class AtividadesEnsinoServiceSimpleImpl method findAllApresentacoesComPendendias.

@Override
@Transactional(readOnly = true)
public TurmaEfetivaDTO[] findAllApresentacoesComPendendias(Date exercicio, Long organizacaoId) {
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    List<TurmaEfetivaDTO> result = new ArrayList<TurmaEfetivaDTO>();
    List<TurmaEfetiva> turmas = null;
    try {
        // buscar turmas efetivas que esta organização é reponsavel ou responsavel por conclusao, neste exercício, com APRESENTACOES PENDENTES
        // Ou seja, turmas sem apresentação após inicio do curso
        // turmas = turmaDAO.findAllTurmasEfetivasNotCancel(exercicio, organizacaoId);
        turmas = turmaDAO.findAllTurmasEfetivasNotCancelOfResponsavelOrResponsavelApresentacao(exercicio, organizacaoId);
        for (TurmaEfetiva turma : turmas) {
            // verificar as turma com dtInicial menor que hoje
            SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
            try {
                exercicio = df.parse(df.format(exercicio));
            } catch (ParseException ex) {
                Logger.getLogger(AtividadesEnsinoServiceSimpleImpl.class.getName()).log(Level.SEVERE, null, ex);
            }
            if (turma.getDataInicio() != null && turma.getDataInicio().before(exercicio)) {
                // verificar se o curso tem apresentacoes
                if (turmaDAO.findNotApresentacoes(turma.getId())) {
                    // turma com pendencia
                    result.add(turma.createDTOWithoutDependencies());
                } else {
                // turma sem pendencia
                }
            } else {
            // turma não começou
            }
        }
    } catch (DAOException ex) {
        Logger.getLogger(AtividadesEnsinoServiceSimpleImpl.class.getName()).log(Level.SEVERE, null, ex);
    }
    TurmaEfetivaDTO[] resultArray = new TurmaEfetivaDTO[result.size()];
    result.toArray(resultArray);
    return resultArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) TurmaEfetivaDTO(com.tomasio.projects.trainning.dto.TurmaEfetivaDTO) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) SimpleDateFormat(java.text.SimpleDateFormat) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with TurmaEfetiva

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

the class AtividadesEnsinoServiceSimpleImpl method removeDesligamento.

@Override
@Transactional
public void removeDesligamento(Long matriculaId) {
    DesligamentoDAO desligamentoDAO = factory.getDesligamentoDAO();
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    try {
        // remover um registro na tabela CancelamentoMatricula
        Desligamento d = (Desligamento) desligamentoDAO.findDesligamentoByMatricula(matriculaId);
        Matricula matricula = matriculaDAO.find(d.getMatricula().getId());
        Indicacao indicacao = matricula.getIndicacao();
        TurmaEfetiva turma = matricula.getTurma();
        if (d != null) {
            desligamentoDAO.remove(d.getId());
            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(ex.getMessage());
    }
}
Also used : IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) Desligamento(com.tomasio.projects.trainning.model.Desligamento) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) CoreException(com.tomasio.projects.trainning.exeption.CoreException) DesligamentoDAO(com.tomasio.projects.trainning.dao.DesligamentoDAO) 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) 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) Transactional(org.springframework.transaction.annotation.Transactional)

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