@Test public void testExecuteForSpecificStreamWithNoData1() { final Long streamScopeId = 877L; Date april4th = new Date(april4th2011 + 8); assertEquals(0, (long) sut.execute(new UsageMetricDailyStreamInfoRequest(april4th, streamScopeId))); }
@Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Long activityCount, commentCount; Date startOfDay, endOfDay; Query activityCountQuery, commentCountQuery; startOfDay = DateDayExtractor.getStartOfDay(inRequest.getMetricsDate()); endOfDay = DateDayExtractor.getEndOfDay(inRequest.getMetricsDate()); if (inRequest.getStreamRecipientStreamScopeId() == null) { activityCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Activity WHERE (appType = null OR appType != :plugin) AND " + "postedTime >= :startDate AND postedTime <= :endDate").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("plugin", EntityType.PLUGIN); commentCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Comment WHERE timeSent >= :startDate AND timeSent <= :endDate") .setParameter("startDate", startOfDay).setParameter("endDate", endOfDay); } else { activityCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Activity WHERE (appType = null OR appType != :plugin) " + "AND postedTime >= :startDate AND postedTime <= :endDate " + "AND recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("plugin", EntityType.PLUGIN) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); commentCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Comment WHERE timeSent >= :startDate AND timeSent <= :endDate " + "AND target.recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } activityCount = (Long) activityCountQuery.getSingleResult(); commentCount = (Long) commentCountQuery.getSingleResult(); return activityCount + commentCount; }
GetDailyMessageCountDbMapper extends BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Long activityCount, commentCount; Date startOfDay, endOfDay; Query activityCountQuery, commentCountQuery; startOfDay = DateDayExtractor.getStartOfDay(inRequest.getMetricsDate()); endOfDay = DateDayExtractor.getEndOfDay(inRequest.getMetricsDate()); if (inRequest.getStreamRecipientStreamScopeId() == null) { activityCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Activity WHERE (appType = null OR appType != :plugin) AND " + "postedTime >= :startDate AND postedTime <= :endDate").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("plugin", EntityType.PLUGIN); commentCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Comment WHERE timeSent >= :startDate AND timeSent <= :endDate") .setParameter("startDate", startOfDay).setParameter("endDate", endOfDay); } else { activityCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Activity WHERE (appType = null OR appType != :plugin) " + "AND postedTime >= :startDate AND postedTime <= :endDate " + "AND recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("plugin", EntityType.PLUGIN) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); commentCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Comment WHERE timeSent >= :startDate AND timeSent <= :endDate " + "AND target.recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } activityCount = (Long) activityCountQuery.getSingleResult(); commentCount = (Long) commentCountQuery.getSingleResult(); return activityCount + commentCount; } }
GetDailyMessageCountDbMapper extends BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Long activityCount, commentCount; Date startOfDay, endOfDay; Query activityCountQuery, commentCountQuery; startOfDay = DateDayExtractor.getStartOfDay(inRequest.getMetricsDate()); endOfDay = DateDayExtractor.getEndOfDay(inRequest.getMetricsDate()); if (inRequest.getStreamRecipientStreamScopeId() == null) { activityCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Activity WHERE (appType = null OR appType != :plugin) AND " + "postedTime >= :startDate AND postedTime <= :endDate").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("plugin", EntityType.PLUGIN); commentCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Comment WHERE timeSent >= :startDate AND timeSent <= :endDate") .setParameter("startDate", startOfDay).setParameter("endDate", endOfDay); } else { activityCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Activity WHERE (appType = null OR appType != :plugin) " + "AND postedTime >= :startDate AND postedTime <= :endDate " + "AND recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("plugin", EntityType.PLUGIN) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); commentCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Comment WHERE timeSent >= :startDate AND timeSent <= :endDate " + "AND target.recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } activityCount = (Long) activityCountQuery.getSingleResult(); commentCount = (Long) commentCountQuery.getSingleResult(); return activityCount + commentCount; }  }
GetDailyMessageCountDbMapper extends BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Long activityCount, commentCount; Date startOfDay, endOfDay; Query activityCountQuery, commentCountQuery; startOfDay = DateDayExtractor.getStartOfDay(inRequest.getMetricsDate()); endOfDay = DateDayExtractor.getEndOfDay(inRequest.getMetricsDate()); if (inRequest.getStreamRecipientStreamScopeId() == null) { activityCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Activity WHERE (appType = null OR appType != :plugin) AND " + "postedTime >= :startDate AND postedTime <= :endDate").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("plugin", EntityType.PLUGIN); commentCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Comment WHERE timeSent >= :startDate AND timeSent <= :endDate") .setParameter("startDate", startOfDay).setParameter("endDate", endOfDay); } else { activityCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Activity WHERE (appType = null OR appType != :plugin) " + "AND postedTime >= :startDate AND postedTime <= :endDate " + "AND recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("plugin", EntityType.PLUGIN) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); commentCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Comment WHERE timeSent >= :startDate AND timeSent <= :endDate " + "AND target.recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } activityCount = (Long) activityCountQuery.getSingleResult(); commentCount = (Long) commentCountQuery.getSingleResult(); return activityCount + commentCount; }  @Override Long execute(final UsageMetricDailyStreamInfoRequest inRequest); }
GetDailyMessageCountDbMapper extends BaseArgDomainMapper<UsageMetricDailyStreamInfoRequest, Long> { @Override public Long execute(final UsageMetricDailyStreamInfoRequest inRequest) { Long activityCount, commentCount; Date startOfDay, endOfDay; Query activityCountQuery, commentCountQuery; startOfDay = DateDayExtractor.getStartOfDay(inRequest.getMetricsDate()); endOfDay = DateDayExtractor.getEndOfDay(inRequest.getMetricsDate()); if (inRequest.getStreamRecipientStreamScopeId() == null) { activityCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Activity WHERE (appType = null OR appType != :plugin) AND " + "postedTime >= :startDate AND postedTime <= :endDate").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("plugin", EntityType.PLUGIN); commentCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Comment WHERE timeSent >= :startDate AND timeSent <= :endDate") .setParameter("startDate", startOfDay).setParameter("endDate", endOfDay); } else { activityCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Activity WHERE (appType = null OR appType != :plugin) " + "AND postedTime >= :startDate AND postedTime <= :endDate " + "AND recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("plugin", EntityType.PLUGIN) .setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); commentCountQuery = getEntityManager().createQuery( "SELECT COUNT(id) FROM Comment WHERE timeSent >= :startDate AND timeSent <= :endDate " + "AND target.recipientStreamScope.id = :recipientStreamScopeId").setParameter("startDate", startOfDay).setParameter("endDate", endOfDay).setParameter("recipientStreamScopeId", inRequest.getStreamRecipientStreamScopeId()); } activityCount = (Long) activityCountQuery.getSingleResult(); commentCount = (Long) commentCountQuery.getSingleResult(); return activityCount + commentCount; }  @Override Long execute(final UsageMetricDailyStreamInfoRequest inRequest);  }