use of com.tomasio.projects.trainning.dto.PlanoDTO in project trainning by fernandotomasio.
the class Plano method createDTOMinimal.
public PlanoDTO createDTOMinimal() {
PlanoDTO dto = new PlanoDTO();
dto.setSigla(this.sigla);
dto.setDescricao(this.descricao);
dto.setId(this.id);
dto.setDiasIndicacaoInicio(diasIndicacaoInicio);
dto.setDiasIndicacaoTermino(diasIndicacaoTermino);
dto.setObjectId(this.getObjectId());
dto.setOMResponsavelId(this.OMResponsavelId);
return dto;
}
use of com.tomasio.projects.trainning.dto.PlanoDTO in project trainning by fernandotomasio.
the class PlanosController method showIndex.
@RequestMapping({ "/", "/index", "" })
public String showIndex(Model model, WebRequest request) {
PlanoDTO[] planos = trainningService.findAllPlanos();
model.addAttribute("total", planos.length);
// model.addAttribute("planos", planos);
List dataList = new ArrayList();
for (PlanoDTO plano : planos) {
Map item = new HashMap();
item.put("id", plano.getId());
item.put("sigla", plano.getSigla());
item.put("descricao", plano.getDescricao());
Long omId = plano.getOMResponsavelId();
if (omId != null) {
OrganizacaoDTO om = organizationalService.findOrganizacao(omId);
if (om != null) {
item.put("omsigla", om.getSigla());
} else {
item.put("omsigla", "não informada");
}
} else {
item.put("omsigla", "não informada");
}
dataList.add(item);
}
model.addAttribute("planos", dataList);
return "plano_cadastro";
}
use of com.tomasio.projects.trainning.dto.PlanoDTO in project trainning by fernandotomasio.
the class PlanosController method savePlano.
@RequestMapping("/save")
public String savePlano(Model model, @Valid PlanoForm planoForm, BindingResult bindingResult, WebRequest request, final RedirectAttributes redirectAttributes) {
if (bindingResult.hasErrors()) {
model.addAttribute("OMs", initializeSelectableOMs());
return "plano_cadastro/form";
}
PlanoDTO dto = new PlanoDTO();
dto.setId(planoForm.getId());
dto.setSigla(planoForm.getSigla());
dto.setDescricao(planoForm.getDescricao());
dto.setDiasIndicacaoInicio(planoForm.getDiasIndicacaoInicio());
dto.setDiasIndicacaoTermino(planoForm.getDiasIndicacaoTermino());
dto.setOMResponsavelId(planoForm.getOrganizacaoId());
if (dto.getId() != null) {
try {
trainningService.updatePlano(dto);
// model.addAttribute("successMessage", "Plano atualizado com sucesso.");
redirectAttributes.addFlashAttribute("successMessage", "Plano atualizado com sucesso!");
return "redirect:detail?planoId=" + dto.getId();
// return "plano_cadastro/detail";
} catch (CoreException e) {
model.addAttribute("errorMessage", e.getMessage());
model.addAttribute("OMs", initializeSelectableOMs());
return "plano_cadastro/form";
}
} else {
try {
Long planoId = trainningService.createPlano(dto);
dto.setId(planoId);
redirectAttributes.addFlashAttribute("successMessage", "Plano criado com sucesso!");
// model.addAttribute("item", dto);
return "redirect:detail?planoId=" + planoId;
} catch (CoreException e) {
model.addAttribute("errorMessage", e.getMessage());
model.addAttribute("OMs", initializeSelectableOMs());
return "plano_cadastro/form";
}
}
}
use of com.tomasio.projects.trainning.dto.PlanoDTO in project trainning by fernandotomasio.
the class PlanosController method editPlano.
@RequestMapping("/edit")
public String editPlano(Model model, WebRequest request) {
String planoId = request.getParameter("planoId");
PlanoDTO dto = trainningService.findPlano(Long.parseLong(planoId));
PlanoForm planoForm = new PlanoForm();
planoForm.setId(dto.getId());
planoForm.setSigla(dto.getSigla());
planoForm.setDescricao(dto.getDescricao());
planoForm.setDiasIndicacaoInicio(dto.getDiasIndicacaoInicio());
planoForm.setDiasIndicacaoTermino(dto.getDiasIndicacaoTermino());
planoForm.setOrganizacaoId(dto.getOMResponsavelId());
model.addAttribute("OMs", initializeSelectableOMs());
model.addAttribute("formPlano", planoForm);
return "plano_cadastro/form";
}
use of com.tomasio.projects.trainning.dto.PlanoDTO in project trainning by fernandotomasio.
the class PlanosController method showDetails.
@RequestMapping("/detail")
public String showDetails(Model model, WebRequest request) {
String planoId = request.getParameter("planoId");
PlanoDTO plano = trainningService.findPlano(Long.parseLong(planoId));
// List dataList = new ArrayList();
// dataList.add(data)
Long omId = plano.getOMResponsavelId();
Map item = new HashMap();
item.put("id", plano.getId());
if (omId != null) {
OrganizacaoDTO om = organizationalService.findOrganizacao(omId);
item.put("omsigla", om.getSigla());
}
item.put("sigla", plano.getSigla());
item.put("descricao", plano.getDescricao());
model.addAttribute("item", item);
return "plano_cadastro/detail";
}
Aggregations