Package com.changestuffs.server.persistence.beans

Examples of com.changestuffs.server.persistence.beans.User


          if(offerPerUser.size()>0){
            Offers offers = new Offers();
            offers.setIdNameProducts(offerPerUser);
            offers.setUserId(offer.getUserId());
            if(email != null){
              User user = model.find(User.class, email);
              offers.setFriend(user.getFriends().contains(offer.getUserId()));
            }
            allOffers.add(offers);
          }
        }
      }
View Full Code Here


    return result;
  }
 
  public OfferInfo getOwner(String offerId){
    Offer offer = model.find(Offer.class, KeyFactory.stringToKey(offerId));
    User user = model.find(User.class, offer.getProduct().getUserId());
    return new OfferInfo(user, offer.getProduct().getName(), KeyFactory.keyToString(offer.getProduct().getKey()));
  }
View Full Code Here

    InfoLoginResult result = null;
    Login login = new Login();
    login.setIp(ip);
    login.setLoginDate(dateIn);
    log.info("Looking for id: "+user.getEmail());
        User userBean = model.find(User.class, user.getEmail());
        if(userBean != null){
          if(AUTH_DOMAIN_NOT_REGISTERED.equals(userBean.getAuthDomain()))
            setUserOpenIdValues(userBean, user);
          Date date = userBean.getLogins().get(userBean.getLogins().size()-1).getLoginDate();
          if(pendingFriend != null)
            userBean.getPendingFriends().add(pendingFriend);
          login.setUser(userBean);
          model.persist(login);
          log.info("Update user: "+user.getEmail()+" with date "+dateIn);
          result = new InfoLoginResult(user.getEmail(), date, false, userBean.isReceiveEmails(), userBean.getUserId());
        }else{
          List<Login> logins = new ArrayList<Login>();
          userBean = new User();
          setUserOpenIdValues(userBean, user);
          userBean.setReceiveEmails(true);
          userBean.setFriends(new HashSet<String>());
          userBean.setPendingFriends(new HashSet<String>());
          if(pendingFriend != null)
            userBean.getPendingFriends().add(pendingFriend);
          logins.add(login);
          userBean.setLogins(logins);
          model.persist(userBean);
          log.info("Creating user: "+user.getEmail());
          result = new InfoLoginResult(user.getEmail(), login.getLoginDate(), true, userBean.isReceiveEmails(), userBean.getUserId());
        }
        log.info("User "+userBean);
    log.info("Returning "+result);
    return result;
  }
View Full Code Here

      userBean.setNickName(user.getNickname());
  }
 
  @Transactional
  public void updateUser(UpdateUserInfo action, String email){
    User userBean = model.find(User.class, email);
    userBean.setCell(action.getCell());
    userBean.setCity(action.getCity());
    userBean.setCountry(action.getCountry());
    userBean.setReceiveEmails(action.isReceiveEmails());
  }
View Full Code Here

  @Transactional
  public String updateNotify(String token, boolean receiveEmails){
    Query query = model.createNamedQuery(User.GET_USER_BY_USER_ID);
    query.setParameter("userId", token);
    log.info("Query: " + query.toString());
    User user = (User) query.getSingleResult();
    user.setReceiveEmails(receiveEmails);
    return user.getEmail();
  }
View Full Code Here

    return user.getEmail();
  }
 
  @Transactional
  public boolean addFriend(String email, String newFriend){
    User userBean = model.find(User.class, email);
    int sizeBefore = userBean.getFriends().size();
    userBean.getFriends().add(newFriend);
    if(userBean.getPendingFriends().contains(newFriend))
      userBean.getPendingFriends().remove(newFriend);
    int sizeAfter = userBean.getFriends().size();
   
    if(sizeBefore == sizeAfter)
      return true;
    else
      return false;
View Full Code Here

      return false;
  }
 
  @Transactional
  public void removeContact(String email, String contactEmail, boolean pending){
    User user = model.find(User.class, email);
    if(pending)
      user.getPendingFriends().remove(contactEmail);
    else
      user.getFriends().remove(contactEmail);
  }
View Full Code Here

    else
      user.getFriends().remove(contactEmail);
  }
 
  public GetUserInfoResult getGetUserInfoResult(String email){
    User userBean = model.find(User.class, email);
    if(userBean != null){
      Set<String> friends = getSecureSet(userBean.getFriends());
      Set<String> prending = getSecureSet(userBean.getPendingFriends());
      return new GetUserInfoResult(userBean.getCell(), userBean.getCountry(), userBean.getCity(), email, userBean.isReceiveEmails(), friends, prending, getOnline(friends));
    }else{
      // It's maybe the first time, and DB is slow so it can be null
      Set<String> empty = new HashSet<String>();
      return new GetUserInfoResult("", "", "", email, true, empty, empty, empty);
    }
View Full Code Here

   
    log.info("First insert");
    InfoLoginResult result1 = oam.persistUser(firstDate, user, ip, null);
    assertEquals(true, result1.isFirstTime());
    assertEquals(firstDate, result1.getDate());
    User user = getUser();
    log.info("User(1): "+user);
    assertEquals(user.getEmail(), user.getEmail());
    assertEquals(1, user.getLogins().size());
    assertEquals(firstDate, user.getLogins().get(0).getLoginDate());
   
   
    log.info("Second insert");
    InfoLoginResult result2 = oam.persistUser(secondDate, this.user, ip, null);
    assertEquals(false, result2.isFirstTime());
    assertEquals(firstDate, result2.getDate());
    user = getUser();
    log.info("User(2): "+user);
    assertEquals(user.getEmail(), user.getEmail());
    assertEquals(2, user.getLogins().size());
    assertEquals(firstDate, user.getLogins().get(0).getLoginDate());
    assertEquals(secondDate, user.getLogins().get(1).getLoginDate());
   
    log.info("Third insert");
    InfoLoginResult result3 = oam.persistUser(thirdDate, this.user, ip, null);
    assertEquals(false, result3.isFirstTime());
    assertEquals(secondDate, result3.getDate());
    user = getUser();
    log.info("User(3): "+user);
    assertEquals(user.getEmail(), user.getEmail());
    assertEquals(3, user.getLogins().size());
    assertEquals(firstDate, user.getLogins().get(0).getLoginDate());
    assertEquals(secondDate, user.getLogins().get(1).getLoginDate());
    assertEquals(thirdDate, user.getLogins().get(2).getLoginDate());
  }
View Full Code Here

  public void inviteNotRegistered() throws ActionException {
    final String invite = "pablo@gmail.com";
    SendInvitationActionHandler handler = injector.getInstance(SendInvitationActionHandler.class);
    SendInvitationResult result = handler.execute(new SendInvitation(invite), mock(ExecutionContext.class));
    assertEquals(true, result.isSent());
    User pablo = appEntity.find(User.class, invite);
    assertNotNull(pablo);
    assertNotNull(pablo.getUserId());
    assertEquals(UserBeanOAM.AUTH_DOMAIN_NOT_REGISTERED, pablo.getAuthDomain());
    assertEquals(true, pablo.isReceiveEmails());
    assertEquals(1, pablo.getPendingFriends().size());
    assertTrue("Pending friends = "+pablo.getPendingFriends(), pablo.getPendingFriends().contains(email));
    assertEquals(1, pablo.getLogins().size());
  }
View Full Code Here

TOP

Related Classes of com.changestuffs.server.persistence.beans.User

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.