Package com.springone.myrestaurants.domain

Examples of com.springone.myrestaurants.domain.UserAccount


  @BeforeTransaction
  public void setUpBeforeTransaction() {
    EntityManager setUpEm = emf.createEntityManager();
    EntityTransaction setUpTx = setUpEm.getTransaction();
    setUpTx.begin();
    UserAccount u = new UserAccount();
    u.setFirstName("Bubba");
    u.setLastName("Jones");
    u.setBirthDate(new Date());
    u.setUserName("user");
    setUpEm.persist(u);
    setUpEm.flush();
        u.persist();
    this.userId = u.getId();
    setUpTx.commit();
  }
View Full Code Here


  @AfterTransaction
  public void tearDown() {
    EntityManager tearDownEm = emf.createEntityManager();
    EntityTransaction tearDownTx = tearDownEm.getTransaction();
    tearDownTx.begin();
    UserAccount u = tearDownEm.find(UserAccount.class, this.userId);
    tearDownEm.remove(u);
    tearDownEm.flush();
    tearDownTx.commit();     
  }
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

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

  @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);
        model.addAttribute("itemId", id);
        return "redirect:/useraccounts/" + account.getId();
    }
View Full Code Here

        this.entityManager.persist(userAccount);
    }

  @Transactional
    public UserAccount merge(UserAccount userAccount) {
        UserAccount merged = this.entityManager.merge(userAccount);
        this.entityManager.flush();
        return merged;
    }
View Full Code Here

  @ModelAttribute("currentUserAccountId")
  public String populateCurrentUserName() {
    String currentUser = SecurityContextHolder.getContext()
        .getAuthentication().getName();
    UserAccount userAccount = userAccountDao.findByName(currentUser);
    if (userAccount != null) {
      return userAccount.getId().toString();
    } else {
      return "USER-ID-NOT-AVAILABLE";
    }
  }
View Full Code Here

    private EntityManager entityManager;

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

    q.setParameter("username", name);
   
    java.util.List resultList = q.getResultList();
    if (resultList.size() > 0)
    {
            final UserAccount userAccount = (UserAccount) resultList.get(0);
            if (userAccount != null) {
              userAccount.persist();
            }
            return userAccount;
    }
    return null;
  }
View Full Code Here

    }

  @Transactional
    public UserAccount merge(UserAccount userAccount) {
        userAccount.persist();
        UserAccount merged = this.entityManager.merge(userAccount);
        this.entityManager.flush();
        return merged;
    }
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.