Package org.eurekastreams.server.persistence.mappers.requests

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


    public void testExecute()
    {
        final List<UserActionRequest> requests = new ArrayList<UserActionRequest>();
        final int maxCacheListSize = 10000;
        final String shortName = "shortname";
        final DeleteGroupResponse deleteGroupResponse = new DeleteGroupResponse(groupId, shortName, 3L);

        sut = new DeleteGroupFromDBExecution(deleteGroupActivityDAO, removeGroupFollowersDAO, deleteGroupDAO,
                deleteGroupSubscriptionsDAO, maxCacheListSize);

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


    public DeleteGroupResponse execute(final Long inRequest)
    {
        DomainGroup group = groupMapper.execute(new FindByIdRequest("DomainGroup", inRequest));
        Long groupId = group.getId();

        DeleteGroupResponse response = new DeleteGroupResponse(groupId, group.getShortName(), new Long(group
                .getStreamScope().getId()));

        getEntityManager().createQuery(
                "DELETE FROM StreamHashTag WHERE streamEntityUniqueKey = :uniqueKey AND streamScopeType = :type")
                .setParameter("uniqueKey", group.getUniqueId()).setParameter("type", ScopeType.GROUP).executeUpdate();
View Full Code Here

        assertEquals(1, getEntityManager().createQuery("FROM StreamScope WHERE id = 875").getResultList().size());
        assertEquals(1, getEntityManager().createQuery(
                "FROM StreamHashTag WHERE streamEntityUniqueKey = :uniqueKey AND streamScopeType = :type")
                .setParameter("uniqueKey", "group2").setParameter("type", ScopeType.GROUP).getResultList().size());

        DeleteGroupResponse response = sut.execute(groupId);

        getEntityManager().flush();
        getEntityManager().clear();

        // assert response values are correct.
        assertEquals(2, response.getGroupId().longValue());
        assertEquals("group2", response.getGroupShortName());
        assertEquals(groupStreamScopeId, response.getStreamScopeId().longValue());

        // verify associated items are gone as expected.
        // TODO: This could be filled out with more related entities to ensure cascading doesn't change for DomainGroup.
        assertEquals(0, getEntityManager().createQuery("FROM DomainGroup WHERE id = 2").getResultList().size());
        assertEquals(0, getEntityManager().createQuery("FROM StreamScope WHERE id = 875").getResultList().size());
View Full Code Here

            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();
View Full Code Here

TOP

Related Classes of org.eurekastreams.server.persistence.mappers.requests.DeleteGroupResponse

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.