Esempio n. 1
0
  @RequestMapping("TMA/{id}/**")
  public void downloadTMA(@PathVariable("id") Long id, HttpServletResponse response)
      throws IOException {
    TinggiMukaAir tma = tinggiMukaAirService.findById(id);
    if (tma == null) return;

    response.setContentType(contentTypeUtils.getContentType(tma.getFilename()));
    tinggiMukaAirService.getBlob(id, response.getOutputStream());
  }
Esempio n. 2
0
  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());
    }
  }
Esempio n. 3
0
 @RequestMapping(value = "{wsId}/{dasId}/remove.html", method = RequestMethod.POST)
 public ModelAndView removeTMA(
     @PathVariable("wsId") Long wsId,
     @PathVariable("dasId") Long dasId,
     @RequestParam(value = "ids", required = false) Long[] ids)
     throws IOException {
   if (ids != null) {
     tinggiMukaAirService.removeByIds(ids);
   }
   return createTMASuccessView(wsId, dasId);
 }
Esempio n. 4
0
  @RequestMapping(value = "list/{wsId}/{dasId}.html")
  public ModelAndView list(@PathVariable("wsId") Long wsId, @PathVariable("dasId") Long dasId) {
    ModelAndView mav = new ModelAndView("admin/sda/hidrologi/tinggi_muka_air/list_tma");

    WilayahSungai ws = wilayahSungaiService.findById(wsId);
    mav.addObject("ws", ws);

    Das das = dasService.findById(dasId);
    mav.addObject("das", das);

    mav.addObject("listTMA", tinggiMukaAirService.findByDas(das));
    return mav;
  }
Esempio n. 5
0
  @RequestMapping(value = "{wsId}/{dasId}/edit/{id}.html", method = RequestMethod.GET)
  public ModelAndView editTMA(
      @PathVariable("wsId") Long wsId,
      @PathVariable("dasId") Long dasId,
      @PathVariable("id") Long id,
      @ModelAttribute("form") TinggiMukaAirForm form) {
    TinggiMukaAir tma = tinggiMukaAirService.findById(id);
    form.setDescription(tma.getDescription());
    if (tma.getYear() != null) {
      form.setYear(tma.getYear().getId());
    }

    return createTMAFormView(wsId, dasId);
  }