Search in sources :

Example 26 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, Integer pageNumber, Integer pagesize) {
    TurmaDAO dao = factory.getTurmaDAO();
    TurmaEfetivaDTO[] turmasArray = null;
    try {
        List<TurmaEfetiva> turmas = dao.searchTurmasEfetivas(exercicio, planoId, cursoId, responsavelId, organizacaoGestoraId, term, pageNumber, pagesize);
        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 27 with TurmaEfetiva

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

the class AtividadesEnsinoServiceSimpleImpl method calculateCustoPrevistoInstrutores.

@Override
@Transactional(readOnly = true)
public Map<String, BigDecimal> calculateCustoPrevistoInstrutores(TurmaEfetivaDTO[] turmas) {
    Map<String, BigDecimal> result = new HashMap();
    SimpleDateFormat df = new SimpleDateFormat("yyyy");
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    BigDecimal transportePrevisto = new BigDecimal(0.00);
    BigDecimal diariasPrevisto = new BigDecimal(0.00);
    for (TurmaEfetivaDTO turma : turmas) {
        try {
            int exercicio = Integer.parseInt(df.format(turma.getExercicio()));
            Long cursoId = turma.getCurso().getId();
            int totalTurmas = 0;
            for (int i = exercicio - 2; i < exercicio; i++) {
                List<TurmaEfetiva> turmasAnteriores = turmaDAO.findAllTurmasEfetivas(df.parse(String.valueOf(i)), null, cursoId, null, null, null);
                Iterator<TurmaEfetiva> iterator = turmasAnteriores.iterator();
                while (iterator.hasNext()) {
                    TurmaEfetiva t = iterator.next();
                    if (t.isAtivado() == false || t.isCancelado()) {
                        iterator.remove();
                    }
                }
                totalTurmas += turmasAnteriores.size();
                TurmaEfetivaDTO[] turmasArray = new TurmaEfetivaDTO[turmasAnteriores.size()];
                for (int j = 0; j < turmasArray.length; j++) {
                    turmasArray[j] = turmasAnteriores.get(j).createDTOWithoutDependencies();
                }
                Map<String, BigDecimal> mapCustos = calculateCustoRealizadoInstrutores(turmasArray);
                if (totalTurmas > 0) {
                    diariasPrevisto = diariasPrevisto.add(mapCustos.get("diarias").divide(new BigDecimal(totalTurmas), BigDecimal.ROUND_UP));
                    transportePrevisto = transportePrevisto.add(mapCustos.get("transporte").divide(new BigDecimal(totalTurmas), BigDecimal.ROUND_UP));
                }
            }
        } catch (DAOException | ParseException ex) {
            Logger.getLogger(AtividadesEnsinoServiceSimpleImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    result.put("transporte", transportePrevisto);
    result.put("diarias", diariasPrevisto);
    result.put("total", transportePrevisto.add(diariasPrevisto));
    return result;
}
Also used : StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) HashMap(java.util.HashMap) BigDecimal(java.math.BigDecimal) DAOException(com.tomasio.projects.trainning.exception.DAOException) TurmaEfetivaDTO(com.tomasio.projects.trainning.dto.TurmaEfetivaDTO) ParseException(java.text.ParseException) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) SimpleDateFormat(java.text.SimpleDateFormat) Transactional(org.springframework.transaction.annotation.Transactional)

Example 28 with TurmaEfetiva

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

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

the class AtividadesEnsinoServiceSimpleImpl method createTurmaEfetiva.

@Override
@Transactional
public Long createTurmaEfetiva(TurmaEfetivaDTO turma) {
    TurmaDAO dao = factory.getTurmaDAO();
    TurmaEfetiva _turma = new TurmaEfetiva(turma);
    Long id = null;
    try {
        id = dao.create(_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 : 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) 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 30 with TurmaEfetiva

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

the class AtividadesEnsinoServiceSimpleImpl method createCancelamentoMatricula.

@Override
@Transactional
public Long createCancelamentoMatricula(CancelamentoMatriculaDTO cancelamentoMatricula) {
    CancelamentoMatriculaDAO cancelamentoMatriculaDAO = factory.getCancelamentoMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    Long id = null;
    CancelamentoMatricula _cancelamentoMatricula = null;
    // cria um registro na tabela CancelamentoMatricula
    if (cancelamentoMatricula != null) {
        _cancelamentoMatricula = new CancelamentoMatricula(cancelamentoMatricula);
    }
    try {
        // verificar se já existe uma apresentação realizada desta matricula
        ApresentacaoDAO daoApre = factory.getApresentacaoDAO();
        boolean apresentacao = daoApre.hasApresentacaoComparecimento(cancelamentoMatricula.getMatricula().getId());
        if (apresentacao) {
            throw new CoreException("N&atilde;o &eacute; poss&iacute;vel cancelar a matricula pois o aluno j&aacute; se apresentou para o in&iacute;cio do curso");
        }
        Matricula matricula = matriculaDAO.find(_cancelamentoMatricula.getMatricula().getId());
        Indicacao indicacao = matricula.getIndicacao();
        TurmaEfetiva turma = matricula.getTurma();
        id = cancelamentoMatriculaDAO.create(_cancelamentoMatricula);
        indicacao.setMatriculado(false);
        indicacaoDAO.update(indicacao);
        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());
        throw new CoreException(ex.getMessage());
    }
    return id;
}
Also used : CancelamentoMatricula(com.tomasio.projects.trainning.model.CancelamentoMatricula) ApresentacaoDAO(com.tomasio.projects.trainning.dao.ApresentacaoDAO) 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) 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) DAOException(com.tomasio.projects.trainning.exception.DAOException) CancelamentoMatriculaDAO(com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO) 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)

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