Пример #1
0
 /**
  * Creates a {@link MapSqlParameterSource} based on data values from the supplied {@link Visit}
  * instance.
  */
 private MapSqlParameterSource createVisitParameterSource(Visit visit) {
   return new MapSqlParameterSource()
       .addValue("id", visit.getId())
       .addValue("visit_date", visit.getDate())
       .addValue("description", visit.getDescription())
       .addValue("pet_id", visit.getPet().getId());
 }
Пример #2
0
 @Transactional
 public void storeVisit(Visit visit) throws DataAccessException {
   if (visit.isNew()) {
     Number newKey = this.insertVisit.executeAndReturnKey(createVisitParameterSource(visit));
     visit.setId(newKey.intValue());
   } else {
     throw new UnsupportedOperationException("Visit update not supported");
   }
 }
Пример #3
0
 @RequestMapping(method = RequestMethod.POST)
 public String processSubmit(
     @ModelAttribute("visit") Visit visit, BindingResult result, SessionStatus status) {
   new VisitValidator().validate(visit, result);
   if (result.hasErrors()) {
     return "visitForm";
   } else {
     this.clinic.storeVisit(visit);
     status.setComplete();
     return "redirect:owner.do?ownerId=" + visit.getPet().getOwner().getId();
   }
 }
Пример #4
0
 /** Method inserts a new <code>Visit</code>. */
 protected ModelAndView onSubmit(Object command) throws ServletException {
   Visit visit = (Visit) command;
   // delegate the insert to the Business layer
   getClinic().storeVisit(visit);
   return new ModelAndView(getSuccessView(), "ownerId", visit.getPet().getOwner().getId());
 }