@RequestMapping(value = "edit", method = RequestMethod.GET) public ModelAndView edit( @ModelAttribute(value = "Schedule") Schedule schedule, @Context HttpServletRequest request) { ModelAndView mv = null; int id = Integer.parseInt(request.getParameter("id")); Schedule sch = scheduleService.getByScheduleId(id); if (sch != null) { mv = new ModelAndView("adminSchedule/edit"); mv.addObject("schedule", sch); mv.addObject("applicant", applicantService.getByApplicantId(sch.getApplicantId())); mv.addObject("applicants", applicantService.getAll()); mv.addObject("role", roleService.getByRoleId(sch.getInterviewer())); mv.addObject("roles", roleService.getAll()); } return mv; }
@Override public int update(Schedule s) { return jdbcTemplate.update( SQLCommand.SCHEDULE_UPDATE, new Object[] { s.getApplicantId(), s.getScheduleDate(), s.getScheduleTime(), s.getInterviewer(), s.getEditDate(), s.getMessageForApplicant(), s.getMessageForInterviewer(), s.getScheduleStatus(), s.getRemarks(), s.getScheduleId() }); }
@RequestMapping(value = "save", method = RequestMethod.POST) public String save( @ModelAttribute(value = "Schedule") Schedule schedule, @Context HttpServletRequest request) throws ParseException { Calendar calendar = Calendar.getInstance(); schedule.setScheduleDate(calendar.getTime()); DateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd"); Date formatedDate = formatDate.parse(request.getParameter("schedule_date")); schedule.setScheduleDate(formatedDate); schedule.setScheduleTime(calendar.getTime()); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); Date SimpleDateFormat = sdf.parse(request.getParameter("schedule_time")); schedule.setScheduleTime(SimpleDateFormat); scheduleService.insert(schedule); return "redirect:/admin/schedule"; }
private Schedule mapData(ResultSet rs) throws SQLException { Schedule schedule = new Schedule(); schedule.setApplicantId(rs.getInt("applicant_id")); schedule.setInterviewer(rs.getInt("interviewer")); schedule.setMessageForApplicant(rs.getString("message_for_applicant")); schedule.setMessageForInterviewer(rs.getString("message_for_interviewer")); schedule.setRemarks(rs.getString("remarks")); schedule.setScheduleDate(rs.getDate("schedule_date")); schedule.setScheduleTime(rs.getTime("schedule_time")); schedule.setEditDate(rs.getDate("edit_date")); schedule.setScheduleId(rs.getInt("schedule_id")); schedule.setScheduleStatus(rs.getBoolean("schedule_status")); /*if(rs.getTime("schedule_time")!=null){ schedule.setScheduleTime(rs.getTime("schedule_time")); }*/ return schedule; }