Search in sources :

Example 1 with Matricula

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

the class InstructorsServiceSimpleImpl method findAllMatriculasInstrutores.

@Override
@Transactional(readOnly = true)
public MatriculaDTO[] findAllMatriculasInstrutores(Long cursoId, Long pessoaId) {
    MatriculaDAO dao = factory.getMatriculaDAO();
    MatriculaDTO[] matriculasArray = null;
    try {
        List<Matricula> matriculas = dao.findAllInstrutoresByCurso(cursoId, pessoaId);
        if (matriculas != null) {
            matriculasArray = new MatriculaDTO[matriculas.size()];
            for (int i = 0; i < matriculas.size(); i++) {
                matriculasArray[i] = matriculas.get(i).createDTO();
            }
        }
    } catch (DAOException ex) {
        throw new CoreException("Erro de de acesso ao banco de dados: " + ex.getMessage());
    }
    return matriculasArray;
}
Also used : MatriculaDTO(com.tomasio.projects.trainning.dto.MatriculaDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) Matricula(com.tomasio.projects.trainning.model.Matricula) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Matricula

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

the class MatriculasLoggerAdvice method logRemoveMatricula.

@Around("remove()")
public void logRemoveMatricula(ProceedingJoinPoint joinPoint) throws Throwable {
    Long id = (Long) joinPoint.getArgs()[0];
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    Matricula matricula = matriculaDAO.find(id);
    joinPoint.proceed();
    LogDTO log = new LogDTO();
    log.setDataCriacao(new Date());
    log.setUser(getUser());
    log.setTexto("EXCLUSÃO DE MATRÍCULA " + getDetails(matricula.createDTO()));
    logger.create(log);
}
Also used : MatriculaDAO(com.tomasio.projects.trainning.dao.MatriculaDAO) Matricula(com.tomasio.projects.trainning.model.Matricula) LogDTO(com.tomasio.projects.trainning.dto.LogDTO) Date(java.util.Date) Around(org.aspectj.lang.annotation.Around)

Example 3 with Matricula

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

the class AtividadesEnsinoServiceSimpleImpl method updateMatricula.

@Override
@Transactional
public void updateMatricula(MatriculaDTO matricula) {
    MatriculaDAO dao = factory.getMatriculaDAO();
    Matricula _matricula = null;
    if (matricula != null) {
        if (matricula instanceof MatriculaAlunoDTO) {
            _matricula = new MatriculaAluno((MatriculaAlunoDTO) matricula);
        } else {
            _matricula = new MatriculaInstrutor((MatriculaInstrutorDTO) matricula);
        }
    }
    try {
        dao.update(_matricula);
    } 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 : PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) MatriculaAlunoDTO(com.tomasio.projects.trainning.dto.MatriculaAlunoDTO) MatriculaInstrutor(com.tomasio.projects.trainning.model.MatriculaInstrutor) PreMatriculaInstrutor(com.tomasio.projects.trainning.model.PreMatriculaInstrutor) 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) 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) 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) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Matricula

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

the class AtividadesEnsinoServiceSimpleImpl method hasMatriculas.

private boolean hasMatriculas(Long id) throws DAOException {
    MatriculaDAO dao = factory.getMatriculaDAO();
    List<Matricula> alunos = dao.findAllAlunos(id);
    for (Matricula matricula : alunos) {
        if (matricula.isCancelada() == false) {
            return true;
        }
    }
    List<Matricula> instrutores = dao.findAllInstrutores(id);
    for (Matricula matricula : instrutores) {
        if (matricula.isCancelada() == false) {
            return true;
        }
    }
    return false;
}
Also used : 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)

Example 5 with Matricula

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

the class AtividadesEnsinoServiceSimpleImpl method calculateCustoRealizadoInstrutores.

@Override
@Transactional(readOnly = true)
public Map<String, BigDecimal> calculateCustoRealizadoInstrutores(TurmaEfetivaDTO[] turmas) {
    Map<String, BigDecimal> result = new HashMap();
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    PessoaDAO pessoaDAO = factory.getPessoaDAO();
    String parameterDiaria = ConfigHelper.getValue("custos.diaria");
    String parameterPassagem = ConfigHelper.getValue("custos.passagem");
    BigDecimal diaria = new BigDecimal(parameterDiaria);
    BigDecimal passagem = new BigDecimal(parameterPassagem);
    OrganizacaoDAO organizacaoDAO = factory.getOrganizacaoDAO();
    BigDecimal transporteRealizado = new BigDecimal(0.00);
    BigDecimal diariasRealizado = new BigDecimal(0.00);
    try {
        for (TurmaEfetivaDTO turma : turmas) {
            if (turma.isCancelado()) {
                continue;
            }
            List<Matricula> instrucoes = matriculaDAO.findAllInstrutores(turma.getId());
            for (Matricula matricula : instrucoes) {
                if (matricula.isCancelada()) {
                    continue;
                }
                matricula.getIndicacao().getId();
                IndicacaoInstrutorDTO indicacao = (IndicacaoInstrutorDTO) matricula.getIndicacao().createDTO();
                int intervalo = 0;
                Interval instrucaoInterval = null;
                if (indicacao.getPeriodo() != null && indicacao.getPeriodo().getDataInicio() != null && indicacao.getPeriodo().getDataTermino() != null) {
                    DateTime dataInicioInstrucao = new DateTime(indicacao.getPeriodo().getDataInicio().getTime());
                    DateTime dataTerminoInstrucao = new DateTime(indicacao.getPeriodo().getDataTermino().getTime());
                    if (dataInicioInstrucao.isAfter(dataTerminoInstrucao)) {
                        continue;
                    }
                    instrucaoInterval = new Interval(dataInicioInstrucao, dataTerminoInstrucao);
                    Days d = Days.daysBetween(dataInicioInstrucao, dataTerminoInstrucao);
                    intervalo = d.getDays() + 2;
                }
                if (intervalo <= 0) {
                    continue;
                }
                if (intervalo > 50) {
                    intervalo = 50;
                }
                Pessoa pessoa = pessoaDAO.find(indicacao.getPessoa().getId());
                if (pessoa.getOrganizacao() != null) {
                    Organizacao organizacaoInstrutor = organizacaoDAO.find(pessoa.getOrganizacao().getId());
                    if (organizacaoInstrutor.createDTO() instanceof ExternoDTO) {
                        continue;
                    }
                    FaseDTO[] fases = turma.getFases();
                    for (FaseDTO fase : fases) {
                        if (fase.getDataInicio() != null && fase.getDataTermino() != null) {
                            DateTime dataInicioFase = new DateTime(fase.getDataInicio().getTime());
                            DateTime dataTerminoFase = new DateTime(fase.getDataTermino().getTime());
                            if (dataTerminoFase.isBefore(dataInicioFase)) {
                                continue;
                            }
                            Interval faseInterval = new Interval(dataInicioFase, dataTerminoFase);
                            if (faseInterval.contains(instrucaoInterval) || instrucaoInterval.contains(faseInterval)) {
                                Organizacao organizacaoLocal = organizacaoDAO.find(fase.getLocal().getId());
                                if (!organizacaoInstrutor.getCidade().getId().equals(organizacaoLocal.getCidade().getId())) {
                                    diariasRealizado = diariasRealizado.add(diaria.multiply(new BigDecimal(intervalo)));
                                    transporteRealizado = transporteRealizado.add(passagem);
                                }
                            }
                        }
                    }
                }
            }
        }
    } catch (DAOException ex) {
        Logger.getLogger(AtividadesEnsinoServiceSimpleImpl.class.getName()).log(Level.SEVERE, null, ex);
    }
    result.put("transporte", transporteRealizado);
    result.put("diarias", diariasRealizado);
    result.put("total", transporteRealizado.add(diariasRealizado));
    return result;
}
Also used : HashMap(java.util.HashMap) PessoaDAO(com.tomasio.projects.trainning.dao.PessoaDAO) 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) Pessoa(com.tomasio.projects.trainning.model.Pessoa) FaseDTO(com.tomasio.projects.trainning.dto.FaseDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) OrganizacaoDAO(com.tomasio.projects.trainning.dao.OrganizacaoDAO) TurmaEfetivaDTO(com.tomasio.projects.trainning.dto.TurmaEfetivaDTO) Organizacao(com.tomasio.projects.trainning.model.Organizacao) 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) ExternoDTO(com.tomasio.projects.trainning.dto.ExternoDTO) IndicacaoInstrutorDTO(com.tomasio.projects.trainning.dto.IndicacaoInstrutorDTO) Interval(org.joda.time.Interval) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Matricula (com.tomasio.projects.trainning.model.Matricula)31 DAOException (com.tomasio.projects.trainning.exception.DAOException)29 MatriculaDAO (com.tomasio.projects.trainning.dao.MatriculaDAO)24 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)22 CancelamentoMatriculaDAO (com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO)21 NotificacaoMatriculaDAO (com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO)21 CancelamentoMatricula (com.tomasio.projects.trainning.model.CancelamentoMatricula)21 NotificacaoMatricula (com.tomasio.projects.trainning.model.NotificacaoMatricula)21 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)21 Transactional (org.springframework.transaction.annotation.Transactional)21 ParseException (java.text.ParseException)19 CoreException (com.tomasio.projects.trainning.exeption.CoreException)18 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)9 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)9 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)8 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)7 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)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