Search in sources :

Example 1 with MatriculaDAO

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

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

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

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

Example 5 with MatriculaDAO

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

the class AtividadesEnsinoServiceSimpleImpl method removeCancelamentoMatricula.

@Override
@Transactional
public void removeCancelamentoMatricula(Long matriculaId) {
    CancelamentoMatriculaDAO cancelamentoMatriculaDAO = factory.getCancelamentoMatriculaDAO();
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    try {
        // remover um registro na tabela CancelamentoMatricula
        CancelamentoMatricula c = (CancelamentoMatricula) cancelamentoMatriculaDAO.findCancelamentoMatriculaByMatricula(matriculaId);
        Matricula matricula = matriculaDAO.find(c.getMatricula().getId());
        Indicacao indicacao = matricula.getIndicacao();
        TurmaEfetiva turma = matricula.getTurma();
        if (c != null) {
            cancelamentoMatriculaDAO.remove(c.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) CancelamentoMatricula(com.tomasio.projects.trainning.model.CancelamentoMatricula) DAOException(com.tomasio.projects.trainning.exception.DAOException) CancelamentoMatriculaDAO(com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO) 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)

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