Package org.apache.rave.portal.model

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


        return pageLayoutRepository;
    }

    @Override
    public MongoDbUser convert(User source) {
        MongoDbUser user = source instanceof MongoDbUser ? (MongoDbUser)source : new MongoDbUser();
        List<String> authorityCodes = Lists.newArrayList();
        for(GrantedAuthority authority : source.getAuthorities()) {
            authorityCodes.add(authority.getAuthority());
        }
        user.setAuthorityCodes(authorityCodes);
        updateProperties(source, user);
        return user;
    }
View Full Code Here


        return pageLayoutRepository;
    }

    @Override
    public MongoDbUser convert(User source) {
        MongoDbUser user = source instanceof MongoDbUser ? (MongoDbUser)source : new MongoDbUser();
        List<String> authorityCodes = Lists.newArrayList();
        for(GrantedAuthority authority : source.getAuthorities()) {
            authorityCodes.add(authority.getAuthority());
        }
        user.setAuthorityCodes(authorityCodes);
        updateProperties(source, user);
        return user;
    }
View Full Code Here

        return findFriendsWithFriend(username, friendUsername); //TODO update when groups is implemented
    }

    @Override
    public List<Person> findFriends(String username) {
        MongoDbUser user = (MongoDbUser) template.findOne(getUsernameQuery(username));
        return Lists.transform(filterByRequestType(user.getFriends(), FriendRequestStatus.ACCEPTED), new Function<MongoDbPersonAssociation, Person>() {
            @Override
            public Person apply(@Nullable MongoDbPersonAssociation input) {
                return input == null ? null : template.get(input.getPersonId()).toPerson();
            }
        });
View Full Code Here

        });
    }

    @Override
    public List<Person> findFriends(String username, String appId) {
        MongoDbUser user = (MongoDbUser) template.findOne(getUsernameQuery(username));
        Widget w = widgetOperations.findOne(query(where("url").is(appId)));
        Query q = query(where("ownerId").in(getFriendIds(user.getFriends())).and("regions").elemMatch(where("regionWidgets").elemMatch(where("widgetId").is(w.getId()))));
        List<Page> pages = pageTemplate.find(q);
        return getPersonListFromPages(pages);
    }
View Full Code Here

        return getPersonListFromPages(pages);
    }

    @Override
    public List<Person> findFriendsWithFriend(String username, String friendUsername) {
        MongoDbUser follower = (MongoDbUser) template.findOne(getUsernameQuery(username));
        MongoDbUser followed = (MongoDbUser) template.findOne(getUsernameQuery(friendUsername));
        List<String> commonFriends = getCommonFriends(follower, followed);
        return Lists.transform(commonFriends, new Function<String, Person>() {
            @Override
            public Person apply(@Nullable String id) {
                return id == null ? null : template.get(id).toPerson();
View Full Code Here

        throw new UnsupportedOperationException("Not implemented")//TODO build query
    }

    @Override
    public boolean addFriend(String friendUsername, String username) {
        MongoDbUser follower = (MongoDbUser) template.findOne(getUsernameQuery(username));
        MongoDbUser followed = (MongoDbUser) template.findOne(getUsernameQuery(friendUsername));

        MongoDbPersonAssociation outgoing = new MongoDbPersonAssociation(followed.getId(), FriendRequestStatus.SENT, MongoDbPersonAssociation.Direction.OUTGOING);
        MongoDbPersonAssociation incoming = new MongoDbPersonAssociation(follower.getId(), FriendRequestStatus.RECEIVED, MongoDbPersonAssociation.Direction.INCOMING);

        follower.getFriends().add(outgoing);
        followed.getFriends().add(incoming);

        template.save(followed);
        template.save(follower);
        return true;
    }
View Full Code Here

        return true;
    }

    @Override
    public void removeFriend(String friendUsername, String username) {
        MongoDbUser follower = (MongoDbUser) template.findOne(getUsernameQuery(username));
        MongoDbUser followed = (MongoDbUser) template.findOne(getUsernameQuery(friendUsername));
        removeAssociation(follower, followed);
        removeAssociation(followed, follower);
        template.save(follower);
        template.save(followed);
    }
View Full Code Here

        return friendsAndRequests;
    }

    @Override
    public boolean acceptFriendRequest(String friendUsername, String username) {
        MongoDbUser follower = (MongoDbUser) template.findOne(getUsernameQuery(username));
        MongoDbUser followed = (MongoDbUser) template.findOne(getUsernameQuery(friendUsername));
        setAccepted(follower, followed);
        setAccepted(followed, follower);
        template.save(follower);
        template.save(followed);
        return true;
View Full Code Here

        return true;
    }

    @Override
    public List<Person> findFriendRequestsReceived(String username) {
        MongoDbUser followed = (MongoDbUser) template.findOne(getUsernameQuery(username));
        return getPersonListFromAssociations(followed, FriendRequestStatus.RECEIVED);
    }
View Full Code Here

        return getPersonListFromAssociations(followed, FriendRequestStatus.RECEIVED);
    }

    @Override
    public List<Person> findFriendRequestsSent(String username) {
        MongoDbUser follower = (MongoDbUser) template.findOne(getUsernameQuery(username));
        return getPersonListFromAssociations(follower, FriendRequestStatus.SENT);
    }
View Full Code Here

TOP

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

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.