Package org.eurekastreams.server.domain

Examples of org.eurekastreams.server.domain.Person


     * Test add follower.
     */
    @Test
    public void testAddFollower()
    {
        Person ford = jpaPersonMapper.findByAccountId("fordp");
        Person sagan = jpaPersonMapper.findByAccountId("csagan");

        assertEquals("followers/followings should be 0 initially", 0, ford.getFollowersCount());
        assertEquals("followers/followings should be 0 initially", 0, ford.getFollowingCount());
        assertEquals("followers/followings should be 0 initially", 0, sagan.getFollowersCount());
        assertEquals("followers/followings should be 0 initially", 0, sagan.getFollowingCount());

        jpaPersonMapper.addFollower(ford.getId(), sagan.getId());
        getEntityManager().clear();

        ford = jpaPersonMapper.findByAccountId("fordp");
        sagan = jpaPersonMapper.findByAccountId("csagan");

        assertEquals("sagan should have 1 follower", 1, sagan.getFollowersCount());
        assertEquals("sagan follows no one", 0, sagan.getFollowingCount());

        assertEquals("ford should have no followers", 0, ford.getFollowersCount());
        assertEquals("ford should be following sagan", 1, ford.getFollowingCount());

        // test case for add when relationship already present.
        jpaPersonMapper.addFollower(ford.getId(), sagan.getId());
        getEntityManager().clear();

        ford = jpaPersonMapper.findByAccountId("fordp");
        sagan = jpaPersonMapper.findByAccountId("csagan");

        // verify nothing has changed counts should be same.
        assertEquals("Followers count changed after duplicate add.", 1, sagan.getFollowersCount());
        assertEquals("Following count changed after duplicate add", 0, sagan.getFollowingCount());

        assertEquals("follower's Followers count changed after duplicate add.", 0, ford.getFollowersCount());
        assertEquals("follower's Following count changed after duplicate add", 1, ford.getFollowingCount());
    }
View Full Code Here


        (readonlyStreamsMapper).setEntityManager(getEntityManager());
        List<String> streamNames = new ArrayList<String>(CollectionUtils.asList("My saved items", "Everyone"));

        PersonCreator localSut = new PersonCreator(personMapperMock, readonlyStreamsMapper, streamNames, ppg);

        Person p = localSut.get(null, inFields);
        context.assertIsSatisfied();

        assertNotNull(p);
        assertNotNull(p.getStartTabGroup());
        assertEquals("nflanders", p.getAccountId());
        assertEquals("Ned", p.getFirstName());
        assertEquals("", p.getMiddleName());
        assertEquals("Flanders", p.getLastName());
        assertEquals("Ned-diddly", p.getPreferredName());
        assertEquals("", p.getDisplayNameSuffix());

        // test stream order
        // IDs: 1, 5,
        assertEquals(2, p.getStreams().size());
        assertEquals(5, p.getStreams().get(0).getId());
        assertEquals(1, p.getStreams().get(1).getId());
    }
View Full Code Here

     * Test remove follower.
     */
    @Test
    public void testRemoveFollower()
    {
        Person smithers = jpaPersonMapper.findByAccountId("smithers");
        Person burns = jpaPersonMapper.findByAccountId("mrburns");

        // assert initial state correct from DB unit.
        assertEquals("burns should have 1 follower", 1, burns.getFollowersCount());
        assertEquals("burns should not be following any", 0, burns.getFollowingCount());

        assertEquals("smithers should have no followers", 0, smithers.getFollowersCount());
        assertEquals("smithers should be following burns", 1, smithers.getFollowingCount());

        jpaPersonMapper.removeFollower(smithers.getId(), burns.getId());
        getEntityManager().clear();

        smithers = jpaPersonMapper.findByAccountId("smithers");
        burns = jpaPersonMapper.findByAccountId("mrburns");

        assertEquals("followers/followings should be 0 after removal", 0, smithers.getFollowersCount());
        assertEquals("followers/followings should be 0 after removal", 0, smithers.getFollowingCount());
        assertEquals("followers/followings should be 0 after removal", 0, burns.getFollowersCount());
        assertEquals("burns followings should be 0 after removal", 0, burns.getFollowingCount());

        // cover case where remove is called on relationship that doesn't exist
        // (no-op).
        Person ford = jpaPersonMapper.findByAccountId("fordp");
        Person sagan = jpaPersonMapper.findByAccountId("csagan");

        // nothing really to assert after this, just verify everything is the
        // same.
        jpaPersonMapper.removeFollower(ford.getId(), sagan.getId());
        getEntityManager().clear();

        ford = jpaPersonMapper.findByAccountId("fordp");
        sagan = jpaPersonMapper.findByAccountId("csagan");

View Full Code Here

    public Serializable execute(final PrincipalActionContext inActionContext) throws ExecutionException
    {
        AddGadgetRequest request = (AddGadgetRequest) inActionContext.getParams();
        Long tabId = request.getTabId();
        String gadgetDefUrl = request.getGadgetDefinitionUrl();
        Person owner = personMapper.findByAccountId(inActionContext.getPrincipal().getAccountId());
        Tab tab = owner.getTabs(TabGroupType.START).get(0);

        if (null != tabId)
        {
            tab = tabMapper.findById(tabId);
        }

        try
        {
            GadgetDefinition gadgetDef;

            // UUID identified by starting with { and ending with }
            if (gadgetDefUrl.startsWith("{") && gadgetDefUrl.substring(gadgetDefUrl.length() - 1).equals("}"))
            {
                // gadget def is identified by a UUID
                gadgetDef = gadgetDefinitionMapper.findByUUID(gadgetDefUrl.substring(1, gadgetDefUrl.length() - 1));
            }
            else
            {
                // gadget def is identified by a URL.
                gadgetDef = gadgetDefinitionMapper.findByUrl(gadgetDefUrl);
            }

            /*
             * If gadgetDef is not found, throw an exception, something went wrong, most likely a bad UUID or URL.
             */
            if (null == gadgetDef)
            {
                throw new ExecutionException("Unable to instantiate gadgetDef.");
            }

            // increment the indexes of any gadgets in that zone
            shiftGadget(tab.getGadgets());

            // get the owner

            // create the new gadget at the top of the last zone
            Gadget gadget = new Gadget(gadgetDef, 0, 0, owner, request.getUserPrefs() == null ? "" : request
                    .getUserPrefs());

            // insert the new gadget - room has been made for it
            tab.getGadgets().add(gadget);

            // commit our operations
            tabMapper.flush();

            deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + owner.getId()));

            // return it
            return gadget;
        }
        catch (NoResultException ex)
        {
            log.error("Could not add Gadget because tab not found: " + owner.getUniqueId());
            throw new ExecutionException("Could not add Gadget because tab not found: " + owner.getUniqueId());
        }
    }
View Full Code Here

    {
        String tabName = (String) inActionContext.getParams();

        Tab tab = new Tab(tabName, Layout.THREECOLUMN);

        Person person = personMapper.findByAccountId(inActionContext.getPrincipal().getAccountId());

        person.addTab(tab, TabGroupType.START);

        // because the caller relies on tabIndex being set properly, we have to
        // flush, then clear the entity manager so we can reget the updated
        // Tab's new tabIndex
        personMapper.flush();
        personMapper.clear();

        deleteKeysMapper.execute(Collections.singleton(CacheKeys.PERSON_PAGE_PROPERTIES_BY_ID + person.getId()));

        if (log.isDebugEnabled())
        {
            log.debug("Saved tab for " + person.getDisplayName());
        }

        return tabMapper.findById(tab.getId());
    }
View Full Code Here

    @Override
    protected Person getDomainEntity(final String inName, final HttpServletRequest request) throws ServletException
    {
        PersonMapper personMapper = (PersonMapper) getSpringContext().getBean("jpaPersonMapper");

        Person outPerson = personMapper.findByAccountId(inName);

        if (outPerson == null)
        {
            throw new ServletException("User:  " + inName + " not found");
        }
View Full Code Here

        // if a requested coordinator is not already in the database,
        // then create a new Person object
        for (Person requestedPerson : requestedPersons)
        {
            Person verfiedCoordinator = personMapper.findByAccountId(requestedPerson.getAccountId());
            if (verfiedCoordinator == null)
            {

                final HashMap<String, Serializable> personData = requestedPerson.getProperties();
View Full Code Here

     * @return Person from the database by their id, or current user if id is null.
     */
    @Override
    public Person execute(final PrincipalActionContext inActionContext)
    {
        Person result = null;
        String identifierParam = (String) inActionContext.getParams();

        // Null parameter indicates request for person from start page so load up current
        // user with tabs/gadgets/tasks. Non-null requests load specified Person and skip
        // tabs/gadgets/tasks loading
        if (identifierParam == null)
        {
            result = mapper.findByAccountId(inActionContext.getPrincipal().getAccountId());

            if (result != null)
            {
                // Trigger loading of the tabs and gadget tasks.
                for (Tab tab : result.getTabs(TabGroupType.START))
                {
                    for (Gadget gadget : tab.getGadgets())
                    {
                        gadget.getGadgetDefinition();
                    }
                }
            }
        }
        else
        {
            result = mapper.findByAccountId(identifierParam);

            if (result != null && result.getBackground() != null)
            {
                result.getBackground().getBackgroundItems(BackgroundItemType.SKILL).size();
            }
        }
        return result;
    }
View Full Code Here

                            {
                                Activity activityForIndividual = (Activity) activity.clone();

                                if (feedSubscriber.getEntityType().equals(EntityType.PERSON))
                                {
                                    Person person = personFinder.execute(new FindByIdRequest("Person", feedSubscriber
                                            .getEntityId()));

                                    if (person.isAccountLocked())
                                    {
                                        log.info("Ignoring locked account: " + person.getAccountId());
                                    }
                                    else
                                    {
                                        activityForIndividual.setActorId(person.getAccountId());
                                        activityForIndividual.setRecipientStreamScope(person.getStreamScope());
                                        activityForIndividual.setIsDestinationStreamPublic(true);

                                        activityForIndividual.setActorType(feedSubscriber.getEntityType());
                                        insertedActivities.add(activityForIndividual);
                                    }
View Full Code Here

    {
        // TODO: bookmarks should really be promoted to it's own entity (e.g. followers) to make this (and deletes)
        // more efficient.
        Long ssIdToInsert = (Long) inActionContext.getParams();

        Person person = personMapper.execute(new FindByIdRequest("Person", inActionContext.getPrincipal().getId()));
        List<StreamScope> bookmarks = person.getBookmarks();

        StreamScope scope = null;

        // if already bookmarked, just assign return scope here.
        for (StreamScope ss : bookmarks)
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.Person

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.