Beispiel #1
0
  public int getRating() {
    HttpSession session = FacesUtil.getSession();
    User user = (User) session.getAttribute("user");

    Rating userRating = getUserRating(user);
    if (userRating != null) {
      this.rating = userRating.getRating();
    }

    return this.rating;
  }
Beispiel #2
0
  private void refreshRecipe() {
    recipe = new Recipe();
    recipe.setCategory(new Category());
    recipe.setCookingMethod(new Cookingmethod());
    recipe.setCuisine(new Cuisine());
    recipe.setCookingTime(30);
    recipe.setPrepTime(15);
    recipe.setServingQty(4);

    HttpSession session = FacesUtil.getSession();
    User user = (User) session.getAttribute("user");
    recipe.setUserId(user);

    recipe.setCreatedDate("2014");
    recipe.setStatus("requested");

    recipe.setRecipeingredientList(ingredients);
  }
Beispiel #3
0
  public void onrate(RateEvent rateEvent) {

    HttpSession session = FacesUtil.getSession();
    User user = (User) session.getAttribute("user");

    Rating userRating = getUserRating(user);

    int score = ((Integer) rateEvent.getRating()).intValue();
    Rating rate = new Rating();
    rate.setRating(score);
    rate.setRecipe(recipe);
    rate.setUserId(user);

    if (userRating == null) {
      serviceRating.create(rate);
    } else {
      rate.setId(userRating.getId());
      serviceRating.update(rate);
    }
  }