Search in sources :

Example 1 with PreMatriculaInstrutor

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

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

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

the class AtividadesEnsinoServiceSimpleImpl method updatePreMatricula.

@Override
@Transactional
public void updatePreMatricula(PreMatriculaDTO preMatricula) {
    PreMatriculaDAO dao = factory.getPreMatriculaDAO();
    PreMatricula _preMatricula = null;
    if (preMatricula instanceof PreMatriculaAlunoDTO) {
        _preMatricula = new PreMatriculaAluno((PreMatriculaAlunoDTO) preMatricula);
    } else {
        _preMatricula = new PreMatriculaInstrutor((PreMatriculaInstrutorDTO) preMatricula);
    }
    try {
        dao.update(_preMatricula);
    } 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 : 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) PreMatriculaAluno(com.tomasio.projects.trainning.model.PreMatriculaAluno) PreMatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO) 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) PreMatriculaDAO(com.tomasio.projects.trainning.dao.PreMatriculaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)3 PreMatriculaAlunoDTO (com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO)3 PreMatriculaInstrutorDTO (com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO)3 DAOException (com.tomasio.projects.trainning.exception.DAOException)3 CoreException (com.tomasio.projects.trainning.exeption.CoreException)3 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)3 PreMatriculaAluno (com.tomasio.projects.trainning.model.PreMatriculaAluno)3 PreMatriculaInstrutor (com.tomasio.projects.trainning.model.PreMatriculaInstrutor)3 ParseException (java.text.ParseException)3 Transactional (org.springframework.transaction.annotation.Transactional)3 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)2 Indicacao (com.tomasio.projects.trainning.model.Indicacao)2 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)1 PreMatriculaDTO (com.tomasio.projects.trainning.dto.PreMatriculaDTO)1 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)1 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)1 ArrayList (java.util.ArrayList)1