private ModelAndView createTMAFormView(Long wsId, Long dasId) { ModelAndView mav = new ModelAndView("admin/sda/hidrologi/tinggi_muka_air/form_tma"); mav.addObject("ws", wilayahSungaiService.findById(wsId)); mav.addObject("das", dasService.findById(dasId)); mav.addObject("yearLookup", getYearLookup()); return mav; }
@RequestMapping(value = "list/{wsId}.html") public ModelAndView list(@PathVariable("wsId") Long wsId) { ModelAndView mav = new ModelAndView("admin/sda/hidrologi/tinggi_muka_air/list_das"); WilayahSungai ws = wilayahSungaiService.findById(wsId); mav.addObject("ws", ws); mav.addObject("listDas", dasService.findByWilayahSungai(ws)); return mav; }
private void saveTMAForm(Long id, TinggiMukaAirForm form, Long dasId) throws IOException { TinggiMukaAir tma = (id == null ? new TinggiMukaAir() : tinggiMukaAirService.findById(id)); tma.setDescription(form.getDescription()); Year year = yearService.findById(form.getYear()); tma.setYear(year); Das das = dasService.findById(dasId); tma.setDas(das); if (form.getFile() == null || form.getFile().isEmpty()) { tinggiMukaAirService.save(tma); } else { tma.setFilename(form.getFile().getOriginalFilename()); tinggiMukaAirService.save(tma, form.getFile().getInputStream()); } }