@Test public void testExecute() { final List<Long> parentOrgIds = new ArrayList<Long>(); parentOrgIds.add(5L); GetListsContainingActivities sut = new GetListsContainingActivities(); sut.setEntityManager(getEntityManager()); final int keySize = 7; final int author1 = 98; final int author2 = 42; final int follower1 = 99; final int follower2 = 142; List<Long> activityIds = new ArrayList<Long>(); activityIds.add(TEST_ACTIVITY_ID_1); activityIds.add(TEST_ACTIVITY_ID_2); List<String> keys = sut.execute(activityIds); assertEquals(keySize, keys.size()); assertTrue(keys.contains(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + "87433")); assertTrue(keys.contains(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + "2")); assertTrue(keys.contains(CacheKeys.EVERYONE_ACTIVITY_IDS)); assertTrue(keys.contains(CacheKeys.EVERYONE_ACTIVITY_IDS)); assertTrue(keys.contains(CacheKeys.ACTIVITIES_BY_FOLLOWING + follower1)); assertTrue(keys.contains(CacheKeys.ACTIVITIES_BY_FOLLOWING + follower2)); assertTrue(keys.contains(CacheKeys.ACTIVITIES_BY_FOLLOWING + author1)); assertTrue(keys.contains(CacheKeys.ACTIVITIES_BY_FOLLOWING + author2)); context.assertIsSatisfied(); }
@SuppressWarnings("unchecked") public List<String> execute(final List<Long> activityIds) { Set<String> lists = new HashSet<String>(); Set<String> authorAccountIds = new HashSet<String>(); if (logger.isTraceEnabled()) { logger.trace("Retrieve the activities for the supplied activity ids: " + activityIds.size()); } List<Activity> activities = getHibernateSession().createQuery("from Activity where id in (:activityIds)") .setParameterList("activityIds", activityIds).list(); if (logger.isTraceEnabled()) { logger.trace("Loop through the retrieved activities " + activities.size() + " to build the list of stream scopes and the authorAccountIds."); } for (Activity activity : activities) { lists.add(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + activity.getRecipientStreamScope().getId()); if (activity.getActorType() == EntityType.PERSON) { authorAccountIds.add(activity.getActorId()); } } if (logger.isTraceEnabled()) { logger.trace("Retrieve the CompositeStreamViews that contain the streamscopes: " + activities.size() + " for the activities to be deleted."); } if (logger.isTraceEnabled()) { logger.trace("Retrieve the follower ids of the authors: " + authorAccountIds.size() + " of the activities to be deleted: "); } List<Long> followerIds = getHibernateSession().createQuery( "select f.pk.followerId from Follower f where f.pk.followingId in " + "(select id from Person p where p.accountId in (:authorIds))").setParameterList("authorIds", authorAccountIds).list(); if (logger.isTraceEnabled()) { logger.trace("Retrieved follower ids " + followerIds.size() + " of the authors of the activities to be deleted: "); } for (long followerId : followerIds) { lists.add(CacheKeys.ACTIVITIES_BY_FOLLOWING + followerId); } lists.add(CacheKeys.EVERYONE_ACTIVITY_IDS); if (logger.isTraceEnabled()) { logger.trace("Retrieve all lists containing the supplied activities count: " + lists.size() + " keys: " + lists); } return new ArrayList(lists); }
GetListsContainingActivities extends BaseArgDomainMapper<List<Long>, List<String>> { @SuppressWarnings("unchecked") public List<String> execute(final List<Long> activityIds) { Set<String> lists = new HashSet<String>(); Set<String> authorAccountIds = new HashSet<String>(); if (logger.isTraceEnabled()) { logger.trace("Retrieve the activities for the supplied activity ids: " + activityIds.size()); } List<Activity> activities = getHibernateSession().createQuery("from Activity where id in (:activityIds)") .setParameterList("activityIds", activityIds).list(); if (logger.isTraceEnabled()) { logger.trace("Loop through the retrieved activities " + activities.size() + " to build the list of stream scopes and the authorAccountIds."); } for (Activity activity : activities) { lists.add(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + activity.getRecipientStreamScope().getId()); if (activity.getActorType() == EntityType.PERSON) { authorAccountIds.add(activity.getActorId()); } } if (logger.isTraceEnabled()) { logger.trace("Retrieve the CompositeStreamViews that contain the streamscopes: " + activities.size() + " for the activities to be deleted."); } if (logger.isTraceEnabled()) { logger.trace("Retrieve the follower ids of the authors: " + authorAccountIds.size() + " of the activities to be deleted: "); } List<Long> followerIds = getHibernateSession().createQuery( "select f.pk.followerId from Follower f where f.pk.followingId in " + "(select id from Person p where p.accountId in (:authorIds))").setParameterList("authorIds", authorAccountIds).list(); if (logger.isTraceEnabled()) { logger.trace("Retrieved follower ids " + followerIds.size() + " of the authors of the activities to be deleted: "); } for (long followerId : followerIds) { lists.add(CacheKeys.ACTIVITIES_BY_FOLLOWING + followerId); } lists.add(CacheKeys.EVERYONE_ACTIVITY_IDS); if (logger.isTraceEnabled()) { logger.trace("Retrieve all lists containing the supplied activities count: " + lists.size() + " keys: " + lists); } return new ArrayList(lists); } }
GetListsContainingActivities extends BaseArgDomainMapper<List<Long>, List<String>> { @SuppressWarnings("unchecked") public List<String> execute(final List<Long> activityIds) { Set<String> lists = new HashSet<String>(); Set<String> authorAccountIds = new HashSet<String>(); if (logger.isTraceEnabled()) { logger.trace("Retrieve the activities for the supplied activity ids: " + activityIds.size()); } List<Activity> activities = getHibernateSession().createQuery("from Activity where id in (:activityIds)") .setParameterList("activityIds", activityIds).list(); if (logger.isTraceEnabled()) { logger.trace("Loop through the retrieved activities " + activities.size() + " to build the list of stream scopes and the authorAccountIds."); } for (Activity activity : activities) { lists.add(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + activity.getRecipientStreamScope().getId()); if (activity.getActorType() == EntityType.PERSON) { authorAccountIds.add(activity.getActorId()); } } if (logger.isTraceEnabled()) { logger.trace("Retrieve the CompositeStreamViews that contain the streamscopes: " + activities.size() + " for the activities to be deleted."); } if (logger.isTraceEnabled()) { logger.trace("Retrieve the follower ids of the authors: " + authorAccountIds.size() + " of the activities to be deleted: "); } List<Long> followerIds = getHibernateSession().createQuery( "select f.pk.followerId from Follower f where f.pk.followingId in " + "(select id from Person p where p.accountId in (:authorIds))").setParameterList("authorIds", authorAccountIds).list(); if (logger.isTraceEnabled()) { logger.trace("Retrieved follower ids " + followerIds.size() + " of the authors of the activities to be deleted: "); } for (long followerId : followerIds) { lists.add(CacheKeys.ACTIVITIES_BY_FOLLOWING + followerId); } lists.add(CacheKeys.EVERYONE_ACTIVITY_IDS); if (logger.isTraceEnabled()) { logger.trace("Retrieve all lists containing the supplied activities count: " + lists.size() + " keys: " + lists); } return new ArrayList(lists); }  }
GetListsContainingActivities extends BaseArgDomainMapper<List<Long>, List<String>> { @SuppressWarnings("unchecked") public List<String> execute(final List<Long> activityIds) { Set<String> lists = new HashSet<String>(); Set<String> authorAccountIds = new HashSet<String>(); if (logger.isTraceEnabled()) { logger.trace("Retrieve the activities for the supplied activity ids: " + activityIds.size()); } List<Activity> activities = getHibernateSession().createQuery("from Activity where id in (:activityIds)") .setParameterList("activityIds", activityIds).list(); if (logger.isTraceEnabled()) { logger.trace("Loop through the retrieved activities " + activities.size() + " to build the list of stream scopes and the authorAccountIds."); } for (Activity activity : activities) { lists.add(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + activity.getRecipientStreamScope().getId()); if (activity.getActorType() == EntityType.PERSON) { authorAccountIds.add(activity.getActorId()); } } if (logger.isTraceEnabled()) { logger.trace("Retrieve the CompositeStreamViews that contain the streamscopes: " + activities.size() + " for the activities to be deleted."); } if (logger.isTraceEnabled()) { logger.trace("Retrieve the follower ids of the authors: " + authorAccountIds.size() + " of the activities to be deleted: "); } List<Long> followerIds = getHibernateSession().createQuery( "select f.pk.followerId from Follower f where f.pk.followingId in " + "(select id from Person p where p.accountId in (:authorIds))").setParameterList("authorIds", authorAccountIds).list(); if (logger.isTraceEnabled()) { logger.trace("Retrieved follower ids " + followerIds.size() + " of the authors of the activities to be deleted: "); } for (long followerId : followerIds) { lists.add(CacheKeys.ACTIVITIES_BY_FOLLOWING + followerId); } lists.add(CacheKeys.EVERYONE_ACTIVITY_IDS); if (logger.isTraceEnabled()) { logger.trace("Retrieve all lists containing the supplied activities count: " + lists.size() + " keys: " + lists); } return new ArrayList(lists); }  @SuppressWarnings("unchecked") List<String> execute(final List<Long> activityIds); }
GetListsContainingActivities extends BaseArgDomainMapper<List<Long>, List<String>> { @SuppressWarnings("unchecked") public List<String> execute(final List<Long> activityIds) { Set<String> lists = new HashSet<String>(); Set<String> authorAccountIds = new HashSet<String>(); if (logger.isTraceEnabled()) { logger.trace("Retrieve the activities for the supplied activity ids: " + activityIds.size()); } List<Activity> activities = getHibernateSession().createQuery("from Activity where id in (:activityIds)") .setParameterList("activityIds", activityIds).list(); if (logger.isTraceEnabled()) { logger.trace("Loop through the retrieved activities " + activities.size() + " to build the list of stream scopes and the authorAccountIds."); } for (Activity activity : activities) { lists.add(CacheKeys.ENTITY_STREAM_BY_SCOPE_ID + activity.getRecipientStreamScope().getId()); if (activity.getActorType() == EntityType.PERSON) { authorAccountIds.add(activity.getActorId()); } } if (logger.isTraceEnabled()) { logger.trace("Retrieve the CompositeStreamViews that contain the streamscopes: " + activities.size() + " for the activities to be deleted."); } if (logger.isTraceEnabled()) { logger.trace("Retrieve the follower ids of the authors: " + authorAccountIds.size() + " of the activities to be deleted: "); } List<Long> followerIds = getHibernateSession().createQuery( "select f.pk.followerId from Follower f where f.pk.followingId in " + "(select id from Person p where p.accountId in (:authorIds))").setParameterList("authorIds", authorAccountIds).list(); if (logger.isTraceEnabled()) { logger.trace("Retrieved follower ids " + followerIds.size() + " of the authors of the activities to be deleted: "); } for (long followerId : followerIds) { lists.add(CacheKeys.ACTIVITIES_BY_FOLLOWING + followerId); } lists.add(CacheKeys.EVERYONE_ACTIVITY_IDS); if (logger.isTraceEnabled()) { logger.trace("Retrieve all lists containing the supplied activities count: " + lists.size() + " keys: " + lists); } return new ArrayList(lists); }  @SuppressWarnings("unchecked") List<String> execute(final List<Long> activityIds);  }