@Test public void testExecuteSpecificStream() { final Long streamScopeId = 87433L; getEntityManager().createQuery("UPDATE Activity set postedTime=:date").setParameter("date", new Date(apri8th2011)).executeUpdate(); getEntityManager().createQuery("UPDATE Comment set timeSent=:date").setParameter("date", new Date(apri8th2011)) .executeUpdate(); Assert.assertEquals(3L, (long) sut.execute(new UsageMetricDailyStreamInfoRequest(new Date(apri8th2011), streamScopeId))); }
@Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Query activityQuery, commentQuery; Date startOfDay, endOfDay; HashSet<String> peopleIds = new HashSet<String>(); startOfDay = DateDayExtractor.getStartOfDay(inRequest.getMetricsDate()); endOfDay = DateDayExtractor.getEndOfDay(inRequest.getMetricsDate()); if (inRequest.getStreamRecipientStreamScopeId() == null) { activityQuery = getEntityManager().createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType" + " AND postedTime >= :startDate AND postedTime <= :endDate").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("actorType", EntityType.PERSON); commentQuery = getEntityManager().createQuery( "SELECT DISTINCT(author.accountId) FROM Comment WHERE timeSent >= :startDate" + " AND timeSent <= :endDate").setParameter("startDate", startOfDay).setParameter( "endDate", endOfDay); } else { activityQuery = getEntityManager().createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType" + " AND postedTime >= :startDate AND postedTime <= :endDate " + "AND recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("actorType", EntityType.PERSON) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); commentQuery = getEntityManager().createQuery( "SELECT DISTINCT(author.accountId) FROM Comment WHERE timeSent >= :startDate" + " AND timeSent <= :endDate " + "AND target.recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } peopleIds.addAll(activityQuery.getResultList()); peopleIds.addAll(commentQuery.getResultList()); return new Long(peopleIds.size()); }
GetDailyStreamContributorCountDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Query activityQuery, commentQuery; Date startOfDay, endOfDay; HashSet<String> peopleIds = new HashSet<String>(); startOfDay = DateDayExtractor.getStartOfDay(inRequest.getMetricsDate()); endOfDay = DateDayExtractor.getEndOfDay(inRequest.getMetricsDate()); if (inRequest.getStreamRecipientStreamScopeId() == null) { activityQuery = getEntityManager().createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType" + " AND postedTime >= :startDate AND postedTime <= :endDate").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("actorType", EntityType.PERSON); commentQuery = getEntityManager().createQuery( "SELECT DISTINCT(author.accountId) FROM Comment WHERE timeSent >= :startDate" + " AND timeSent <= :endDate").setParameter("startDate", startOfDay).setParameter( "endDate", endOfDay); } else { activityQuery = getEntityManager().createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType" + " AND postedTime >= :startDate AND postedTime <= :endDate " + "AND recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("actorType", EntityType.PERSON) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); commentQuery = getEntityManager().createQuery( "SELECT DISTINCT(author.accountId) FROM Comment WHERE timeSent >= :startDate" + " AND timeSent <= :endDate " + "AND target.recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } peopleIds.addAll(activityQuery.getResultList()); peopleIds.addAll(commentQuery.getResultList()); return new Long(peopleIds.size()); } }
GetDailyStreamContributorCountDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Query activityQuery, commentQuery; Date startOfDay, endOfDay; HashSet<String> peopleIds = new HashSet<String>(); startOfDay = DateDayExtractor.getStartOfDay(inRequest.getMetricsDate()); endOfDay = DateDayExtractor.getEndOfDay(inRequest.getMetricsDate()); if (inRequest.getStreamRecipientStreamScopeId() == null) { activityQuery = getEntityManager().createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType" + " AND postedTime >= :startDate AND postedTime <= :endDate").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("actorType", EntityType.PERSON); commentQuery = getEntityManager().createQuery( "SELECT DISTINCT(author.accountId) FROM Comment WHERE timeSent >= :startDate" + " AND timeSent <= :endDate").setParameter("startDate", startOfDay).setParameter( "endDate", endOfDay); } else { activityQuery = getEntityManager().createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType" + " AND postedTime >= :startDate AND postedTime <= :endDate " + "AND recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("actorType", EntityType.PERSON) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); commentQuery = getEntityManager().createQuery( "SELECT DISTINCT(author.accountId) FROM Comment WHERE timeSent >= :startDate" + " AND timeSent <= :endDate " + "AND target.recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } peopleIds.addAll(activityQuery.getResultList()); peopleIds.addAll(commentQuery.getResultList()); return new Long(peopleIds.size()); }  }
GetDailyStreamContributorCountDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Query activityQuery, commentQuery; Date startOfDay, endOfDay; HashSet<String> peopleIds = new HashSet<String>(); startOfDay = DateDayExtractor.getStartOfDay(inRequest.getMetricsDate()); endOfDay = DateDayExtractor.getEndOfDay(inRequest.getMetricsDate()); if (inRequest.getStreamRecipientStreamScopeId() == null) { activityQuery = getEntityManager().createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType" + " AND postedTime >= :startDate AND postedTime <= :endDate").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("actorType", EntityType.PERSON); commentQuery = getEntityManager().createQuery( "SELECT DISTINCT(author.accountId) FROM Comment WHERE timeSent >= :startDate" + " AND timeSent <= :endDate").setParameter("startDate", startOfDay).setParameter( "endDate", endOfDay); } else { activityQuery = getEntityManager().createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType" + " AND postedTime >= :startDate AND postedTime <= :endDate " + "AND recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("actorType", EntityType.PERSON) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); commentQuery = getEntityManager().createQuery( "SELECT DISTINCT(author.accountId) FROM Comment WHERE timeSent >= :startDate" + " AND timeSent <= :endDate " + "AND target.recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } peopleIds.addAll(activityQuery.getResultList()); peopleIds.addAll(commentQuery.getResultList()); return new Long(peopleIds.size()); }  @Override Long execute(final UsageMetricDailyStreamInfoRequest inRequest); }
GetDailyStreamContributorCountDbMapper extends
        BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Query activityQuery, commentQuery; Date startOfDay, endOfDay; HashSet<String> peopleIds = new HashSet<String>(); startOfDay = DateDayExtractor.getStartOfDay(inRequest.getMetricsDate()); endOfDay = DateDayExtractor.getEndOfDay(inRequest.getMetricsDate()); if (inRequest.getStreamRecipientStreamScopeId() == null) { activityQuery = getEntityManager().createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType" + " AND postedTime >= :startDate AND postedTime <= :endDate").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("actorType", EntityType.PERSON); commentQuery = getEntityManager().createQuery( "SELECT DISTINCT(author.accountId) FROM Comment WHERE timeSent >= :startDate" + " AND timeSent <= :endDate").setParameter("startDate", startOfDay).setParameter( "endDate", endOfDay); } else { activityQuery = getEntityManager().createQuery( "SELECT DISTINCT(actorId) FROM Activity WHERE actorType=:actorType" + " AND postedTime >= :startDate AND postedTime <= :endDate " + "AND recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("actorType", EntityType.PERSON) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); commentQuery = getEntityManager().createQuery( "SELECT DISTINCT(author.accountId) FROM Comment WHERE timeSent >= :startDate" + " AND timeSent <= :endDate " + "AND target.recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } peopleIds.addAll(activityQuery.getResultList()); peopleIds.addAll(commentQuery.getResultList()); return new Long(peopleIds.size()); }  @Override Long execute(final UsageMetricDailyStreamInfoRequest inRequest);  }