@Test public void testExecute() { BulkActivityDeleteResponse response = sut.execute(Arrays.asList(activityId)); 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 List<Long> inActivityIds) { if (inActivityIds == null || inActivityIds.isEmpty()) { return new BulkActivityDeleteResponse(); } List<Long> commentIds = getCommentIds(inActivityIds); Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inActivityIds); getHibernateSession().createQuery("DELETE FROM Comment c WHERE c.target.id IN (:activityIds)") .setParameterList("activityIds", inActivityIds).executeUpdate(); getHibernateSession().createQuery("DELETE FROM StarredActivity where activityId IN (:activityIds)") .setParameterList("activityIds", inActivityIds).executeUpdate(); getEntityManager().createQuery("DELETE FROM StreamHashTag WHERE activity.id in (:activityIds)").setParameter( "activityIds", inActivityIds).executeUpdate(); getHibernateSession().createQuery("DELETE FROM Activity a WHERE a.id IN (:activityIds)").setParameterList( "activityIds", inActivityIds).executeUpdate(); return new BulkActivityDeleteResponse(inActivityIds, commentIds, peopleWithStarredActivities); }
DeleteActivities extends BaseArgDomainMapper<List<Long>, BulkActivityDeleteResponse> { @Override public BulkActivityDeleteResponse execute(final List<Long> inActivityIds) { if (inActivityIds == null || inActivityIds.isEmpty()) { return new BulkActivityDeleteResponse(); } List<Long> commentIds = getCommentIds(inActivityIds); Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inActivityIds); getHibernateSession().createQuery("DELETE FROM Comment c WHERE c.target.id IN (:activityIds)") .setParameterList("activityIds", inActivityIds).executeUpdate(); getHibernateSession().createQuery("DELETE FROM StarredActivity where activityId IN (:activityIds)") .setParameterList("activityIds", inActivityIds).executeUpdate(); getEntityManager().createQuery("DELETE FROM StreamHashTag WHERE activity.id in (:activityIds)").setParameter( "activityIds", inActivityIds).executeUpdate(); getHibernateSession().createQuery("DELETE FROM Activity a WHERE a.id IN (:activityIds)").setParameterList( "activityIds", inActivityIds).executeUpdate(); return new BulkActivityDeleteResponse(inActivityIds, commentIds, peopleWithStarredActivities); } }
DeleteActivities extends BaseArgDomainMapper<List<Long>, BulkActivityDeleteResponse> { @Override public BulkActivityDeleteResponse execute(final List<Long> inActivityIds) { if (inActivityIds == null || inActivityIds.isEmpty()) { return new BulkActivityDeleteResponse(); } List<Long> commentIds = getCommentIds(inActivityIds); Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inActivityIds); getHibernateSession().createQuery("DELETE FROM Comment c WHERE c.target.id IN (:activityIds)") .setParameterList("activityIds", inActivityIds).executeUpdate(); getHibernateSession().createQuery("DELETE FROM StarredActivity where activityId IN (:activityIds)") .setParameterList("activityIds", inActivityIds).executeUpdate(); getEntityManager().createQuery("DELETE FROM StreamHashTag WHERE activity.id in (:activityIds)").setParameter( "activityIds", inActivityIds).executeUpdate(); getHibernateSession().createQuery("DELETE FROM Activity a WHERE a.id IN (:activityIds)").setParameterList( "activityIds", inActivityIds).executeUpdate(); return new BulkActivityDeleteResponse(inActivityIds, commentIds, peopleWithStarredActivities); }  }
DeleteActivities extends BaseArgDomainMapper<List<Long>, BulkActivityDeleteResponse> { @Override public BulkActivityDeleteResponse execute(final List<Long> inActivityIds) { if (inActivityIds == null || inActivityIds.isEmpty()) { return new BulkActivityDeleteResponse(); } List<Long> commentIds = getCommentIds(inActivityIds); Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inActivityIds); getHibernateSession().createQuery("DELETE FROM Comment c WHERE c.target.id IN (:activityIds)") .setParameterList("activityIds", inActivityIds).executeUpdate(); getHibernateSession().createQuery("DELETE FROM StarredActivity where activityId IN (:activityIds)") .setParameterList("activityIds", inActivityIds).executeUpdate(); getEntityManager().createQuery("DELETE FROM StreamHashTag WHERE activity.id in (:activityIds)").setParameter( "activityIds", inActivityIds).executeUpdate(); getHibernateSession().createQuery("DELETE FROM Activity a WHERE a.id IN (:activityIds)").setParameterList( "activityIds", inActivityIds).executeUpdate(); return new BulkActivityDeleteResponse(inActivityIds, commentIds, peopleWithStarredActivities); }  @Override BulkActivityDeleteResponse execute(final List<Long> inActivityIds); }
DeleteActivities extends BaseArgDomainMapper<List<Long>, BulkActivityDeleteResponse> { @Override public BulkActivityDeleteResponse execute(final List<Long> inActivityIds) { if (inActivityIds == null || inActivityIds.isEmpty()) { return new BulkActivityDeleteResponse(); } List<Long> commentIds = getCommentIds(inActivityIds); Map<Long, Set<Long>> peopleWithStarredActivities = getPeopleWithStarredActivities(inActivityIds); getHibernateSession().createQuery("DELETE FROM Comment c WHERE c.target.id IN (:activityIds)") .setParameterList("activityIds", inActivityIds).executeUpdate(); getHibernateSession().createQuery("DELETE FROM StarredActivity where activityId IN (:activityIds)") .setParameterList("activityIds", inActivityIds).executeUpdate(); getEntityManager().createQuery("DELETE FROM StreamHashTag WHERE activity.id in (:activityIds)").setParameter( "activityIds", inActivityIds).executeUpdate(); getHibernateSession().createQuery("DELETE FROM Activity a WHERE a.id IN (:activityIds)").setParameterList( "activityIds", inActivityIds).executeUpdate(); return new BulkActivityDeleteResponse(inActivityIds, commentIds, peopleWithStarredActivities); }  @Override BulkActivityDeleteResponse execute(final List<Long> inActivityIds);  }