Examples of BulkActivityDeleteResponse


Examples of org.eurekastreams.server.persistence.mappers.requests.BulkActivityDeleteResponse

        listsToUpdate.add(CacheKeys.ACTIVITIES_BY_FOLLOWING + 1L);
        final List<Long> commentIds = new ArrayList<Long>();
        commentIds.add(1L);
        commentIds.add(2L);
        final Map<Long, Set<Long>> starredActivityIds = new HashMap<Long, Set<Long>>();
        final BulkActivityDeleteResponse deleteResponse = new BulkActivityDeleteResponse(activityIds, commentIds,
                starredActivityIds);

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

Examples of org.eurekastreams.server.persistence.mappers.requests.BulkActivityDeleteResponse

    public BulkActivityDeleteResponse execute(final List<Long> inActivityIds)
    {
        // short-circut as no activities to delete.
        if (inActivityIds == null || inActivityIds.isEmpty())
        {
            return new BulkActivityDeleteResponse();
        }

        // get comment ids to return (cache and search index cleanup)
        List<Long> commentIds = getCommentIds(inActivityIds);

        // get people with starred Activities map (cache clean up).
        Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inActivityIds);

        // delete comments.
        getHibernateSession().createQuery("DELETE FROM Comment c WHERE c.target.id IN (:activityIds)")
                .setParameterList("activityIds", inActivityIds).executeUpdate();

        // delete activity from currentUser's starred activity collections in DB.
        getHibernateSession().createQuery("DELETE FROM StarredActivity where activityId IN (:activityIds)")
                .setParameterList("activityIds", inActivityIds).executeUpdate();

        // delete any hashtags stored to streams on behalf of this activity
        getEntityManager().createQuery("DELETE FROM StreamHashTag WHERE activity.id in (:activityIds)").setParameter(
                "activityIds", inActivityIds).executeUpdate();

        // delete the activities.
        getHibernateSession().createQuery("DELETE FROM Activity a WHERE a.id IN (:activityIds)").setParameterList(
                "activityIds", inActivityIds).executeUpdate();

        return new BulkActivityDeleteResponse(inActivityIds, commentIds, peopleWithStarredActivities);
    }
View Full Code Here

Examples of org.eurekastreams.server.persistence.mappers.requests.BulkActivityDeleteResponse

     */
    @Test
    public void testExecute()
    {
        // call sut.
        BulkActivityDeleteResponse response = sut.execute(Arrays.asList(activityId));

        // assert results are correct.
        assertTrue(response.getCommentIds().contains(comment1Id));
        assertTrue(response.getCommentIds().contains(comment2Id));
        assertTrue(response.getActivityIds().contains(activityId));
        assertNotNull(response.getPeopleWithStarredActivities());

        // assert that expected activity and comments are actually gone.
        assertEquals(0, getEntityManager().createQuery("From Activity WHERE id=:activityId").setParameter("activityId",
                activityId).getResultList().size());

View Full Code Here

Examples of org.eurekastreams.server.persistence.mappers.requests.BulkActivityDeleteResponse

     */
    @Test
    public void testExecuteEmptyList()
    {
        // call sut.
        BulkActivityDeleteResponse response = sut.execute(new ArrayList<Long>(0));

        // assert that result is emtpy.
        assertEquals(0, response.getCommentIds().size());
        assertEquals(0, response.getActivityIds().size());
        assertEquals(0, response.getPeopleWithStarredActivities().keySet().size());
    }
View Full Code Here

Examples of org.eurekastreams.server.persistence.mappers.requests.BulkActivityDeleteResponse

     */
    @Test
    public void testExecuteNullList()
    {
        // call sut.
        BulkActivityDeleteResponse response = sut.execute(null);

        // assert that result is emtpy.
        assertEquals(0, response.getCommentIds().size());
        assertEquals(0, response.getActivityIds().size());
        assertEquals(0, response.getPeopleWithStarredActivities().keySet().size());
    }
View Full Code Here

Examples of org.eurekastreams.server.persistence.mappers.requests.BulkActivityDeleteResponse

     */
    @Test
    public void testExecute()
    {
        // call sut.
        BulkActivityDeleteResponse response = sut.execute(groupId);

        // assert results are correct.
        assertTrue(response.getCommentIds().contains(comment1Id));
        assertTrue(response.getCommentIds().contains(comment2Id));
        assertTrue(response.getActivityIds().contains(activityId));
        assertNotNull(response.getPeopleWithStarredActivities());

        // assert that expected activity and comments are actually gone.
        assertEquals(0, getEntityManager().createQuery("From Activity WHERE id=:activityId").setParameter("activityId",
                activityId).getResultList().size());

View Full Code Here

Examples of org.eurekastreams.server.persistence.mappers.requests.BulkActivityDeleteResponse

     */
    @Test
    public void testExecuteGroupGone()
    {
        // call sut.
        BulkActivityDeleteResponse response = sut.execute(fakeGroupId);

        // assert that result is empty.
        assertEquals(0, response.getCommentIds().size());
        assertEquals(0, response.getActivityIds().size());
        assertEquals(0, response.getPeopleWithStarredActivities().keySet().size());
    }
View Full Code Here

Examples of org.eurekastreams.server.persistence.mappers.requests.BulkActivityDeleteResponse

        // assert that 1 Person has the to-be deleted group as a bookmark
        assertEquals(1, getEntityManager().createQuery("From PersonBookmark pb WHERE pb.pk.scopeId = :groupId")
                .setParameter("groupId", streamscopeIdOfRemovedGroup).getResultList().size());
       
        // call sut.
        BulkActivityDeleteResponse response = sut.execute(groupIdForRemoveBookmarksTest);
      
        // assert that no Person has a bookmark to this deleted group
        assertEquals(0, getEntityManager().createQuery("From PersonBookmark pb WHERE pb.pk.scopeId = :groupId")
                .setParameter("groupId", streamscopeIdOfRemovedGroup).getResultList().size());
    }
View Full Code Here

Examples of org.eurekastreams.server.persistence.mappers.requests.BulkActivityDeleteResponse

        // get groupDTO to fetch group stream id
        Long groupStreamId = getGroupStreamId(inRequest);
        if (groupStreamId == null)
        {
            // short-circut as group is no longer present.
            return new BulkActivityDeleteResponse();
        }

        // get activity ids to return (cache and search index cleanup)
        List<Long> activityIds = getActivityIds(groupStreamId);

        // get comment ids to return (cache and search index cleanup)
        List<Long> commentIds = getCommentIds(groupStreamId);

        // get people with starred Activities map (cache clean up).
        Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inRequest);

        // Why the following queries use sub-selects:
        // FROM HIBERNATE DOCS: No joins can be specified in a bulk HQL query. Sub-queries can be used in the
        // where-clause,
        // where the subqueries themselves may contain joins.
        getEntityManager().createQuery(
                "DELETE FROM Comment c WHERE c.target.id IN"
                        + " (SELECT a.id FROM Activity a  WHERE a.recipientStreamScope.id = :groupStreamId)")// \n
                .setParameter("groupStreamId", groupStreamId).executeUpdate();

        // delete activity from currentUser's starred activity collections in DB.
        getEntityManager().createQuery(
                "DELETE FROM StarredActivity where activityId IN"
                        + " (SELECT a.id FROM Activity a  WHERE a.recipientStreamScope.id = :groupStreamId)")// \n
                .setParameter("groupStreamId", groupStreamId).executeUpdate();

        // delete activity hashtags for this group stream
        if (!activityIds.isEmpty())
        {
            getEntityManager().createQuery("DELETE FROM StreamHashTag where activityId IN (:activityIds)")
                    .setParameter("activityIds", activityIds).executeUpdate();
        }

        // delete the activities.
        getEntityManager().createQuery("DELETE FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId")
                .setParameter("groupStreamId", groupStreamId).executeUpdate();
       
        // delete any Person's bookmark to the group that's just about to be deleted
        getEntityManager().createQuery("DELETE FROM PersonBookmark pb where pb.pk.scopeId = :groupStreamId)")
                .setParameter("groupStreamId", groupStreamId).executeUpdate();

        return new BulkActivityDeleteResponse(activityIds, commentIds, peopleWithStarredActivities);
    }
View Full Code Here

Examples of org.eurekastreams.server.persistence.mappers.requests.BulkActivityDeleteResponse

        {
            log.debug("Deleting activities for groupid:" + groupId);
            startTime = System.currentTimeMillis();
        }
        // Delete comments/activities/starred activity associations
        BulkActivityDeleteResponse deleteActivityResponse = deleteGroupActivityDAO.execute(groupId);
        if (log.isDebugEnabled())
        {
            endTime = System.currentTimeMillis();
            log.debug("Time to delete activities/comments: " + (endTime - startTime));

            log.debug("Removing followers for groupid:" + groupId);
            startTime = endTime;
        }
        // Remove user/group follower associations (reset order indexes) and adjust groupsCount for followers.
        List<Long> followerIds = removeGroupFollowersDAO.execute(groupId);
        if (log.isDebugEnabled())
        {
            endTime = System.currentTimeMillis();
            log.debug("Time to remove followers from group: " + (endTime - startTime));

            log.debug("Removing group subscriptions for groupid:" + groupId);
            startTime = endTime;
        }
        // Remove feed subscriptions for group.
        deleteGroupFeedSubscriptions.execute(new DeleteAllFeedSubscriberByEntityTypeAndIdRequest(groupId,
                EntityType.GROUP));
        if (log.isDebugEnabled())
        {
            endTime = System.currentTimeMillis();
            log.debug("Time to remove group subscriptions: " + (endTime - startTime));

            log.debug("Removing group and associated objects for groupid:" + groupId);
            startTime = endTime;
        }
        // Remove the group itself and adjust parent org stats recursively
        DeleteGroupResponse deleteGroupResponse = deleteGroupDAO.execute(groupId);
        if (log.isDebugEnabled())
        {
            endTime = System.currentTimeMillis();
            log.debug("Time to remove group and associated objects: " + (endTime - startTime));
        }

        Long endDB = null;
        if (log.isInfoEnabled())
        {
            endDB = System.currentTimeMillis();
        }

        // ================= Cache update task generation =======================
      
  Long startAsync = null;
        if (log.isInfoEnabled())
        {
            startAsync = System.currentTimeMillis();
        }

        int startSize = 0;
        int endSize = 0;

        if (log.isDebugEnabled())
        {
            startSize = inActionContext.getUserActionRequests().size();
        }
        // purge fixed set of cache keys.
        generateSingleDeleteKeyFromCacheTask(getKeysToPurgeFromCache(deleteGroupResponse), inActionContext);

        if (log.isDebugEnabled())
        {
            endSize = inActionContext.getUserActionRequests().size();
            log.debug("Tasks for purge fixed set of cache keys: " + (endSize - startSize));
        }

        startSize = endSize;
        // create tasks (1/key) for removing group id from CacheKeys.GROUPS_FOLLOWED_BY_PERSON lists
        generateRemoveIdsFromListTasks(createKeys(CacheKeys.GROUPS_FOLLOWED_BY_PERSON, followerIds), Collections
                .singletonList(deleteGroupResponse.getGroupId()), inActionContext);

        if (log.isDebugEnabled())
        {
            endSize = inActionContext.getUserActionRequests().size();
            log.debug("Tasks for remove group id from GROUPS_FOLLOWED_BY_PERSON lists: " + (endSize - startSize));
        }

        startSize = endSize;
        // create task for removing activities in group's stream from users' starred activity lists.
        generateRemoveIdsFromStarredActivityListTasks(deleteActivityResponse, inActionContext);

        if (log.isDebugEnabled())
        {
            endSize = inActionContext.getUserActionRequests().size();
            log.debug("Tasks for remove groups activity ids from starred activity lists: " + (endSize - startSize));
        }

        // get list of activity ids to remove from cache lists, no need to go beyond maxCacheListSize
        List<Long> cachedActivityIds = deleteActivityResponse.getActivityIds().size() > maxCacheListSize // \n
        ? deleteActivityResponse.getActivityIds().subList(0, maxCacheListSize - 1)
                : deleteActivityResponse.getActivityIds();

        startSize = endSize;

        if (log.isDebugEnabled())
        {
            endSize = inActionContext.getUserActionRequests().size();
            log.debug("Tasks for remove activity ids from parent orgs of the deleted group: " + (endSize - startSize));
        }

        // create task for removing activities in group's stream from everyone stream
        generateRemoveIdsFromListTasks(Collections.singletonList(CacheKeys.EVERYONE_ACTIVITY_IDS), cachedActivityIds,
                inActionContext);

        startSize = endSize;
        // purge group from search index.
        generateDeleteFromSearchIndexTasks(DomainGroup.class, Collections.singletonList(deleteGroupResponse
                .getGroupId()), inActionContext);

        if (log.isDebugEnabled())
        {
            endSize = inActionContext.getUserActionRequests().size();
            log.debug("Tasks for purge group from search index: " + (endSize - startSize));
        }

        startSize = endSize;
        // purge ALL activities from search index.
        generateDeleteFromSearchIndexTasks(Activity.class, deleteActivityResponse.getActivityIds(), inActionContext);

        if (log.isDebugEnabled())
        {
            endSize = inActionContext.getUserActionRequests().size();
            log.debug("Tasks for purge ALL activities from search index: " + (endSize - startSize));
        }

        startSize = endSize;
        // remove ALL activities from cache (low priority should we even do this?)
        generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.ACTIVITY_BY_ID,
                deleteActivityResponse.getActivityIds())), inActionContext);

        if (log.isDebugEnabled())
        {
            endSize = inActionContext.getUserActionRequests().size();
            log.debug("Tasks for remove ALL activities from cache: " + (endSize - startSize));
        }

        startSize = endSize;
        // remove ALL comments from cache (low priority should we even do this?)
        generateIndividualDeleteKeyFromCacheTasks(new HashSet<String>(createKeys(CacheKeys.COMMENT_BY_ID,
                deleteActivityResponse.getCommentIds())), inActionContext);

        if (log.isDebugEnabled())
        {
            endSize = inActionContext.getUserActionRequests().size();
            log.debug("Tasks for remove ALL comments from cache: " + (endSize - startSize));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.