Search in sources :

Example 6 with MatriculaInstrutorDTO

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

the class AtividadesEnsinoServiceSimpleImpl method updateMatricula.

@Override
@Transactional
public void updateMatricula(MatriculaDTO matricula) {
    MatriculaDAO dao = factory.getMatriculaDAO();
    Matricula _matricula = null;
    if (matricula != null) {
        if (matricula instanceof MatriculaAlunoDTO) {
            _matricula = new MatriculaAluno((MatriculaAlunoDTO) matricula);
        } else {
            _matricula = new MatriculaInstrutor((MatriculaInstrutorDTO) matricula);
        }
    }
    try {
        dao.update(_matricula);
    } 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 : PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) MatriculaAlunoDTO(com.tomasio.projects.trainning.dto.MatriculaAlunoDTO) MatriculaInstrutor(com.tomasio.projects.trainning.model.MatriculaInstrutor) PreMatriculaInstrutor(com.tomasio.projects.trainning.model.PreMatriculaInstrutor) DAOException(com.tomasio.projects.trainning.exception.DAOException) PreMatriculaAluno(com.tomasio.projects.trainning.model.PreMatriculaAluno) MatriculaAluno(com.tomasio.projects.trainning.model.MatriculaAluno) 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) PreMatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO) MatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.MatriculaInstrutorDTO) 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 7 with MatriculaInstrutorDTO

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

the class AtividadesEnsinoServiceSimpleImpl method createMatricula.

@Override
@Transactional
public void createMatricula(MatriculaDTO[] matriculas) {
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    List<Matricula> matriculasList = new ArrayList<Matricula>();
    List<Indicacao> indicacoesList = new ArrayList<Indicacao>();
    Set<TurmaEfetiva> turmasList = new HashSet<TurmaEfetiva>();
    for (MatriculaDTO matricula : matriculas) {
        Matricula _matricula = null;
        if (matricula != null) {
            if (matricula instanceof MatriculaAlunoDTO) {
                _matricula = new MatriculaAluno((MatriculaAlunoDTO) matricula);
            } else {
                _matricula = new MatriculaInstrutor((MatriculaInstrutorDTO) matricula);
            }
        }
        matriculasList.add(_matricula);
        indicacoesList.add(_matricula.getIndicacao());
        turmasList.add(_matricula.getTurma());
    }
    try {
        matriculaDAO.create(matriculasList);
        for (Indicacao indicacao : indicacoesList) {
            indicacao.setMatriculado(true);
            indicacaoDAO.update(indicacao);
        }
        for (TurmaEfetiva turmaEfetiva : turmasList) {
            turmaEfetiva.setAtivado(true);
            turmaDAO.update(turmaEfetiva);
        }
    } 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 : PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) NotificacaoMatriculaDTO(com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO) MatriculaDTO(com.tomasio.projects.trainning.dto.MatriculaDTO) CancelamentoMatriculaDTO(com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO) MatriculaInstrutor(com.tomasio.projects.trainning.model.MatriculaInstrutor) PreMatriculaInstrutor(com.tomasio.projects.trainning.model.PreMatriculaInstrutor) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) 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) ArrayList(java.util.ArrayList) Indicacao(com.tomasio.projects.trainning.model.Indicacao) PreMatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO) MatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.MatriculaInstrutorDTO) 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) PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) MatriculaAlunoDTO(com.tomasio.projects.trainning.dto.MatriculaAlunoDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) PreMatriculaAluno(com.tomasio.projects.trainning.model.PreMatriculaAluno) MatriculaAluno(com.tomasio.projects.trainning.model.MatriculaAluno) 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) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) HashSet(java.util.HashSet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with MatriculaInstrutorDTO

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

the class TurmasEfetivasController method saveMatriculas.

@RequestMapping("/save_matriculas")
public String saveMatriculas(Model model, WebRequest request, final RedirectAttributes redirectAttributes, @ModelAttribute("turma") @Valid TurmaEfetivaDTO turma) {
    String[] selecionados = request.getParameterValues("selecionados");
    if (selecionados == null) {
        selecionados = new String[0];
    }
    List<MatriculaDTO> matriculas = new ArrayList<MatriculaDTO>();
    for (String selecionado : selecionados) {
        IndicacaoDTO indicacao = atividadesEnsinoService.findIndicacao(Long.parseLong(selecionado));
        PessoaDTO pessoa = organizationalService.findPessoa(indicacao.getPessoa().getId());
        MatriculaDTO matricula = null;
        if (indicacao instanceof IndicacaoAlunoDTO) {
            matricula = new MatriculaAlunoDTO();
        } else {
            matricula = new MatriculaInstrutorDTO();
        }
        matricula.setIndicacao(indicacao);
        matricula.setPessoa(pessoa);
        matricula.setTurma(turma);
        matriculas.add(matricula);
    }
    MatriculaDTO[] arrayMatriculas = new MatriculaDTO[matriculas.size()];
    matriculas.toArray(arrayMatriculas);
    try {
        atividadesEnsinoService.createMatricula(arrayMatriculas);
        redirectAttributes.addFlashAttribute("successMessage", "Matrícula criada com sucesso.");
    } catch (CoreException e) {
        redirectAttributes.addFlashAttribute("errorMessage", e.getMessage());
    }
    return "redirect:detail/matriculas";
}
Also used : PreMatriculaDTO(com.tomasio.projects.trainning.dto.PreMatriculaDTO) NotificacaoMatriculaDTO(com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO) MatriculaDTO(com.tomasio.projects.trainning.dto.MatriculaDTO) CancelamentoMatriculaDTO(com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO) IndicacaoAlunoDTO(com.tomasio.projects.trainning.dto.IndicacaoAlunoDTO) PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) MatriculaAlunoDTO(com.tomasio.projects.trainning.dto.MatriculaAlunoDTO) 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) MatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.MatriculaInstrutorDTO) IndicacaoDTO(com.tomasio.projects.trainning.dto.IndicacaoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with MatriculaInstrutorDTO

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

the class AtividadesEnsinoServiceSimpleImpl method createMatricula.

@Override
@Transactional
public Long createMatricula(MatriculaDTO matricula) {
    MatriculaDAO matriculaDAO = factory.getMatriculaDAO();
    IndicacaoDAO indicacaoDAO = factory.getIndicacaoDAO();
    TurmaDAO turmaDAO = factory.getTurmaDAO();
    Matricula _matricula = null;
    if (matricula != null) {
        if (matricula instanceof MatriculaAlunoDTO) {
            _matricula = new MatriculaAluno((MatriculaAlunoDTO) matricula);
        } else {
            _matricula = new MatriculaInstrutor((MatriculaInstrutorDTO) matricula);
        }
    }
    Long id = null;
    try {
        Indicacao _indicacao = _matricula.getIndicacao();
        TurmaEfetiva _turma = _matricula.getTurma();
        id = matriculaDAO.create(_matricula);
        _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("Erro em tempo de execução: " + ex.getMessage());
    }
    return id;
}
Also used : MatriculaInstrutor(com.tomasio.projects.trainning.model.MatriculaInstrutor) PreMatriculaInstrutor(com.tomasio.projects.trainning.model.PreMatriculaInstrutor) StatusTurmaEfetiva(com.tomasio.projects.trainning.model.StatusTurmaEfetiva) TurmaEfetiva(com.tomasio.projects.trainning.model.TurmaEfetiva) 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) PreMatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO) MatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.MatriculaInstrutorDTO) 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) PreMatriculaAlunoDTO(com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO) MatriculaAlunoDTO(com.tomasio.projects.trainning.dto.MatriculaAlunoDTO) DAOException(com.tomasio.projects.trainning.exception.DAOException) PreMatriculaAluno(com.tomasio.projects.trainning.model.PreMatriculaAluno) MatriculaAluno(com.tomasio.projects.trainning.model.MatriculaAluno) 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) TurmaDAO(com.tomasio.projects.trainning.dao.TurmaDAO) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with MatriculaInstrutorDTO

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

the class MatriculaInstrutor method createDTOMinimal.

@Override
public MatriculaDTO createDTOMinimal() {
    MatriculaInstrutorDTO dto = new MatriculaInstrutorDTO();
    dto.setId(id);
    dto.setCancelada(isCancelada());
    dto.setDesligado(isDesligado());
    return dto;
}
Also used : MatriculaInstrutorDTO(com.tomasio.projects.trainning.dto.MatriculaInstrutorDTO)

Aggregations

MatriculaInstrutorDTO (com.tomasio.projects.trainning.dto.MatriculaInstrutorDTO)10 MatriculaAlunoDTO (com.tomasio.projects.trainning.dto.MatriculaAlunoDTO)6 PreMatriculaAlunoDTO (com.tomasio.projects.trainning.dto.PreMatriculaAlunoDTO)6 PreMatriculaInstrutorDTO (com.tomasio.projects.trainning.dto.PreMatriculaInstrutorDTO)6 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)5 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)4 CoreException (com.tomasio.projects.trainning.exeption.CoreException)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 CancelamentoMatriculaDAO (com.tomasio.projects.trainning.dao.CancelamentoMatriculaDAO)3 MatriculaDAO (com.tomasio.projects.trainning.dao.MatriculaDAO)3 NotificacaoMatriculaDAO (com.tomasio.projects.trainning.dao.NotificacaoMatriculaDAO)3 PreMatriculaDAO (com.tomasio.projects.trainning.dao.PreMatriculaDAO)3 PessoaDTO (com.tomasio.projects.trainning.dto.PessoaDTO)3 DAOException (com.tomasio.projects.trainning.exception.DAOException)3 CancelamentoMatricula (com.tomasio.projects.trainning.model.CancelamentoMatricula)3 Matricula (com.tomasio.projects.trainning.model.Matricula)3 MatriculaAluno (com.tomasio.projects.trainning.model.MatriculaAluno)3 MatriculaInstrutor (com.tomasio.projects.trainning.model.MatriculaInstrutor)3 NotificacaoMatricula (com.tomasio.projects.trainning.model.NotificacaoMatricula)3 PreMatricula (com.tomasio.projects.trainning.model.PreMatricula)3