Search in sources :

Example 1 with Indicacao

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

the class IndicacoesLoggerAdvice method logRemoveIndicacao.

@Around("remove()")
public void logRemoveIndicacao(ProceedingJoinPoint joinPoint) throws Throwable {
    Long id = (Long) joinPoint.getArgs()[0];
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    Indicacao indicacao = indicacaoDAO.find(id);
    joinPoint.proceed();
    LogDTO log = new LogDTO();
    log.setDataCriacao(new Date());
    log.setUser(getUser());
    log.setTexto("EXCLUSÃO DE INDICACAO " + getDetails(indicacao.createDTO()));
    logger.create(log);
}
Also used : IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) LogDTO(com.tomasio.projects.trainning.dto.LogDTO) Indicacao(com.tomasio.projects.trainning.model.Indicacao) Date(java.util.Date) Around(org.aspectj.lang.annotation.Around)

Example 2 with Indicacao

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

the class AtividadesEnsinoServiceSimpleImpl method updateWorkflowActors.

@Override
@Transactional
public void updateWorkflowActors(Long indicacaoId) throws Exception {
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    ParecerDAO parecerDAO = factory.getParecerDAO();
    Indicacao indicacao = indicacaoDAO.find(indicacaoId);
    List<Parecer> pareceres = parecerDAO.findAll(indicacao.getId());
    TurmaEfetiva turma = (TurmaEfetiva) turmaDAO.find(indicacao.getTurma().getId());
    Organizacao nextActor;
    Organizacao lastActor = null;
    if (pareceres.size() > 0) {
        // pareceres são retornados pelo dao em ordem decrescente
        Parecer lastParecer = pareceres.get(0);
        lastActor = lastParecer.getOrganizacao();
        nextActor = getNextActor(lastParecer.getOrganizacao(), turma);
        if (lastParecer instanceof Reprovacao) {
            indicacao.setReprovado(true);
        } else {
            indicacao.setReprovado(false);
        }
    } else {
        // não havendo pareceres
        nextActor = getNextActor(indicacao.getOrganizacao(), turma);
        /*
            verifica se é uma indicação de grande comando para outro grande comando
            então o grande comando que indicou ainda precisa aprovar.
             */
        if ((indicacao.getOrganizacao() instanceof Comando) && (turma.getOrganizacaoGestoraId().equals(indicacao.getOrganizacao().getId()) == false)) {
            nextActor = indicacao.getOrganizacao();
        }
        indicacao.setReprovado(false);
    }
    indicacao.setNextWorkflowActor(nextActor);
    indicacao.setLastWorkflowActor(lastActor);
    indicacaoDAO.update(indicacao);
}
Also used : IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) Comando(com.tomasio.projects.trainning.model.Comando) Parecer(com.tomasio.projects.trainning.model.Parecer) Organizacao(com.tomasio.projects.trainning.model.Organizacao) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) ParecerDAO(com.tomasio.projects.trainning.dao.ParecerDAO) Indicacao(com.tomasio.projects.trainning.model.Indicacao) Reprovacao(com.tomasio.projects.trainning.model.Reprovacao) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Indicacao

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

the class AtividadesEnsinoServiceSimpleImpl method findAllIndicacoesInstrutorByPessoaId.

@Override
@Transactional(readOnly = true)
public IndicacaoDTO[] findAllIndicacoesInstrutorByPessoaId(Date exercicio, Long pessoaId) {
    IndicacaoDAO dao = factory.getIndicacaoDAO();
    IndicacaoDTO[] indicacoesArray = null;
    try {
        List<Indicacao> indicacoes = dao.findAllIndicacoesInstrutorByPessoaId(pessoaId, exercicio);
        if (indicacoes != null) {
            indicacoesArray = new IndicacaoInstrutorDTO[indicacoes.size()];
            for (int i = 0; i < indicacoes.size(); i++) {
                indicacoesArray[i] = indicacoes.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 indicacoesArray;
}
Also used : IndicacaoDAO(com.tomasio.projects.trainning.dao.IndicacaoDAO) DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) 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) IndicacaoDTO(com.tomasio.projects.trainning.dto.IndicacaoDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Indicacao

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

Example 5 with Indicacao

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

Aggregations

Indicacao (com.tomasio.projects.trainning.model.Indicacao)25 DAOException (com.tomasio.projects.trainning.exception.DAOException)23 ParseException (java.text.ParseException)21 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)20 Transactional (org.springframework.transaction.annotation.Transactional)19 CoreException (com.tomasio.projects.trainning.exeption.CoreException)18 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)11 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)10 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)10 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)10 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)10 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 IndicacaoAluno (com.tomasio.projects.trainning.model.IndicacaoAluno)5 HibernateException (org.hibernate.HibernateException)5 Session (org.hibernate.Session)5