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";
}
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";
}
Aggregations