示例#1
0
  public void createComment() {
    try {
      Comments com = new Comments();
      Date date = new Date();
      com.setComId(1);
      com.setAccomId(curAccom);
      com.setCustId(curAccom.getCustId());
      com.setContent(commentMessage);
      com.setComDate(date);

      commentsFacade.create(com);
    } catch (Exception ex) {
      printStackTrace();
    }
  }
示例#2
0
  public String displayRoomDetail(int id) {
    try {
      Accommodation accom = accommodationFacade.find(id);
      if (accom != null) {
        curAccom = new Accommodation();
        curAccom.setAccomName(accom.getAccomName());
        curAccom.setDescription(accom.getDescription());
        curAccom.setPrice(accom.getPrice());
        curAccom.setAccomId(id);
        curAccom.setNoOfBed(accom.getNoOfBed());
        curAccom.setNoOfPersons(accom.getNoOfPersons());
        curAccom.setNoOfToilet(accom.getNoOfToilet());
        curAccom.setCustId(customerFacade.find(1));

        List<Comments> commentsCount =
            commentsFacade.findCommentsByAccomId(
                id); // != null ? commentsFacade.findCommentsByAccomId(id).size() : 0;
        Gson gson = new Gson();
        RoomImage roomImage = gson.fromJson(accom.getImages(), RoomImage.class);
        // curAccom.setImages(accom.getImages());
        slider1 = roomImage.getSlider1();
        slider2 = roomImage.getSlider2();
        slider3 = roomImage.getSlider3();

        List<Rating> ratings = ratingFacade.findByAccRoomId(id);
        int sumRateScore = 0;
        for (Rating rate : ratings) {
          sumRateScore += rate.getScore();
        }
        displayRate = ratings.size() > 0 ? sumRateScore / ratings.size() : 0;
      }
    } catch (Exception ex) {
      printStackTrace();
    }
    return "roomdetail";
  }