Search in sources :

Example 1 with PreMatriculaDTO

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

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

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

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

the class AtividadesEnsinoServiceSimpleImpl method findAllPreMatriculas.

@Override
@Transactional(readOnly = true)
public PreMatriculaDTO[] findAllPreMatriculas() {
    PreMatriculaDAO dao = factory.getPreMatriculaDAO();
    PreMatriculaDTO[] preMatriculasArray = null;
    try {
        List<PreMatricula> preMatriculas = dao.findAll();
        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 5 with PreMatriculaDTO

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

the class AtividadesEnsinoServiceSimpleImpl method findAllPreMatriculasInstrutores.

@Override
@Transactional(readOnly = true)
public PreMatriculaDTO[] findAllPreMatriculasInstrutores(Long turmaId) {
    PreMatriculaDAO dao = factory.getPreMatriculaDAO();
    PreMatriculaDTO[] preMatriculasArray = null;
    try {
        List<PreMatricula> preMatriculas = dao.findAllInstrutores(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)

Aggregations

PreMatriculaDTO (com.tomasio.projects.trainning.dto.PreMatriculaDTO)8 CoreException (com.tomasio.projects.trainning.exeption.CoreException)5 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)4 DAOException (com.tomasio.projects.trainning.exception.DAOException)4 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)4 ParseException (java.text.ParseException)4 Transactional (org.springframework.transaction.annotation.Transactional)4 PreMatriculaAlunoDTO (com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO)3 PreMatriculaInstrutorDTO (com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO)3 ArrayList (java.util.ArrayList)3 IndicacaoAlunoDTO (com.tomasio.projects.trainning.dto.IndicacaoAlunoDTO)2 IndicacaoDTO (com.tomasio.projects.trainning.dto.IndicacaoDTO)2 PessoaDTO (com.tomasio.projects.trainning.dto.PessoaDTO)2 IndicacaoDAO (com.tomasio.projects.trainning.dao.IndicacaoDAO)1 ApresentacaoDTO (com.tomasio.projects.trainning.dto.ApresentacaoDTO)1 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)1 ConclusaoDTO (com.tomasio.projects.trainning.dto.ConclusaoDTO)1 MatriculaAlunoDTO (com.tomasio.projects.trainning.dto.MatriculaAlunoDTO)1 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)1 TurmaDTO (com.tomasio.projects.trainning.dto.TurmaDTO)1