Examples of Restaurant


Examples of com.eatle.persistent.pojo.merchant.Restaurant

  private static IRestaurantService restaurantService = (IRestaurantService) ctx.getBean("restaurantService");

  @Test
  public void test()
  {
    Restaurant r = new Restaurant();
    r.setName("肯德基观音桥分店");
    r.setAddress("江北区观音桥北城天街");

    System.out.println(restaurantService.add(r));

    System.out.println(restaurantService.findAll().size());
  }
View Full Code Here

Examples of com.eatle.persistent.pojo.merchant.Restaurant

  }

  @Override
  public Restaurant findById(long id)
  {
    Restaurant restaurant = restaurantMapper.selectByPrimaryKey(id);
    // 设置主营类型
    restaurant.setShopTypeStr(shopTypeService.
        findByIdentify(restaurant.getShopType()).getTypeName());
    // 设置所属商家
    restaurant.setMerchantName(merchantService.
        findById(restaurant.getMerchantId()).getMerchantName());
    return restaurant;
  }
View Full Code Here

Examples of com.eatle.persistent.pojo.merchant.Restaurant

          // 保存文件
          String saveName = ServletActionContext.getServletContext()
              .getRealPath(path) + File.separator + uuidName;
          ImageUtil.thumbnails(logo[i], new File(saveName), 70);
          // 更新餐厅LogoUrl
          Restaurant restaurant = restaurantService.findById(id);
          String oldLogoPath = ServletActionContext.getServletContext()
              .getRealPath(restaurant.getLogoUrl());
          File oldLogoFile = new File(oldLogoPath == null ? "" : oldLogoPath);
          if (oldLogoFile.exists())
          {
            oldLogoFile.delete();
          }
          restaurant.setLogoUrl(path + "/" + uuidName);
          restaurantService.update(restaurant);
        }
      }
      else
      {
View Full Code Here

Examples of com.springone.myrestaurants.domain.Restaurant

    @Transactional
    @Test
    public void testAddRecommendation() {
      UserAccount user = userAccountRepo.findUserAccount(userId);
      Restaurant rest = restaurantRepository.findRestaurant(22L);
      user.rate(rest, 3, "Pretty Good");
      em.flush();
      UserAccount updatedUser = userAccountRepo.findUserAccount(userId);
      Assert.assertNotNull("should have found something" ,updatedUser);
      List<Recommendation> recommendations = new ArrayList<Recommendation>();
      for (Recommendation r : updatedUser.getRecommendations()) {
        recommendations.add(r);
      }
      Assert.assertEquals("user should now have correct number of recommendations", 1, recommendations.size());
      Recommendation r = recommendations.get(0);
      Assert.assertEquals("recommendation should have correct rating", 3, r.getStars());
      Assert.assertEquals("recommendation should have correct comment", "Pretty Good", r.getComment());
        final Restaurant restaurant = r.getRestaurant();
        Assert.assertEquals("recommendation should have correct restaurant id", new Long(22), restaurant.getId());
      Assert.assertEquals("recommendation should have correct restaurant name", "Subway Sandwiches & Salads", restaurant.getName());
    }
View Full Code Here

Examples of com.springone.myrestaurants.domain.Restaurant

    }

    @Transactional
    @Test
    public void testFindRestaurant() {
      Restaurant r = repo.findRestaurant(1L);
      Assert.assertNotNull("should have found something" ,r);
      Assert.assertEquals("should have found the right one", "Boston Market", r.getName());
    }
View Full Code Here

Examples of com.springone.myrestaurants.domain.Restaurant

 
  @RequestMapping(value = "/{id}/{userId}", params = "favorite", method = RequestMethod.PUT)
    public String addFavoriteRestaurant(@PathVariable("id") Long id,
                      @PathVariable("userId") Long userId,
                      Model model) {
    Restaurant restaurant = this.restaurantDao.findRestaurant(id);
    UserAccount account = this.userAccountDao.findUserAccount(userId);   
    account.getFavorites().add(restaurant);
    this.userAccountDao.persist(account);
        addDateTimeFormatPatterns(model);      
        model.addAttribute("useraccount", account);
View Full Code Here

Examples of com.springone.myrestaurants.domain.Restaurant

    private EntityManager entityManager;

  @Transactional
  public Restaurant findRestaurant(Long id) {
    if (id == null) return null;
    final Restaurant rest = entityManager.find(Restaurant.class, id);
    if (rest != null) {
      rest.persist();
    }
    return rest;
    }
View Full Code Here

Examples of com.springone.myrestaurants.domain.Restaurant

    RecommendationFormBean bean = new RecommendationFormBean();
    if (foundRec != null) {
      bean.setComments(foundRec.getComment());
      bean.setRating(foundRec.getStars());
            bean.setId(foundRec.getRelationshipId());
            Restaurant r = foundRec.getRestaurant();
            bean.setName(r.getName());
            bean.setRestaurantId(r.getId());
    }
    model.addAttribute("recommendation", bean);
        return "recommendations/show";
    }
View Full Code Here

Examples of com.springone.myrestaurants.domain.Restaurant

    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();
            rfb.setComments(recommendation.getComment());
            rfb.setName(restaurant.getName());
      rfb.setRating(recommendation.getStars());   
      rfb.setId(recommendation.getRelationshipId());
            rfb.setRestaurantId(restaurant.getId());
      listRecs.add(rfb);
    }                       
    model.addAttribute("recommendations", listRecs);
        return "recommendations/list";
    }
View Full Code Here

Examples of com.springone.myrestaurants.domain.Restaurant

    if (result.hasErrors()) {
      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());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.