@RequestMapping(value = "/add/{id}", method = RequestMethod.POST)
 public String add(@Valid LocatorDTO locatorDTO, BindingResult br) {
   if (br.hasErrors()) {
     return "locator/add";
   }
   CaseBean caseBean = new CaseBean();
   caseBean.setId(locatorDTO.getCaseId());
   LocatorBean locatorBean = new LocatorBean();
   locatorBean.setCaseBean(caseBean);
   locatorBean.setLocatorData(locatorDTO.getLocatorData());
   locatorBean.setLocatorDataName(locatorDTO.getLocatorDataName());
   locatorBean.setLocatorType(locatorDTO.getLocatorType());
   locatorService.addLocator(locatorBean);
   return "redirect:/locator/case/" + locatorDTO.getCaseId();
 }
Exemplo n.º 2
0
 @RequestMapping(value = "/add/{id}", method = RequestMethod.POST)
 public String add(
     @PathVariable Integer id, @Valid DataDTO dataDTO, BindingResult br, Model model) {
   if (br.hasErrors()) {
     model.addAttribute(caseService.getCaseBean(id));
     return "data/add";
   }
   CaseBean caseBean = new CaseBean();
   DataBean dataBean = new DataBean();
   caseBean.setId(dataDTO.getCaseId());
   dataBean.setCaseBean(caseBean);
   dataBean.setDataContent(dataDTO.getDataContent());
   dataBean.setDataName(dataDTO.getDataName());
   dataService.addData(dataBean);
   return "redirect:/data/list/" + dataDTO.getCaseId();
 }
  @RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
  public String update(
      @PathVariable Integer id, @Valid LocatorDTO locatorDTO, BindingResult br, Model model) {
    if (br.hasErrors()) {
      return "locator/edit";
    }
    CaseBean caseBean = new CaseBean();
    caseBean.setId(locatorDTO.getCaseId());

    LocatorBean locatorBean = locatorService.getLocatorBean(id);
    locatorBean.setCaseBean(caseBean);
    locatorBean.setLocatorData(locatorDTO.getLocatorData());
    locatorBean.setLocatorDataName(locatorDTO.getLocatorDataName());
    locatorBean.setLocatorType(locatorDTO.getLocatorType());
    locatorService.updateLocator(locatorBean);
    return "redirect:/locator/case/" + locatorDTO.getCaseId();
  }