@Test(expected = RuntimeException.class) public void testExecuteWithoutUserAccountId() { PagedSet<ActivityDTO> flaggedActivities = sut.execute(new GetFlaggedActivitiesRequest(0, 9)); assertEquals(1, flaggedActivities.getPagedSet().size()); }
@Override @SuppressWarnings("unchecked") public PagedSet<ActivityDTO> execute(final GetFlaggedActivitiesRequest inRequest) { if (inRequest.getRequestingUserAccountId() == null) { log.error("Missing requesting user account."); throw new RuntimeException("Missing requesting user account."); } Long flaggedActivityCount = (Long) buildQuery("count(*)").getSingleResult(); List<ActivityDTO> activities; if (flaggedActivityCount > 0) { log.info("Found " + flaggedActivityCount + " flagged activity ids - passing them to the bulk activity mapper for ActivityDTOs."); Query q = buildQuery("id"); q.setFirstResult(inRequest.getStartIndex()); q.setMaxResults(inRequest.getEndIndex() - inRequest.getStartIndex() + 1); List<Long> activityIds = q.getResultList(); activities = activitiesMapper.execute(activityIds); } else { log.info("Found no flagged activity ids."); activities = new ArrayList<ActivityDTO>(); } return new PagedSet<ActivityDTO>(inRequest.getStartIndex(), inRequest.getEndIndex(), flaggedActivityCount .intValue(), activities); }
GetFlaggedActivities extends BaseArgDomainMapper<GetFlaggedActivitiesRequest, PagedSet<ActivityDTO>> { @Override @SuppressWarnings("unchecked") public PagedSet<ActivityDTO> execute(final GetFlaggedActivitiesRequest inRequest) { if (inRequest.getRequestingUserAccountId() == null) { log.error("Missing requesting user account."); throw new RuntimeException("Missing requesting user account."); } Long flaggedActivityCount = (Long) buildQuery("count(*)").getSingleResult(); List<ActivityDTO> activities; if (flaggedActivityCount > 0) { log.info("Found " + flaggedActivityCount + " flagged activity ids - passing them to the bulk activity mapper for ActivityDTOs."); Query q = buildQuery("id"); q.setFirstResult(inRequest.getStartIndex()); q.setMaxResults(inRequest.getEndIndex() - inRequest.getStartIndex() + 1); List<Long> activityIds = q.getResultList(); activities = activitiesMapper.execute(activityIds); } else { log.info("Found no flagged activity ids."); activities = new ArrayList<ActivityDTO>(); } return new PagedSet<ActivityDTO>(inRequest.getStartIndex(), inRequest.getEndIndex(), flaggedActivityCount .intValue(), activities); } }
GetFlaggedActivities extends BaseArgDomainMapper<GetFlaggedActivitiesRequest, PagedSet<ActivityDTO>> { @Override @SuppressWarnings("unchecked") public PagedSet<ActivityDTO> execute(final GetFlaggedActivitiesRequest inRequest) { if (inRequest.getRequestingUserAccountId() == null) { log.error("Missing requesting user account."); throw new RuntimeException("Missing requesting user account."); } Long flaggedActivityCount = (Long) buildQuery("count(*)").getSingleResult(); List<ActivityDTO> activities; if (flaggedActivityCount > 0) { log.info("Found " + flaggedActivityCount + " flagged activity ids - passing them to the bulk activity mapper for ActivityDTOs."); Query q = buildQuery("id"); q.setFirstResult(inRequest.getStartIndex()); q.setMaxResults(inRequest.getEndIndex() - inRequest.getStartIndex() + 1); List<Long> activityIds = q.getResultList(); activities = activitiesMapper.execute(activityIds); } else { log.info("Found no flagged activity ids."); activities = new ArrayList<ActivityDTO>(); } return new PagedSet<ActivityDTO>(inRequest.getStartIndex(), inRequest.getEndIndex(), flaggedActivityCount .intValue(), activities); } GetFlaggedActivities(final DomainMapper<List<Long>, List<ActivityDTO>> inActivitiesMapper); }
GetFlaggedActivities extends BaseArgDomainMapper<GetFlaggedActivitiesRequest, PagedSet<ActivityDTO>> { @Override @SuppressWarnings("unchecked") public PagedSet<ActivityDTO> execute(final GetFlaggedActivitiesRequest inRequest) { if (inRequest.getRequestingUserAccountId() == null) { log.error("Missing requesting user account."); throw new RuntimeException("Missing requesting user account."); } Long flaggedActivityCount = (Long) buildQuery("count(*)").getSingleResult(); List<ActivityDTO> activities; if (flaggedActivityCount > 0) { log.info("Found " + flaggedActivityCount + " flagged activity ids - passing them to the bulk activity mapper for ActivityDTOs."); Query q = buildQuery("id"); q.setFirstResult(inRequest.getStartIndex()); q.setMaxResults(inRequest.getEndIndex() - inRequest.getStartIndex() + 1); List<Long> activityIds = q.getResultList(); activities = activitiesMapper.execute(activityIds); } else { log.info("Found no flagged activity ids."); activities = new ArrayList<ActivityDTO>(); } return new PagedSet<ActivityDTO>(inRequest.getStartIndex(), inRequest.getEndIndex(), flaggedActivityCount .intValue(), activities); } GetFlaggedActivities(final DomainMapper<List<Long>, List<ActivityDTO>> inActivitiesMapper); @Override @SuppressWarnings("unchecked") PagedSet<ActivityDTO> execute(final GetFlaggedActivitiesRequest inRequest); }
GetFlaggedActivities extends BaseArgDomainMapper<GetFlaggedActivitiesRequest, PagedSet<ActivityDTO>> { @Override @SuppressWarnings("unchecked") public PagedSet<ActivityDTO> execute(final GetFlaggedActivitiesRequest inRequest) { if (inRequest.getRequestingUserAccountId() == null) { log.error("Missing requesting user account."); throw new RuntimeException("Missing requesting user account."); } Long flaggedActivityCount = (Long) buildQuery("count(*)").getSingleResult(); List<ActivityDTO> activities; if (flaggedActivityCount > 0) { log.info("Found " + flaggedActivityCount + " flagged activity ids - passing them to the bulk activity mapper for ActivityDTOs."); Query q = buildQuery("id"); q.setFirstResult(inRequest.getStartIndex()); q.setMaxResults(inRequest.getEndIndex() - inRequest.getStartIndex() + 1); List<Long> activityIds = q.getResultList(); activities = activitiesMapper.execute(activityIds); } else { log.info("Found no flagged activity ids."); activities = new ArrayList<ActivityDTO>(); } return new PagedSet<ActivityDTO>(inRequest.getStartIndex(), inRequest.getEndIndex(), flaggedActivityCount .intValue(), activities); } GetFlaggedActivities(final DomainMapper<List<Long>, List<ActivityDTO>> inActivitiesMapper); @Override @SuppressWarnings("unchecked") PagedSet<ActivityDTO> execute(final GetFlaggedActivitiesRequest inRequest);  }