@Test public void testExecute() { BulkActivityDeleteResponse response = sut.execute(groupId); assertTrue(response.getCommentIds().contains(comment1Id)); assertTrue(response.getCommentIds().contains(comment2Id)); assertTrue(response.getActivityIds().contains(activityId)); assertNotNull(response.getPeopleWithStarredActivities()); assertEquals(0, getEntityManager().createQuery("From Activity WHERE id=:activityId").setParameter("activityId", activityId).getResultList().size()); assertEquals(0, getEntityManager().createQuery("From Comment WHERE id=:commentId").setParameter("commentId", comment1Id).getResultList().size()); assertEquals(0, getEntityManager().createQuery("From Comment WHERE id=:commentId").setParameter("commentId", comment2Id).getResultList().size()); }
@Override public BulkActivityDeleteResponse execute(final Long inRequest) { Long groupStreamId = getGroupStreamId(inRequest); if (groupStreamId == null) { return new BulkActivityDeleteResponse(); } List<Long> activityIds = getActivityIds(groupStreamId); List<Long> commentIds = getCommentIds(groupStreamId); Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inRequest); getEntityManager().createQuery( "DELETE FROM Comment c WHERE c.target.id IN" + " (SELECT a.id FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); getEntityManager().createQuery( "DELETE FROM StarredActivity where activityId IN" + " (SELECT a.id FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); if (!activityIds.isEmpty()) { getEntityManager().createQuery("DELETE FROM StreamHashTag where activityId IN (:activityIds)") .setParameter("activityIds", activityIds).executeUpdate(); } getEntityManager().createQuery("DELETE FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId") .setParameter("groupStreamId", groupStreamId).executeUpdate(); getEntityManager().createQuery("DELETE FROM PersonBookmark pb where pb.pk.scopeId = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); return new BulkActivityDeleteResponse(activityIds, commentIds, peopleWithStarredActivities); }
DeleteGroupActivity extends BaseArgDomainMapper<Long, BulkActivityDeleteResponse> { @Override public BulkActivityDeleteResponse execute(final Long inRequest) { Long groupStreamId = getGroupStreamId(inRequest); if (groupStreamId == null) { return new BulkActivityDeleteResponse(); } List<Long> activityIds = getActivityIds(groupStreamId); List<Long> commentIds = getCommentIds(groupStreamId); Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inRequest); getEntityManager().createQuery( "DELETE FROM Comment c WHERE c.target.id IN" + " (SELECT a.id FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); getEntityManager().createQuery( "DELETE FROM StarredActivity where activityId IN" + " (SELECT a.id FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); if (!activityIds.isEmpty()) { getEntityManager().createQuery("DELETE FROM StreamHashTag where activityId IN (:activityIds)") .setParameter("activityIds", activityIds).executeUpdate(); } getEntityManager().createQuery("DELETE FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId") .setParameter("groupStreamId", groupStreamId).executeUpdate(); getEntityManager().createQuery("DELETE FROM PersonBookmark pb where pb.pk.scopeId = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); return new BulkActivityDeleteResponse(activityIds, commentIds, peopleWithStarredActivities); } }
DeleteGroupActivity extends BaseArgDomainMapper<Long, BulkActivityDeleteResponse> { @Override public BulkActivityDeleteResponse execute(final Long inRequest) { Long groupStreamId = getGroupStreamId(inRequest); if (groupStreamId == null) { return new BulkActivityDeleteResponse(); } List<Long> activityIds = getActivityIds(groupStreamId); List<Long> commentIds = getCommentIds(groupStreamId); Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inRequest); getEntityManager().createQuery( "DELETE FROM Comment c WHERE c.target.id IN" + " (SELECT a.id FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); getEntityManager().createQuery( "DELETE FROM StarredActivity where activityId IN" + " (SELECT a.id FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); if (!activityIds.isEmpty()) { getEntityManager().createQuery("DELETE FROM StreamHashTag where activityId IN (:activityIds)") .setParameter("activityIds", activityIds).executeUpdate(); } getEntityManager().createQuery("DELETE FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId") .setParameter("groupStreamId", groupStreamId).executeUpdate(); getEntityManager().createQuery("DELETE FROM PersonBookmark pb where pb.pk.scopeId = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); return new BulkActivityDeleteResponse(activityIds, commentIds, peopleWithStarredActivities); }  }
DeleteGroupActivity extends BaseArgDomainMapper<Long, BulkActivityDeleteResponse> { @Override public BulkActivityDeleteResponse execute(final Long inRequest) { Long groupStreamId = getGroupStreamId(inRequest); if (groupStreamId == null) { return new BulkActivityDeleteResponse(); } List<Long> activityIds = getActivityIds(groupStreamId); List<Long> commentIds = getCommentIds(groupStreamId); Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inRequest); getEntityManager().createQuery( "DELETE FROM Comment c WHERE c.target.id IN" + " (SELECT a.id FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); getEntityManager().createQuery( "DELETE FROM StarredActivity where activityId IN" + " (SELECT a.id FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); if (!activityIds.isEmpty()) { getEntityManager().createQuery("DELETE FROM StreamHashTag where activityId IN (:activityIds)") .setParameter("activityIds", activityIds).executeUpdate(); } getEntityManager().createQuery("DELETE FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId") .setParameter("groupStreamId", groupStreamId).executeUpdate(); getEntityManager().createQuery("DELETE FROM PersonBookmark pb where pb.pk.scopeId = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); return new BulkActivityDeleteResponse(activityIds, commentIds, peopleWithStarredActivities); }  @Override BulkActivityDeleteResponse execute(final Long inRequest); }
DeleteGroupActivity extends BaseArgDomainMapper<Long, BulkActivityDeleteResponse> { @Override public BulkActivityDeleteResponse execute(final Long inRequest) { Long groupStreamId = getGroupStreamId(inRequest); if (groupStreamId == null) { return new BulkActivityDeleteResponse(); } List<Long> activityIds = getActivityIds(groupStreamId); List<Long> commentIds = getCommentIds(groupStreamId); Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inRequest); getEntityManager().createQuery( "DELETE FROM Comment c WHERE c.target.id IN" + " (SELECT a.id FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); getEntityManager().createQuery( "DELETE FROM StarredActivity where activityId IN" + " (SELECT a.id FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); if (!activityIds.isEmpty()) { getEntityManager().createQuery("DELETE FROM StreamHashTag where activityId IN (:activityIds)") .setParameter("activityIds", activityIds).executeUpdate(); } getEntityManager().createQuery("DELETE FROM Activity a WHERE a.recipientStreamScope.id = :groupStreamId") .setParameter("groupStreamId", groupStreamId).executeUpdate(); getEntityManager().createQuery("DELETE FROM PersonBookmark pb where pb.pk.scopeId = :groupStreamId)") .setParameter("groupStreamId", groupStreamId).executeUpdate(); return new BulkActivityDeleteResponse(activityIds, commentIds, peopleWithStarredActivities); }  @Override BulkActivityDeleteResponse execute(final Long inRequest);  }