Search in sources :

Example 1 with CancelamentoMatricula

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

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

the class AtividadesEnsinoServiceSimpleImpl method findAllCancelamentoMatriculaByTurma.

@Override
@Transactional(readOnly = true)
public CancelamentoMatriculaDTO[] findAllCancelamentoMatriculaByTurma(Long turmaId) {
    CancelamentoMatriculaDAO dao = factory.getCancelamentoMatriculaDAO();
    CancelamentoMatriculaDTO[] cancelamentoMatriculasArray = null;
    try {
        List<CancelamentoMatricula> cancelamentoMatricula = dao.findAllCancelamentoMatriculaByTurma(turmaId);
        if (cancelamentoMatricula != null) {
            cancelamentoMatriculasArray = new CancelamentoMatriculaDTO[cancelamentoMatricula.size()];
            for (int i = 0; i < cancelamentoMatricula.size(); i++) {
                cancelamentoMatriculasArray[i] = cancelamentoMatricula.get(i).createDTO();
            }
        }
    } 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 cancelamentoMatriculasArray;
}
Also used : CancelamentoMatricula(com.tomasio.projects.trainning.model.CancelamentoMatricula) DAOException(com.tomasio.projects.trainning.exception.DAOException) CancelamentoMatriculaDTO(com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO) CancelamentoMatriculaDAO(com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) 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 CancelamentoMatricula

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

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

the class AtividadesEnsinoServiceSimpleImpl method createDesligamento.

@Override
@Transactional
public Long createDesligamento(DesligamentoDTO desligamento) {
    DesligamentoDAO desligamentoDAO = factory.getDesligamentoDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    Long id = null;
    Desligamento _desligamento = null;
    // cria um registro na tabela CancelamentoMatricula
    if (desligamento != null) {
        _desligamento = new Desligamento(desligamento);
    }
    try {
        Matricula matricula = matriculaDAO.find(_desligamento.getMatricula().getId());
        Indicacao indicacao = matricula.getIndicacao();
        TurmaEfetiva turma = matricula.getTurma();
        id = desligamentoDAO.create(_desligamento);
        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 : 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 5 with CancelamentoMatricula

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

the class HibernateCancelamentoMatriculaDAO method create.

@Override
public void create(List<CancelamentoMatricula> cancelamentosMatriculas) throws DAOException {
    Session session = sessionFactory.getCurrentSession();
    try {
        for (CancelamentoMatricula cancelamentoMatricula : cancelamentosMatriculas) {
            Long countCancelamentosMatricula = (Long) session.createQuery("select count(*) from CancelamentoMatricula c where c.matricula.id = :matriculaId").setLong("matriculaId", cancelamentoMatricula.getMatricula().getId()).uniqueResult();
            if (countCancelamentosMatricula > 0) {
                throw new DAOException("Cancelamento de Matricula já existente");
            }
            session.save(cancelamentoMatricula);
        }
    } catch (HibernateException e) {
        Logger.getLogger(HibernateMatriculaDAO.class.getName()).log(Level.SEVERE, null, e);
        throw new DAOException(MessageHelper.getMessage("cancelamentoMatricula.create.list.error"));
    }
}
Also used : CancelamentoMatricula(com.tomasio.projects.trainning.model.CancelamentoMatricula) DAOException(com.tomasio.projects.trainning.exception.DAOException) HibernateException(org.hibernate.HibernateException) Session(org.hibernate.Session)

Aggregations

DAOException (com.tomasio.projects.trainning.exception.DAOException)7 CancelamentoMatricula (com.tomasio.projects.trainning.model.CancelamentoMatricula)7 CancelamentoMatriculaDAO (com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO)5 CoreException (com.tomasio.projects.trainning.exeption.CoreException)5 ParseException (java.text.ParseException)5 Transactional (org.springframework.transaction.annotation.Transactional)5 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)4 MatriculaDAO (com.tomasio.projects.trainning.dao.MatriculaDAO)4 NotificacaoMatriculaDAO (com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO)4 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)4 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)4 Indicacao (com.tomasio.projects.trainning.model.Indicacao)4 Matricula (com.tomasio.projects.trainning.model.Matricula)4 NotificacaoMatricula (com.tomasio.projects.trainning.model.NotificacaoMatricula)4 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)4 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)4 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)4 DesligamentoDAO (com.tomasio.projects.trainning.dao.DesligamentoDAO)2 Desligamento (com.tomasio.projects.trainning.model.Desligamento)2 HibernateException (org.hibernate.HibernateException)2