Search in sources :

Example 1 with PreMatriculaAlunoDTO

use of com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO 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 PreMatriculaAlunoDTO

use of com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO 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 PreMatriculaAlunoDTO

use of com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO in project trainning by fernandotomasio.

the class TurmasEfetivasController method savePreMatriculas.

@RequestMapping("/save_pre_matriculas")
public String savePreMatriculas(Model model, WebRequest request, @ModelAttribute("turma") @Valid TurmaEfetivaDTO turma) {
    String[] selecionados = request.getParameterValues("selecionados");
    List<PreMatriculaDTO> preMatriculas = new ArrayList<>();
    for (String selecionado : selecionados) {
        IndicacaoDTO indicacaoDTO = atividadesEnsinoService.findIndicacao(Long.parseLong(selecionado));
        PessoaDTO pessoa = organizationalService.findPessoa(indicacaoDTO.getPessoa().getId());
        PreMatriculaDTO preMatricula = null;
        if (indicacaoDTO instanceof IndicacaoAlunoDTO) {
            preMatricula = new PreMatriculaAlunoDTO();
        } else {
            preMatricula = new PreMatriculaInstrutorDTO();
        }
        preMatricula.setIndicacao(indicacaoDTO);
        preMatricula.setPessoa(pessoa);
        preMatricula.setTurma(turma);
        preMatriculas.add(preMatricula);
    }
    PreMatriculaDTO[] arrayPreMatriculas = new PreMatriculaDTO[preMatriculas.size()];
    preMatriculas.toArray(arrayPreMatriculas);
    try {
        atividadesEnsinoService.createPreMatricula(arrayPreMatriculas);
        model.addAttribute("successMessage", "Pré-Matrícula criada com sucesso.");
    } catch (CoreException e) {
        model.addAttribute("errorMessage", e.getMessage());
    }
    model.addAttribute("tab", "pre-matriculas");
    return "redirect:detail/pre_matriculas";
}
Also used : IndicacaoAlunoDTO(com.tomasio.projects.trainning.dto.IndicacaoAlunoDTO) PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) CoreException(com.tomasio.projects.trainning.exeption.CoreException) ArrayList(java.util.ArrayList) PreMatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO) PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) IndicacaoDTO(com.tomasio.projects.trainning.dto.IndicacaoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with PreMatriculaAlunoDTO

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

Example 5 with PreMatriculaAlunoDTO

use of com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO in project trainning by fernandotomasio.

the class PreMatriculaAluno method createDTOMinimal.

@Override
public PreMatriculaDTO createDTOMinimal() {
    PreMatriculaDTO dto = new PreMatriculaAlunoDTO();
    dto.setId(id);
    return dto;
}
Also used : PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO)

Aggregations

PreMatriculaAlunoDTO (com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO)5 PreMatriculaInstrutorDTO (com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO)4 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)3 PreMatriculaDTO (com.tomasio.projects.trainning.dto.PreMatriculaDTO)3 DAOException (com.tomasio.projects.trainning.exception.DAOException)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 ArrayList (java.util.ArrayList)2 TurmaDAO (com.tomasio.projects.trainning.dao.TurmaDAO)1 IndicacaoAlunoDTO (com.tomasio.projects.trainning.dto.IndicacaoAlunoDTO)1 IndicacaoDTO (com.tomasio.projects.trainning.dto.IndicacaoDTO)1 PessoaDTO (com.tomasio.projects.trainning.dto.PessoaDTO)1 StatusTurmaEfetiva (com.tomasio.projects.trainning.model.StatusTurmaEfetiva)1 TurmaEfetiva (com.tomasio.projects.trainning.model.TurmaEfetiva)1