Package org.apache.rave.portal.model

Examples of org.apache.rave.portal.model.JpaPersonAssociation


        manager.remove(item instanceof JpaPerson ? item : findByUsername(item.getUsername()));
    }

  @Override
  public boolean addFriend(String friendUsername, String username) {
    JpaPersonAssociation senderItem = new JpaPersonAssociation();
    senderItem.setFollower(personConverter.convert(findByUsername(username)));
    senderItem.setFollowedby(personConverter.convert(findByUsername(friendUsername)));
    senderItem.setStatus(FriendRequestStatus.SENT);
    senderItem = saveOrUpdate(senderItem.getEntityId(), manager, senderItem);

    JpaPersonAssociation receiverItem = new JpaPersonAssociation();
    receiverItem.setFollower(personConverter.convert(findByUsername(friendUsername)));
    receiverItem.setFollowedby(personConverter.convert(findByUsername(username)));
    receiverItem.setStatus(FriendRequestStatus.RECEIVED);
    receiverItem = saveOrUpdate(receiverItem.getEntityId(), manager, receiverItem);

    if(senderItem.getEntityId()!=null && receiverItem.getEntityId()!=null)
      return true;
    else
      return false;
  }
View Full Code Here


  @Override
  public void removeFriend(String friendUsername, String username) {
    TypedQuery<JpaPersonAssociation> query = manager.createNamedQuery(JpaPersonAssociation.FIND_ASSOCIATION_ITEM_BY_USERNAMES, JpaPersonAssociation.class);
        query.setParameter(JpaPersonAssociation.FOLLOWER_USERNAME, username);
        query.setParameter(JpaPersonAssociation.FOLLOWEDBY_USERNAME, friendUsername);
        JpaPersonAssociation item = getSingleResult(query.getResultList());
        manager.remove(item);

    query = manager.createNamedQuery(JpaPersonAssociation.FIND_ASSOCIATION_ITEM_BY_USERNAMES, JpaPersonAssociation.class);
        query.setParameter(JpaPersonAssociation.FOLLOWER_USERNAME, friendUsername);
        query.setParameter(JpaPersonAssociation.FOLLOWEDBY_USERNAME, username);
        JpaPersonAssociation inverseItem = getSingleResult(query.getResultList());
        manager.remove(inverseItem);
  }
View Full Code Here

  @Override
  public boolean acceptFriendRequest(String friendUsername, String username) {
    TypedQuery<JpaPersonAssociation> query = manager.createNamedQuery(JpaPersonAssociation.FIND_ASSOCIATION_ITEM_BY_USERNAMES, JpaPersonAssociation.class);
        query.setParameter(JpaPersonAssociation.FOLLOWER_USERNAME, username);
        query.setParameter(JpaPersonAssociation.FOLLOWEDBY_USERNAME, friendUsername);
        JpaPersonAssociation receiverItem = getSingleResult(query.getResultList());
        receiverItem.setStatus(FriendRequestStatus.ACCEPTED);
        receiverItem = saveOrUpdate(receiverItem.getEntityId(), manager, receiverItem);

    query = manager.createNamedQuery(JpaPersonAssociation.FIND_ASSOCIATION_ITEM_BY_USERNAMES, JpaPersonAssociation.class);
        query.setParameter(JpaPersonAssociation.FOLLOWER_USERNAME, friendUsername);
        query.setParameter(JpaPersonAssociation.FOLLOWEDBY_USERNAME, username);
        JpaPersonAssociation senderItem = getSingleResult(query.getResultList());
        senderItem.setStatus(FriendRequestStatus.ACCEPTED);
        senderItem = saveOrUpdate(senderItem.getEntityId(), manager, senderItem);

    if(receiverItem.getEntityId()!=null && senderItem.getEntityId()!=null)
      return true;
    else
      return false;
  }
View Full Code Here

TOP

Related Classes of org.apache.rave.portal.model.JpaPersonAssociation

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.