Search in sources :

Example 1 with PreMatricula

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

the class AtividadesEnsinoServiceSimpleImpl method findPreMatricula.

@Override
@Transactional(readOnly = true)
public PreMatriculaDTO findPreMatricula(Long preMatriculaId) {
    PreMatriculaDAO dao = factory.getPreMatriculaDAO();
    PreMatricula preMatricula = null;
    try {
        preMatricula = dao.find(preMatriculaId);
    } 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());
    }
    if (preMatricula != null) {
        return preMatricula.createDTO();
    } else {
        return null;
    }
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with PreMatricula

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

the class AtividadesEnsinoServiceSimpleImpl method findAllPreMatriculasAlunos.

@Override
@Transactional(readOnly = true)
public PreMatriculaDTO[] findAllPreMatriculasAlunos(Long turmaId) {
    PreMatriculaDAO dao = factory.getPreMatriculaDAO();
    PreMatriculaDTO[] preMatriculasArray = null;
    try {
        List<PreMatricula> preMatriculas = dao.findAllAlunos(turmaId);
        if (preMatriculas != null) {
            preMatriculasArray = new PreMatriculaDTO[preMatriculas.size()];
            for (int i = 0; i < preMatriculas.size(); i++) {
                preMatriculasArray[i] = preMatriculas.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 preMatriculasArray;
}
Also used : DAOException(com.tomasio.projects.trainning.exception.DAOException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) ParseException(java.text.ParseException) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with PreMatricula

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

the class AtividadesEnsinoServiceSimpleImpl method createPreMatricula.

@Override
@Transactional
public void createPreMatricula(PreMatriculaDTO[] preMatriculas) {
    PreMatriculaDAO preMatriculaDAO = factory.getPreMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    List<PreMatricula> preMatriculasList = new ArrayList<PreMatricula>();
    List<Indicacao> indicacoesList = new ArrayList<Indicacao>();
    for (PreMatriculaDTO preMatriculaDTO : preMatriculas) {
        PreMatricula _preMatricula = null;
        if (preMatriculaDTO instanceof PreMatriculaAlunoDTO) {
            _preMatricula = new PreMatriculaAluno((PreMatriculaAlunoDTO) preMatriculaDTO);
        } else {
            _preMatricula = new PreMatriculaInstrutor((PreMatriculaInstrutorDTO) preMatriculaDTO);
        }
        preMatriculasList.add(_preMatricula);
        indicacoesList.add(_preMatricula.getIndicacao());
    }
    try {
        preMatriculaDAO.create(preMatriculasList);
        for (Indicacao indicacao : indicacoesList) {
            indicacao.setPreMatriculado(true);
            indicacaoDAO.update(indicacao);
        }
    } 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 : ArrayList(java.util.ArrayList) Indicacao(com.tomasio.projects.trainning.model.Indicacao) PreMatriculaAluno(com.tomasio.projects.trainning.model.PreMatriculaAluno) PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) 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) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) PreMatriculaInstrutor(com.tomasio.projects.trainning.model.PreMatriculaInstrutor) PreMatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with PreMatricula

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

the class AtividadesEnsinoServiceSimpleImpl method createPreMatricula.

@Override
@Transactional
public Long createPreMatricula(PreMatriculaDTO preMatricula) {
    PreMatriculaDAO preMatriculaDAO = factory.getPreMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    PreMatricula _preMatricula = null;
    if (preMatricula instanceof PreMatriculaAlunoDTO) {
        _preMatricula = new PreMatriculaAluno((PreMatriculaAlunoDTO) preMatricula);
    } else {
        _preMatricula = new PreMatriculaInstrutor((PreMatriculaInstrutorDTO) preMatricula);
    }
    Long id = null;
    try {
        Indicacao _indicacao = _preMatricula.getIndicacao();
        TurmaEfetiva _turma = _preMatricula.getTurma();
        id = preMatriculaDAO.create(_preMatricula);
        _indicacao.setPreMatriculado(true);
        _turma.setPreAtivado(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 : StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) Indicacao(com.tomasio.projects.trainning.model.Indicacao) PreMatriculaAluno(com.tomasio.projects.trainning.model.PreMatriculaAluno) PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) 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) CoreException(com.tomasio.projects.trainning.exeption.CoreException) PreMatricula(com.tomasio.projects.trainning.model.PreMatricula) PreMatriculaInstrutor(com.tomasio.projects.trainning.model.PreMatriculaInstrutor) PreMatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with PreMatricula

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

the class AtividadesEnsinoServiceSimpleImpl method removePreMatricula.

@Override
@Transactional
public void removePreMatricula(Long preMatriculaId) {
    PreMatriculaDAO preMatriculaDAO = factory.getPreMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    try {
        PreMatricula preMatricula = preMatriculaDAO.find(preMatriculaId);
        Indicacao indicacao = preMatricula.getIndicacao();
        TurmaEfetiva turma = preMatricula.getTurma();
        preMatriculaDAO.remove(preMatriculaId);
        indicacao.setPreMatriculado(false);
        indicacaoDAO.update(indicacao);
        if (hasPreMatriculas(turma.getId())) {
            turma.setPreAtivado(true);
        } else {
            turma.setPreAtivado(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) 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) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)11 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)10 DAOException (com.tomasio.projects.trainning.exception.DAOException)10 CoreException (com.tomasio.projects.trainning.exeption.CoreException)8 ParseException (java.text.ParseException)8 Transactional (org.springframework.transaction.annotation.Transactional)8 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)4 PreMatriculaDTO (com.tomasio.projects.trainning.dto.PreMatriculaDTO)4 PreMatriculaAluno (com.tomasio.projects.trainning.model.PreMatriculaAluno)4 PreMatriculaAlunoDTO (com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO)3 PreMatriculaInstrutorDTO (com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO)3 Indicacao (com.tomasio.projects.trainning.model.Indicacao)3 PreMatriculaInstrutor (com.tomasio.projects.trainning.model.PreMatriculaInstrutor)3 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)2 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)2 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)2 HibernateIndicacaoDAO (com.tomasio.projects.trainning.dao.HibernateIndicacaoDAO)1 HibernatePreMatriculaDAO (com.tomasio.projects.trainning.dao.HibernatePreMatriculaDAO)1 IndicacaoAluno (com.tomasio.projects.trainning.model.IndicacaoAluno)1 IndicacaoInstrutor (com.tomasio.projects.trainning.model.IndicacaoInstrutor)1