Search in sources :

Example 1 with ConclusaoFormBean

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

Example 2 with ConclusaoFormBean

use of com.tomasio.projects.trainning.form.ConclusaoFormBean in project trainning by fernandotomasio.

the class HistoryController method newConclusao.

@RequestMapping("/new")
public String newConclusao(Model model, WebRequest request) {
    String origin = request.getParameter("origin");
    if (origin != null) {
        model.addAttribute("origin", origin);
    }
    model.addAttribute("target", "edit");
    String pessoaIdParam = request.getParameter("pessoaId");
    String cursoIdParam = request.getParameter("cursoId");
    if (pessoaIdParam == null) {
        if (model.asMap().get("person") == null) {
            return "redirect:select_pessoa";
        }
    } else {
        model.addAttribute("person", organizationalService.findPessoa(Long.parseLong(pessoaIdParam)));
    }
    if (cursoIdParam == null) {
        if (model.asMap().get("course") == null) {
            return "redirect:select_curso";
        }
    } else {
        model.addAttribute("course", trainningService.findCurso(Long.parseLong(cursoIdParam)));
    }
    PessoaDTO pessoa = (PessoaDTO) model.asMap().get("person");
    CursoDTO curso = (CursoDTO) model.asMap().get("course");
    model.asMap().remove("person");
    model.asMap().remove("course");
    ConclusaoFormBean form = new ConclusaoFormBean();
    form.setPessoaId(pessoa.getId());
    form.setCapacitacaoId(curso.getId());
    form.setOrigin(request.getParameter("origin"));
    model.addAttribute(form);
    model.addAttribute("pessoa", pessoa);
    model.addAttribute("curso", curso);
    return "history/form";
}
Also used : PessoaDTO(com.tomasio.projects.trainning.dto.PessoaDTO) ConclusaoFormBean(com.tomasio.projects.trainning.form.ConclusaoFormBean) CursoDTO(com.tomasio.projects.trainning.dto.CursoDTO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ConclusaoFormBean (com.tomasio.projects.trainning.form.ConclusaoFormBean)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ConclusaoDTO (com.tomasio.projects.trainning.dto.ConclusaoDTO)1 CursoDTO (com.tomasio.projects.trainning.dto.CursoDTO)1 PeriodoDTO (com.tomasio.projects.trainning.dto.PeriodoDTO)1 PessoaDTO (com.tomasio.projects.trainning.dto.PessoaDTO)1 SimpleDateFormat (java.text.SimpleDateFormat)1