Package org.eurekastreams.server.domain.stream

Examples of org.eurekastreams.server.domain.stream.ActivityDTO


        //fully popluate and cache the commentDTO
        commentDTOPopulator.execute(commentDTO, getCache());
       
        //if present update activityDTO in cache.
        String activityDTOKey = CacheKeys.ACTIVITY_BY_ID + inRequest.getActivityId();
        ActivityDTO activityDTO = (ActivityDTO) getCache().get(activityDTOKey);
        if (activityDTO != null)
        {
            if (activityDTO.getCommentCount() == 0)
            {
                activityDTO.setFirstComment(commentDTO);
            }
            else
            {
                activityDTO.setLastComment(commentDTO);
            }
            activityDTO.setCommentCount(activityDTO.getCommentCount() + 1);
            getCache().set(activityDTOKey, activityDTO);
        }
       
        //if present, update commentId list for activity in cache.
        String commentIdListKey = CacheKeys.COMMENT_IDS_BY_ACTIVITY_ID + inRequest.getActivityId();
View Full Code Here


     * Test retrieving followers with entity type of Person for the Destination Stream.
     */
    @Test
    public void testGetFollowersWithPersonDestinationStream()
    {
        ActivityDTO testActivity = new ActivityDTO();
        testActivity.setId(1L);

        StreamEntityDTO testDestinationStream = new StreamEntityDTO();
        testDestinationStream.setId(1L);
        testDestinationStream.setUniqueIdentifier("fordp");
        testDestinationStream.setType(EntityType.PERSON);
        testActivity.setDestinationStream(testDestinationStream);

        PersonModelView testPersonModelView = new PersonModelView();
        testPersonModelView.setEntityId(TEST_PERSON_ID);

        final Long fordpId = 42L;
View Full Code Here

     * Test retrieving followers with entity type of Group for the Destination Stream.
     */
    @Test
    public void testGetFollowersWithGroupDestinationStream()
    {
        ActivityDTO testActivity = new ActivityDTO();
        testActivity.setId(1L);

        StreamEntityDTO testDestinationStream = new StreamEntityDTO();
        testDestinationStream.setId(1L);
        testDestinationStream.setUniqueIdentifier("group1");
        testDestinationStream.setType(EntityType.GROUP);
        testActivity.setDestinationStream(testDestinationStream);

        DomainGroupModelView testGroupModelView = new DomainGroupModelView();
        testGroupModelView.setEntityId(5L);

        final List<DomainGroupModelView> testGroupModelViewList = new ArrayList<DomainGroupModelView>();
View Full Code Here

     * Test retrieving followers with an unsupported entity type.
     */
    @Test(expected = IllegalArgumentException.class)
    public void testGetFollowersUnsupportedDestinationStream()
    {
        ActivityDTO testActivity = new ActivityDTO();
        testActivity.setId(1L);

        StreamEntityDTO testDestinationStream = new StreamEntityDTO();
        testDestinationStream.setId(1L);
        testDestinationStream.setUniqueIdentifier("group1");
        testDestinationStream.setType(EntityType.NOTSET);
        testActivity.setDestinationStream(testDestinationStream);

        sut.execute(testActivity);
    }
View Full Code Here

        List<ActivityDTO> activityList = activityByIdDAO.execute(Arrays.asList(activityId));

        assertEquals(1, activityList.size());

        ActivityDTO activity = activityList.get(0);
        assertNotNull(activity);

        List<Long> commentIds = new ArrayList<Long>(3);
        commentIds.add(1L);
        commentIds.add(2L);
View Full Code Here

        List<Long> starredActivityIds = cache.getList(CacheKeys.STARRED_BY_PERSON_ID + mrburnsId);
        assertEquals(1, starredActivityIds.size());

        commentIdsByActivityIdDAO.execute(activityId);

        ActivityDTO activity = activityByIdDAO.execute(new ArrayList()
        {
            {
                add(activityId);
            }
        }).get(0);
View Full Code Here

        // Get the activityDTO for activity that will be commented on.
        // and assert initial state is correct.
        List<Long> activityIds = new ArrayList<Long>(1);
        activityIds.add(activityId);
        ActivityDTO activityDTO = activityMapper.execute(activityIds).get(0);

        assertEquals(activityId, activityDTO.getId());
        assertEquals(3, activityDTO.getCommentCount());
        assertEquals(5L, activityDTO.getFirstComment().getId());
        assertEquals(7, activityDTO.getLastComment().getId());

        // Create the insertRequest and insert the comment via sut.
        InsertActivityCommentRequest insertRequest = new InsertActivityCommentRequest(smithersId, activityId, is1000);
        CommentDTO result = sut.execute(insertRequest);

        // Grab entity id for later use
        long newCommentId = result.getId();

        // flush and clear entityManager before query the DB.
        getEntityManager().flush();
        getEntityManager().clear();

        // Query comment from DB to assert that record was inserted in.
        Comment comment = (Comment) getEntityManager().createQuery("FROM Comment where id = :commentId").setParameter(
                "commentId", newCommentId).getSingleResult();

        // verify correct values were inserted into DB.
        assertNotNull(comment);
        assertEquals(smithersId, comment.getAuthor().getId());
        assertEquals(activityId, comment.getTarget().getId());
        assertEquals(is1000, comment.getBody());

        // Get the activity DTO and assert is was updated correctly by sut.
        activityDTO = activityMapper.execute(activityIds).get(0);
        assertEquals(activityId, activityDTO.getId());
        assertEquals(4, activityDTO.getCommentCount());
        assertEquals(5L, activityDTO.getFirstComment().getId());
        assertEquals(newCommentId, activityDTO.getLastComment().getId());

        // Insert another comment to make sure first/last comment works.
        insertRequest.setContent("another comment");
        result = sut.execute(insertRequest);

        // Get the activity DTO and assert is was updated correctly.
        activityDTO = activityMapper.execute(activityIds).get(0);
        assertEquals(5L, activityDTO.getFirstComment().getId());
        assertEquals(result.getId(), activityDTO.getLastComment().getId());
    }
View Full Code Here

        // Get the activityDTO for activity that will be commented on.
        // and assert initial state is correct.
        List<Long> activityIds = new ArrayList<Long>(1);
        activityIds.add(activityId);
        ActivityDTO activityDTO = activityMapper.execute(activityIds).get(0);

        assertEquals(activityId, activityDTO.getId());
        assertEquals(3, activityDTO.getCommentCount());
        assertEquals(5L, activityDTO.getFirstComment().getId());
        assertEquals(7, activityDTO.getLastComment().getId());

        // Create the insertRequest and insert the comment via sut.
        InsertActivityCommentRequest insertRequest = new InsertActivityCommentRequest(smithersId, activityId, over1000);

        sut.execute(insertRequest);
View Full Code Here

            StreamEntityDTO destStream = new StreamEntityDTO();
            destStream.setUniqueIdentifier(currentUserPrincipal.getAccountId());
            destStream.setType(EntityType.PERSON);

            // Create the activitydto object.
            ActivityDTO currentActivity = new ActivityDTO();
            currentActivity.setActor(actorEntity);
            currentActivity.setBaseObjectProperties(new HashMap<String, String>(
                    convertActivityFromOSToEureka(activity)));
            Long appIdNumeric = Long.valueOf(appId);
            currentActivity.setAppId(appIdNumeric);
            currentActivity.setAppType(EntityType.APPLICATION);
            currentActivity.setAppName(lookupGadgetTitle(appIdNumeric));

            // Sets default activity type
            if (!currentActivity.getBaseObjectProperties().containsKey("baseObjectType"))
            {
                currentActivity.setBaseObjectType(BaseObjectType.NOTE);
            }
            else
            {
                String objectType = currentActivity.getBaseObjectProperties().get("baseObjectType");
                currentActivity.setBaseObjectType(BaseObjectType.valueOf(objectType));

                if (currentActivity.getBaseObjectProperties().containsKey("source"))
                {
                    currentActivity.setAppSource(currentActivity.getBaseObjectProperties().get("source"));
                }
            }

            currentActivity.setVerb(ActivityVerb.POST);
            currentActivity.setDestinationStream(destStream);

            PostActivityRequest params = new PostActivityRequest(currentActivity);
            ServiceActionContext currentContext = new ServiceActionContext(params, currentUserPrincipal);
            // Make the call to the action to perform the create.
            serviceActionController.execute(currentContext, postActivityAction);
View Full Code Here

     * @return true if successful.
     */
    @Override
    public Boolean execute(final DeleteActivityCacheUpdateRequest inRequest)
    {
        ActivityDTO activity = inRequest.getActivity();
        long activityId = activity.getId();

        log.info("Cleaning up cache for deleted activity #" + activity.getId());

        // Remove from entity stream.
        EntityType streamType = activity.getDestinationStream().getType();

        switch (streamType)
        {
        case GROUP:
            DomainGroupModelView group = groupByShortNameDAO.execute(
                    Arrays.asList(activity.getDestinationStream().getUniqueIdentifier())).get(0);
            log.info("Removing activity #" + activityId + " from group stream + " + group.getStreamId());

            getCache().removeFromList(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + group.getStreamId(), activityId);
            break;
        case PERSON:
            PersonModelView person = getPersonModelViewByAccountIdMapper.execute(activity.getDestinationStream()
                    .getUniqueIdentifier());

            log.info("Removing activity #" + activityId + " from person stream + " + person.getStreamId());

            getCache().removeFromList(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + person.getStreamId(), activityId);
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.domain.stream.ActivityDTO

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.