Package com.springone.myrestaurants.domain

Examples of com.springone.myrestaurants.domain.UserAccount


    }


  private Recommendation findRecommendation(Long userId,
      Long recommendationId) {
    UserAccount account = this.userAccountRepository.findUserAccount(userId);
    Iterable<Recommendation> recs = account.getRecommendations();
    Recommendation foundRec = null;
    for (Recommendation recommendation : recs) {
      if (recommendation.getRelationshipId().equals(recommendationId)) {
        foundRec = recommendation;
      }
View Full Code Here


    public String list(@RequestParam(value = "page", required = false) Integer page,
               @RequestParam(value = "size", required = false) Integer size,
               @ModelAttribute("currentUserAccountId") Long userId,
               Model model) {

    UserAccount account = this.userAccountRepository.findUserAccount(userId);
    Iterable<Recommendation> recs = account.getRecommendations();
    //View expects a list with indexer access and properties that match those of the form bean.
    List<RecommendationFormBean> listRecs = new ArrayList<RecommendationFormBean>();
    for (Recommendation recommendation : recs) {
      RecommendationFormBean rfb = new RecommendationFormBean();
            final Restaurant restaurant = recommendation.getRestaurant();
View Full Code Here

      model.addAttribute("recommendation", recommendationFormBean);
      return "recommendations/create";
    }
    long restaurantId = recommendationFormBean.getRestaurantId();
    Restaurant restaurant = this.restaurantRepository.findRestaurant(restaurantId);
    UserAccount account = this.userAccountRepository.findUserAccount(userId);
    Recommendation recommendation = account.rate(restaurant,
        recommendationFormBean.getRating(),
        recommendationFormBean.getComments());
    model.addAttribute("recommendationId", recommendation.getRelationshipId());
    return "redirect:/recommendations/" + recommendation.getRelationshipId();
  }
View Full Code Here

        return "redirect:/useraccounts/" + userAccount.getId();
    }

  @RequestMapping(params = "form", method = RequestMethod.GET)
    public String createForm(Model model) {
        model.addAttribute("userAccount", new UserAccount());
        addDateTimeFormatPatterns(model);
        return "useraccounts/create";
    }
View Full Code Here

        if (result.hasErrors()) {
            model.addAttribute("userAccount", userAccount);
            addDateTimeFormatPatterns(model);
            return "useraccounts/update";
        }
        final UserAccount mergedAccount = userAccountRepository.merge(userAccount);
        return "redirect:/useraccounts/" + mergedAccount.getId();
    }
View Full Code Here

        return "useraccounts/update";
    }
 
  @RequestMapping(value = "/{username}", params = "form2", method = RequestMethod.GET)
    public String updateForm(@PathVariable("username") String userName, Model model) {
    UserAccount userAccount = userAccountRepository.findByName(userName);
        model.addAttribute("userAccount", userAccount);
        addDateTimeFormatPatterns(model);
        return "useraccounts/update";
    }
View Full Code Here

 
 
    @RequestMapping(method = RequestMethod.GET)
    public String list(@ModelAttribute("currentUserAccountId") Long userId,
                   Model model) {
      UserAccount currentUser = this.userAccountRepository.findUserAccount(userId);
      Collection<RatedRestaurant> top5 = currentUser.getTop5RatedRestaurants();
      List<RatedRestaurantBean> topn = new ArrayList<RatedRestaurantBean>();
      for (RatedRestaurant rr : top5) {
        RatedRestaurantBean rrb = new RatedRestaurantBean();
        rrb.setId(rr.getRestaurant().getId());
        rrb.setName(rr.getRestaurant().getName());
View Full Code Here

        if (result.hasErrors()) {
            model.addAttribute("friend", friend);
            return "friends/create";
        }
        //TODO additional error checking
        UserAccount account = this.userAccountRepository.findUserAccount(userId);
        UserAccount friendAccount = this.userAccountRepository.findByName(friend.getUserName());
        if (friendAccount != null) {
          account.getFriends().add(friendAccount);
        }
        return "redirect:/friends/" + friendAccount.getId();
    }
View Full Code Here

        return "friends/create";
    }
   
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public String show(@PathVariable("id") Long id, Model model) {
      UserAccount friendAccount = this.userAccountRepository.findUserAccount(id);
        model.addAttribute("friend", friendAccount);
        model.addAttribute("itemId", id);
        return "friends/show";
    }
View Full Code Here

    public String list(@RequestParam(value = "page", required = false) Integer page,
                   @RequestParam(value = "size", required = false) Integer size,
                   @ModelAttribute("currentUserAccountId") Long userId,
                   Model model) {
     
      UserAccount currentUser = this.userAccountRepository.findUserAccount(userId);
      Set<UserAccount> friends = currentUser.getFriends();
      model.addAttribute("friends", friends);
     
        return "friends/list";
    }
View Full Code Here

TOP

Related Classes of com.springone.myrestaurants.domain.UserAccount

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.