Search in sources :

Example 6 with TurmaDAO

use of com.tomasio.projects.trainning.dao.TurmaDAO 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 TurmaDAO

use of com.tomasio.projects.trainning.dao.TurmaDAO 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 TurmaDAO

use of com.tomasio.projects.trainning.dao.TurmaDAO 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 TurmaDAO

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

the class AtividadesEnsinoServiceSimpleImpl method createIndicacao.

@Override
@Transactional
public Long createIndicacao(IndicacaoDTO indicacao) {
    IndicacaoDAO dao = factory.getIndicacaoDAO();
    OrganizacaoDAO organizacaoDAO = factory.getOrganizacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    Indicacao _indicacao = null;
    if (indicacao != null) {
        if (indicacao instanceof IndicacaoAlunoDTO) {
            _indicacao = new IndicacaoAluno((IndicacaoAlunoDTO) indicacao);
        } else {
            _indicacao = new IndicacaoInstrutor((IndicacaoInstrutorDTO) indicacao);
        }
    }
    Long id = null;
    try {
        id = dao.create(_indicacao);
        updateWorkflowActors(_indicacao.getId());
    } catch (DAOException ex) {
        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 : IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) IndicacaoAlunoDTO(com.tomasio.projects.trainning.dto.IndicacaoAlunoDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) OrganizacaoDAO(com.tomasio.projects.trainning.dao.OrganizacaoDAO) IndicacaoAluno(com.tomasio.projects.trainning.model.IndicacaoAluno) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Indicacao(com.tomasio.projects.trainning.model.Indicacao) IndicacaoInstrutor(com.tomasio.projects.trainning.model.IndicacaoInstrutor) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) IndicacaoInstrutorDTO(com.tomasio.projects.trainning.dto.IndicacaoInstrutorDTO) 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 10 with TurmaDAO

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

Aggregations

TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)29 DAOException (com.tomasio.projects.trainning.exception.DAOException)27 Transactional (org.springframework.transaction.annotation.Transactional)26 ParseException (java.text.ParseException)25 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)22 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)21 CoreException (com.tomasio.projects.trainning.exeption.CoreException)19 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)13 Indicacao (com.tomasio.projects.trainning.model.Indicacao)11 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)9 TurmaEfetivaDTO (com.tomasio.projects.trainning.dto.TurmaEfetivaDTO)9 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)9 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 ArrayList (java.util.ArrayList)7 SimpleDateFormat (java.text.SimpleDateFormat)6