Package org.eurekastreams.server.search.modelview

Examples of org.eurekastreams.server.search.modelview.CommentDTO


    @Override
    protected Boolean updateCachedEntity(final ActivityDTO inActivityDTO, final Person inPerson)
    {
        boolean isUpdated = false;

        CommentDTO firstComment = inActivityDTO.getFirstComment();
        CommentDTO lastComment = inActivityDTO.getLastComment();

        // check the first comment embedded in the activity dto
        if (isAuthoredByPerson(firstComment, inPerson))
        {
            for (UpdateCommentDTOFromPerson updater : commentUpdaters)
View Full Code Here


    public void testExecuteWithNewDisplayName()
    {
        final String oldDisplayName = "sdlfjsdfkdfjsdf";
        final String newDisplayName = "dksdkdkdkdk";

        final CommentDTO comment = context.mock(CommentDTO.class);
        final Person person = context.mock(Person.class);

        context.checking(new Expectations()
        {
            {
View Full Code Here

    public void testExecuteWithSameDisplayName()
    {
        final String oldDisplayName = "sdlfjsdfkdfjsdf";
        final String newDisplayName = oldDisplayName;

        final CommentDTO comment = context.mock(CommentDTO.class);
        final Person person = context.mock(Person.class);

        context.checking(new Expectations()
        {
            {
View Full Code Here

    public void testExecuteWithNewAvatarId()
    {
        final String oldAvatarId = "sdlfjsdfkdfjsdf";
        final String newAvatarId = "dksdkdkdkdk";

        final CommentDTO comment = context.mock(CommentDTO.class);
        final Person person = context.mock(Person.class);

        context.checking(new Expectations()
        {
            {
View Full Code Here

    public void testExecuteWithSameAvatarId()
    {
        final String oldAvatarId = "sdlfjsdfkdfjsdf";
        final String newAvatarId = oldAvatarId;

        final CommentDTO comment = context.mock(CommentDTO.class);
        final Person person = context.mock(Person.class);

        context.checking(new Expectations()
        {
            {
View Full Code Here

     */
    @Override
    public Boolean execute(final Long inCommentId)
    {
        // get comment to delete (need this to get activity that comment is associated with).
        CommentDTO comment = getCommentById(inCommentId);

        // short circuit here if comment to delete is not present.
        if (comment == null)
        {
            return true;
        }

        long activityId = comment.getActivityId();

        // delete comment from DB.
        getEntityManager().createQuery("DELETE FROM Comment WHERE id = :commentId").setParameter("commentId",
                inCommentId).executeUpdate();

View Full Code Here

                activity,
                inRequest.getContent().trim());
       
        getEntityManager().persist(comment);
       
        CommentDTO commentDTO = new CommentDTO();
        commentDTO.setActivityId(inRequest.getActivityId());
        commentDTO.setAuthorId(inRequest.getUserId());
        commentDTO.setId(comment.getId());
        commentDTO.setTimeSent(comment.getTimeSent());
        commentDTO.setBody(inRequest.getContent());
       
        //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();
        List<Long> commentIds = getCache().getList(commentIdListKey);
        if (commentIds != null)
        {
            commentIds.add(commentDTO.getId());
            getCache().setList(commentIdListKey, commentIds)
        }
       
        commentDTO.setDeletable(true);

        Search.getFullTextSession((Session) getEntityManager().getDelegate()).index(activity);
       
        return commentDTO;
    }
View Full Code Here

            activity.getBaseObjectProperties().put("originalActivityId", String.valueOf(originalActivity.getId()));
        }
        activity.setBaseObjectType(originalActivity.getBaseObjectType());
        if (commentBody != null && commentBody.length() > 0)
        {
            CommentDTO sharedActivityComment = new CommentDTO();
            sharedActivityComment.setBody(commentBody);
            List<CommentDTO> comments = new ArrayList<CommentDTO>();
            comments.add(sharedActivityComment);
            activity.setFirstComment(sharedActivityComment);
            activity.setComments(comments);
            activity.setCommentCount(comments.size());
View Full Code Here

                add(activityId);
            }
        }).get(0);

        cache.set(CacheKeys.ACTIVITY_BY_ID + activityId, activity);
        cache.set(CacheKeys.COMMENT_BY_ID + 1, new CommentDTO());
        cache.set(CacheKeys.COMMENT_BY_ID + 3, new CommentDTO());
    }
View Full Code Here

        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

TOP

Related Classes of org.eurekastreams.server.search.modelview.CommentDTO

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.