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; }
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); }
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); } }