Search in sources :

Example 6 with MatriculaDAO

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

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

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

the class AtividadesEnsinoServiceSimpleImpl method calculateCustoRealizadoAdministrativo.

@Override
@Transactional(readOnly = true)
public BigDecimal calculateCustoRealizadoAdministrativo(TurmaEfetivaDTO[] turmas) {
    BigDecimal result = new BigDecimal(0);
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    String parameterIcea = ConfigHelper.getValue("custos.icea");
    BigDecimal custoIndividualIcea = new BigDecimal(parameterIcea);
    try {
        for (TurmaEfetivaDTO turma : turmas) {
            if (turma.isCancelado()) {
                continue;
            }
            List<Matricula> alunos = matriculaDAO.findAllAlunos(turma.getId());
            FaseDTO[] fases = turma.getFases();
            for (FaseDTO fase : fases) {
                if ("PRESENCIAL".equals(fase.getTipoFase())) {
                    int intervalo = 0;
                    if (fase.getDataInicio() != null && fase.getDataTermino() != null) {
                        DateTime dataInicio = new DateTime(fase.getDataInicio().getTime());
                        DateTime dataTermino = new DateTime(fase.getDataTermino().getTime());
                        Days d = Days.daysBetween(dataInicio, dataTermino);
                        intervalo = d.getDays() + 1;
                    }
                    if (intervalo <= 0) {
                        continue;
                    }
                    BigDecimal custoTurma = custoIndividualIcea.multiply(new BigDecimal(intervalo)).multiply(new BigDecimal(alunos.size()));
                    result = result.add(custoTurma);
                }
            }
        }
    } catch (DAOException ex) {
        Logger.getLogger(AtividadesEnsinoServiceSimpleImpl.class.getName()).log(Level.SEVERE, null, ex);
    }
    return result;
}
Also used : 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) BigDecimal(java.math.BigDecimal) DateTime(org.joda.time.DateTime) FaseDTO(com.tomasio.projects.trainning.dto.FaseDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) TurmaEfetivaDTO(com.tomasio.projects.trainning.dto.TurmaEfetivaDTO) 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) Days(org.joda.time.Days) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with MatriculaDAO

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

Example 10 with MatriculaDAO

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

the class AtividadesEnsinoServiceSimpleImpl method countMatriculasAlunos.

@Override
@Transactional(readOnly = true)
public int countMatriculasAlunos(Date start, Date end) {
    MatriculaDAO dao = factory.getMatriculaDAO();
    int count = 0;
    try {
        count = dao.countAllAlunos(start, end);
    } catch (DAOException ex) {
        throw new CoreException(ex.getMessage());
    } catch (Exception ex) {
        throw new CoreException("Erro em tempo de execução: " + ex.getMessage());
    }
    return count;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) 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) 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

MatriculaDAO (com.tomasio.projects.trainning.dao.MatriculaDAO)29 DAOException (com.tomasio.projects.trainning.exception.DAOException)26 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)24 Matricula (com.tomasio.projects.trainning.model.Matricula)24 CancelamentoMatriculaDAO (com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO)23 NotificacaoMatriculaDAO (com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO)23 Transactional (org.springframework.transaction.annotation.Transactional)22 CancelamentoMatricula (com.tomasio.projects.trainning.model.CancelamentoMatricula)21 NotificacaoMatricula (com.tomasio.projects.trainning.model.NotificacaoMatricula)21 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)21 CoreException (com.tomasio.projects.trainning.exeption.CoreException)19 ParseException (java.text.ParseException)19 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)12 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)7 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)7 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)7 NotificacaoMatriculaDTO (com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO)7 PreMatriculaDTO (com.tomasio.projects.trainning.dto.PreMatriculaDTO)7 Indicacao (com.tomasio.projects.trainning.model.Indicacao)7 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)7