Exemplo n.º 1
0
  /** Show all Room entities */
  @RequestMapping("/indexRoom")
  public ModelAndView listRooms() {
    ModelAndView mav = new ModelAndView();

    mav.addObject("rooms", roomService.loadRooms());

    mav.setViewName("room/listRooms.jsp");

    return mav;
  }
Exemplo n.º 2
0
  /** Save an existing Roomtype entity */
  @RequestMapping("/saveRoomRoomtype")
  public ModelAndView saveRoomRoomtype(
      @RequestParam Integer room_roomId, @ModelAttribute Roomtype roomtype) {
    Room parent_room = roomService.saveRoomRoomtype(room_roomId, roomtype);

    ModelAndView mav = new ModelAndView();
    mav.addObject("room_roomId", room_roomId);
    mav.addObject("room", parent_room);
    mav.setViewName("room/viewRoom.jsp");

    return mav;
  }
Exemplo n.º 3
0
  /** Delete an existing Roomtype entity */
  @RequestMapping("/deleteRoomRoomtype")
  public ModelAndView deleteRoomRoomtype(
      @RequestParam Integer room_roomId, @RequestParam Integer related_roomtype_roomTypeId) {
    ModelAndView mav = new ModelAndView();

    Room room = roomService.deleteRoomRoomtype(room_roomId, related_roomtype_roomTypeId);

    mav.addObject("room_roomId", room_roomId);
    mav.addObject("room", room);
    mav.setViewName("room/viewRoom.jsp");

    return mav;
  }
Exemplo n.º 4
0
 /** Delete an existing Room entity */
 @RequestMapping("/deleteRoom")
 public String deleteRoom(@RequestParam Integer roomIdKey) {
   Room room = roomDAO.findRoomByPrimaryKey(roomIdKey);
   roomService.deleteRoom(room);
   return "forward:/indexRoom";
 }
Exemplo n.º 5
0
  /** Save an existing Room entity */
  @RequestMapping("/saveRoom")
  public String saveRoom(
      @ModelAttribute Room room,
      @RequestParam(value = "file1") MultipartFile file1,
      @RequestParam(value = "file2") MultipartFile file2,
      @RequestParam(value = "file3") MultipartFile file3,
      @RequestParam(value = "file4") MultipartFile file4) {
    System.out.println(file1.getOriginalFilename());
    System.out.println(file2.getOriginalFilename());
    System.out.println(file3.getOriginalFilename());
    System.out.println(file4.getOriginalFilename());
    System.out.println(System.getProperty("user.dir"));
    InputStream inputStream = null;
    OutputStream outputStream = null;
    String path = System.getProperty("user.dir");

    try {
      inputStream = file1.getInputStream();
      System.out.println(file1.getOriginalFilename());
      File newFile =
          new File(
              "/usr/local/pms/apache-tomcat-7.0.42/webapps/pms/roomimages/"
                  + file1.getOriginalFilename());
      if (!newFile.exists()) {
        newFile.createNewFile();
      }
      outputStream = new FileOutputStream(newFile);
      int read = 0;
      byte[] bytes = new byte[1024];

      while ((read = inputStream.read(bytes)) != -1) {
        outputStream.write(bytes, 0, read);
      }
      room.setImage1("http://65.181.118.166:9090/pms/roomimages/" + file1.getOriginalFilename());
      outputStream.close();
      inputStream.close();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }

    try {
      inputStream = file2.getInputStream();
      System.out.println(file2.getOriginalFilename());
      File newFile =
          new File(
              "/usr/local/pms/apache-tomcat-7.0.42/webapps/pms/roomimages/"
                  + file2.getOriginalFilename());
      if (!newFile.exists()) {
        newFile.createNewFile();
      }
      outputStream = new FileOutputStream(newFile);
      int read = 0;
      byte[] bytes = new byte[1024];

      while ((read = inputStream.read(bytes)) != -1) {
        outputStream.write(bytes, 0, read);
      }
      outputStream.close();
      inputStream.close();
      room.setImage2("http://65.181.118.166:9090/pms/roomimages/" + file2.getOriginalFilename());
    } catch (IOException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }

    try {
      inputStream = file3.getInputStream();
      System.out.println(file3.getOriginalFilename());
      File newFile =
          new File(
              "/usr/local/pms/apache-tomcat-7.0.42/webapps/pms/roomimages/"
                  + file3.getOriginalFilename());
      if (!newFile.exists()) {
        newFile.createNewFile();
      }
      outputStream = new FileOutputStream(newFile);
      int read = 0;
      byte[] bytes = new byte[1024];

      while ((read = inputStream.read(bytes)) != -1) {
        outputStream.write(bytes, 0, read);
      }
      outputStream.close();
      inputStream.close();
      room.setImage3("http://65.181.118.166:9090/pms/roomimages/" + file3.getOriginalFilename());
    } catch (IOException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }

    try {
      inputStream = file4.getInputStream();
      System.out.println(file4.getOriginalFilename());
      File newFile =
          new File(
              "/usr/local/pms/apache-tomcat-7.0.42/webapps/pms/roomimages/"
                  + file4.getOriginalFilename());
      if (!newFile.exists()) {
        newFile.createNewFile();
      }
      outputStream = new FileOutputStream(newFile);
      int read = 0;
      byte[] bytes = new byte[1024];

      while ((read = inputStream.read(bytes)) != -1) {
        outputStream.write(bytes, 0, read);
      }
      outputStream.close();
      inputStream.close();
      room.setImage4("http://65.181.118.166:9090/pms/roomimages/" + file4.getOriginalFilename());
    } catch (IOException e) {
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }

    /*Blob blob = null;
    try {
    	if(null != file1){
    		blob = Hibernate.createBlob(file1.getInputStream());
    		room.setImage1(blob);
    	}
    } catch (IOException e) {
    	// TODO Auto-generated catch block
    	e.printStackTrace();
    }
          document.setFilename(file.getOriginalFilename());
          document.setContent(blob);
          document.setContentType(file.getContentType());
    roomService.saveRoom(room);*/
    System.out.println("BEFORE SAVE: " + room.getImage1());
    System.out.println("BEFORE SAVE: " + room.getImage2());
    System.out.println("BEFORE SAVE: " + room.getImage3());
    System.out.println("BEFORE SAVE: " + room.getImage4());
    roomService.saveRoom(room);
    return "forward:/indexRoom";
  }