Search in sources :

Example 6 with ConclusaoDTO

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

the class TurmasEfetivasController method saveConclusao.

@RequestMapping("/save_conclusao")
public String saveConclusao(Model model, WebRequest request) {
    String matriculaId = request.getParameter("alunoNaoConcluidoId");
    MatriculaDTO matricula = atividadesEnsinoService.findMatricula(Long.parseLong(matriculaId));
    ConclusaoDTO conclusao = new ConclusaoDTO();
    CapacitacaoDTO capacitacao = trainningService.findCurso(matricula.getTurma().getCurso().getId());
    PeriodoDTO periodo = new PeriodoDTO();
    periodo.setDataInicio(matricula.getTurma().getDataInicio());
    periodo.setDataTermino(matricula.getTurma().getDataTermino());
    int ano = 0;
    SimpleDateFormat df = new SimpleDateFormat("yyyy");
    if (matricula.getTurma().getExercicio() != null) {
        Integer.parseInt(df.format(matricula.getTurma().getExercicio()));
    }
    conclusao.setAno(ano);
    conclusao.setCapacitacao(capacitacao);
    conclusao.setLocal(matricula.getTurma().getLocal());
    conclusao.setMatricula(matricula);
    conclusao.setPeriodo(periodo);
    conclusao.setPessoa(matricula.getPessoa());
    try {
        atividadesEnsinoService.createConclusao(conclusao);
        model.addAttribute("successMessage", "Conclusão realizada com sucesso.");
    } catch (CoreException e) {
        model.addAttribute("errorMessage", e.getMessage());
    }
    model.addAttribute("tab", "concluidos");
    return "redirect:detail/conclusoes";
}
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) CoreException(com.tomasio.projects.trainning.exeption.CoreException) CertificadoConclusaoDTO(com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO) ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) PeriodoDTO(com.tomasio.projects.trainning.dto.PeriodoDTO) CapacitacaoDTO(com.tomasio.projects.trainning.dto.CapacitacaoDTO) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with ConclusaoDTO

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

the class HistoryController method saveConclusao.

@RequestMapping("/save")
public String saveConclusao(Model model, @ModelAttribute("origin") String origin, @Valid ConclusaoFormBean form, BindingResult bindingResult, WebRequest request, final RedirectAttributes redirectAttributes) {
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    Date dataInicio = null;
    Date dataTermino = null;
    try {
        dataInicio = df.parse(form.getDataInicio());
        dataTermino = df.parse(form.getDataTermino());
    } catch (ParseException ex) {
        Logger.getLogger(HistoryController.class.getName()).log(Level.SEVERE, null, ex);
    }
    if (bindingResult.hasErrors()) {
        return "history/form";
    }
    ConclusaoDTO dto = new ConclusaoDTO();
    dto.setId(form.getId());
    dto.setCapacitacao(trainningService.findCurso(form.getCapacitacaoId()));
    dto.setComAproveitamento(true);
    dto.setLocal(form.getLocal());
    dto.setObservacao(form.getObservacao());
    dto.setPessoa(organizationalService.findPessoa(form.getPessoaId()));
    if (dataInicio != null && dataTermino != null) {
        PeriodoDTO periodo = new PeriodoDTO();
        periodo.setDataInicio(dataInicio);
        periodo.setDataTermino(dataTermino);
        dto.setPeriodo(periodo);
    }
    if (dto.getId() > 0) {
        try {
            atividadesEnsinoService.updateConclusao(dto);
            redirectAttributes.addFlashAttribute("selectedPerson", dto.getPessoa());
            redirectAttributes.addFlashAttribute("selectedCourse", dto.getCapacitacao());
            redirectAttributes.addFlashAttribute("successMessage", "Registro atualizado com sucesso.");
            return "redirect:" + origin;
        } catch (CoreException e) {
            redirectAttributes.addFlashAttribute("errorMessage", e.getMessage());
            return "history/form";
        }
    } else {
        try {
            ConclusaoDTO[] conclusoes = new ConclusaoDTO[1];
            conclusoes[0] = dto;
            atividadesEnsinoService.createConclusao(conclusoes);
            redirectAttributes.addFlashAttribute("selectedPerson", dto.getPessoa());
            redirectAttributes.addFlashAttribute("selectedCourse", dto.getCapacitacao());
            redirectAttributes.addFlashAttribute("successMessage", "Registro criado com sucesso.");
            return "redirect:" + origin;
        } catch (CoreException e) {
            redirectAttributes.addFlashAttribute("errorMessage", e.getMessage());
            return "history/form";
        }
    }
}
Also used : CoreException(com.tomasio.projects.trainning.exeption.CoreException) ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) PeriodoDTO(com.tomasio.projects.trainning.dto.PeriodoDTO) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with ConclusaoDTO

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

the class HistoryController method showPersonHistory.

@RequestMapping("/person")
public String showPersonHistory(Model model, WebRequest request) {
    String pessoaIdParam = request.getParameter("pessoaId");
    PessoaDTO pessoa = null;
    if (pessoaIdParam == null || pessoaIdParam.equals("") || pessoaIdParam.equals("NULL")) {
        pessoa = (PessoaDTO) model.asMap().get("selectedPerson");
        if (pessoa == null) {
            model.addAttribute("target", "view");
            return "redirect:select_pessoa";
        }
    } else {
        pessoa = organizationalService.findPessoa(Long.parseLong(pessoaIdParam));
        model.addAttribute("selectedPerson", pessoa);
    }
    ConclusaoDTO[] conclusoes = atividadesEnsinoService.findAllConcluidosByPessoa(pessoa.getId(), true);
    List<Map<Object, Object>> conclusoesDataList = new ArrayList<Map<Object, Object>>();
    for (ConclusaoDTO conclusaoDTO : conclusoes) {
        // if (conclusaoDTO.getPessoa().isAtivo()) {
        Map<Object, Object> item = new HashMap<Object, Object>();
        if (conclusaoDTO.getCapacitacao() instanceof CursoDTO) {
            CursoDTO curso = (CursoDTO) conclusaoDTO.getCapacitacao();
            item.put("codigo", curso.getCodigo());
            item.put("descricao", curso.getDescricao());
        }
        item.put("local", conclusaoDTO.getLocal());
        item.put("observacao", conclusaoDTO.getObservacao());
        if (conclusaoDTO.getPeriodo() != null) {
            item.put("periodo", conclusaoDTO.getPeriodo().getPeriodoFormatted());
        }
        item.put("editable", (conclusaoDTO.getMatricula() == null));
        item.put("id", conclusaoDTO.getId());
        conclusoesDataList.add(item);
    // }
    }
    model.addAttribute("conclusoesDataList", conclusoesDataList);
    model.addAttribute("pessoa", pessoa);
    model.addAttribute("emails", pessoa.getEmails());
    model.addAttribute("telefones", pessoa.getTelefones());
    return "history/person";
}
Also used : PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with ConclusaoDTO

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

the class HistoryController method showCourseHistory.

@RequestMapping("/course")
public String showCourseHistory(Model model, WebRequest request) {
    String cursoIdParam = request.getParameter("cursoId");
    CursoDTO curso = null;
    if (cursoIdParam == null || cursoIdParam.equals("") || cursoIdParam.equals("NULL")) {
        curso = (CursoDTO) model.asMap().get("selectedCourse");
        if (curso == null) {
            model.addAttribute("target", "view");
            return "redirect:select_curso";
        }
    } else {
        curso = trainningService.findCurso(Long.parseLong(cursoIdParam));
        model.addAttribute("selectedCourse", curso);
    }
    ConclusaoDTO[] conclusoes = atividadesEnsinoService.findAllConcluidosByCapacitacao(curso.getId(), true);
    List<Map<Object, Object>> conclusoesDataList = new ArrayList<Map<Object, Object>>();
    for (ConclusaoDTO conclusaoDTO : conclusoes) {
        if (conclusaoDTO.getPessoa().isAtivo()) {
            Map<Object, Object> item = new HashMap<Object, Object>();
            item.put("tarjeta", conclusaoDTO.getPessoa().getTargetaCompletaOM());
            item.put("local", conclusaoDTO.getLocal());
            item.put("observacao", conclusaoDTO.getObservacao());
            item.put("editable", (conclusaoDTO.getMatricula() == null));
            item.put("id", conclusaoDTO.getId());
            if (conclusaoDTO.getPeriodo() != null) {
                item.put("periodo", conclusaoDTO.getPeriodo().getPeriodoFormatted());
            }
            conclusoesDataList.add(item);
        }
    }
    model.addAttribute("conclusoesDataList", conclusoesDataList);
    model.addAttribute("curso", curso);
    return "history/course";
}
Also used : ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) HashMap(java.util.HashMap) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with ConclusaoDTO

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

the class HistoryController method editConclusao.

@RequestMapping("/edit")
public String editConclusao(Model model, WebRequest request) {
    String origin = request.getParameter("origin");
    if (origin != null) {
        model.addAttribute("origin", origin);
    }
    SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    String conclusaoIdParam = request.getParameter("conclusaoId");
    ConclusaoDTO conclusao = atividadesEnsinoService.findConclusao(Long.parseLong(conclusaoIdParam));
    ConclusaoFormBean form = new ConclusaoFormBean();
    form.setId(conclusao.getId());
    form.setCapacitacaoId(conclusao.getCapacitacao().getId());
    form.setPessoaId(conclusao.getPessoa().getId());
    form.setObservacao(conclusao.getObservacao());
    form.setLocal(conclusao.getLocal());
    if (conclusao.getPeriodo() != null) {
        PeriodoDTO periodo = conclusao.getPeriodo();
        if (periodo.getDataInicio() != null) {
            form.setDataInicio(df.format(periodo.getDataInicio()));
        }
        if (periodo.getDataTermino() != null) {
            form.setDataTermino(df.format(periodo.getDataTermino()));
        }
    }
    model.addAttribute("pessoa", conclusao.getPessoa());
    model.addAttribute("curso", conclusao.getCapacitacao());
    model.addAttribute(form);
    return "history/form";
}
Also used : ConclusaoDTO(com.tomasio.projects.trainning.dto.ConclusaoDTO) PeriodoDTO(com.tomasio.projects.trainning.dto.PeriodoDTO) ConclusaoFormBean(com.tomasio.projects.trainning.form.ConclusaoFormBean) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ConclusaoDTO (com.tomasio.projects.trainning.dto.ConclusaoDTO)36 ArrayList (java.util.ArrayList)20 CertificadoConclusaoDTO (com.tomasio.projects.trainning.dto.CertificadoConclusaoDTO)18 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)18 CoreException (com.tomasio.projects.trainning.exeption.CoreException)12 HashMap (java.util.HashMap)11 Map (java.util.Map)11 MatriculaDTO (com.tomasio.projects.trainning.dto.MatriculaDTO)10 CancelamentoMatriculaDTO (com.tomasio.projects.trainning.dto.CancelamentoMatriculaDTO)9 OrganizacaoDTO (com.tomasio.projects.trainning.dto.OrganizacaoDTO)9 SimpleDateFormat (java.text.SimpleDateFormat)9 CertificadoConclusaoDAO (com.tomasio.projects.trainning.dao.CertificadoConclusaoDAO)7 ConclusaoDAO (com.tomasio.projects.trainning.dao.ConclusaoDAO)7 PreMatriculaDTO (com.tomasio.projects.trainning.dto.PreMatriculaDTO)7 DAOException (com.tomasio.projects.trainning.exception.DAOException)7 CertificadoConclusao (com.tomasio.projects.trainning.model.CertificadoConclusao)7 Conclusao (com.tomasio.projects.trainning.model.Conclusao)7 Transactional (org.springframework.transaction.annotation.Transactional)7 NotificacaoMatriculaDTO (com.tomasio.projects.trainning.dto.NotificacaoMatriculaDTO)6 List (java.util.List)6