@Test public void testExecute() { getEntityManager().persist(new UsageMetric(1L, true, true, 1L, new Date(apri8th2011))); getEntityManager().persist(new UsageMetric(3L, true, false, null, new Date(apri8th2011 + 4))); getEntityManager().persist(new UsageMetric(3L, true, true, 1L, new Date(apri8th2011 + 5))); getEntityManager().persist(new UsageMetric(4L, true, true, 1L, new Date(apri8th2011))); getEntityManager().persist(new UsageMetric(5L, true, true, 1L, new Date(apri8th2011))); getEntityManager().persist(new UsageMetric(6L, true, false, null, new Date(april7th2011))); getEntityManager().persist(new UsageMetric(5L, true, false, null, new Date(april7th2011))); getEntityManager().persist(new UsageMetric(4L, true, false, null, new Date(april7th2011))); getEntityManager().persist(new UsageMetric(3L, true, false, null, new Date(april7th2011))); getEntityManager().flush(); getEntityManager().clear(); Assert.assertEquals(4L, (long) sut.execute(new Date(apri8th2011))); }
@Override public Long execute(final Date inDay) { Date startOfDay, endOfDay; Query q; startOfDay = DateDayExtractor.getStartOfDay(inDay); endOfDay = DateDayExtractor.getEndOfDay(inDay); q = getEntityManager().createQuery( "SELECT COUNT(DISTINCT actorPersonId) FROM UsageMetric " + "WHERE created >= :startDate AND created < :endDate").setParameter("startDate", startOfDay) .setParameter("endDate", endOfDay); return (Long) q.getSingleResult(); }
GetDailyUniqueVisitorCountDbMapper extends BaseArgDomainMapper<Date, Long> { @Override public Long execute(final Date inDay) { Date startOfDay, endOfDay; Query q; startOfDay = DateDayExtractor.getStartOfDay(inDay); endOfDay = DateDayExtractor.getEndOfDay(inDay); q = getEntityManager().createQuery( "SELECT COUNT(DISTINCT actorPersonId) FROM UsageMetric " + "WHERE created >= :startDate AND created < :endDate").setParameter("startDate", startOfDay) .setParameter("endDate", endOfDay); return (Long) q.getSingleResult(); } }
GetDailyUniqueVisitorCountDbMapper extends BaseArgDomainMapper<Date, Long> { @Override public Long execute(final Date inDay) { Date startOfDay, endOfDay; Query q; startOfDay = DateDayExtractor.getStartOfDay(inDay); endOfDay = DateDayExtractor.getEndOfDay(inDay); q = getEntityManager().createQuery( "SELECT COUNT(DISTINCT actorPersonId) FROM UsageMetric " + "WHERE created >= :startDate AND created < :endDate").setParameter("startDate", startOfDay) .setParameter("endDate", endOfDay); return (Long) q.getSingleResult(); }  }
GetDailyUniqueVisitorCountDbMapper extends BaseArgDomainMapper<Date, Long> { @Override public Long execute(final Date inDay) { Date startOfDay, endOfDay; Query q; startOfDay = DateDayExtractor.getStartOfDay(inDay); endOfDay = DateDayExtractor.getEndOfDay(inDay); q = getEntityManager().createQuery( "SELECT COUNT(DISTINCT actorPersonId) FROM UsageMetric " + "WHERE created >= :startDate AND created < :endDate").setParameter("startDate", startOfDay) .setParameter("endDate", endOfDay); return (Long) q.getSingleResult(); }  @Override Long execute(final Date inDay); }
GetDailyUniqueVisitorCountDbMapper extends BaseArgDomainMapper<Date, Long> { @Override public Long execute(final Date inDay) { Date startOfDay, endOfDay; Query q; startOfDay = DateDayExtractor.getStartOfDay(inDay); endOfDay = DateDayExtractor.getEndOfDay(inDay); q = getEntityManager().createQuery( "SELECT COUNT(DISTINCT actorPersonId) FROM UsageMetric " + "WHERE created >= :startDate AND created < :endDate").setParameter("startDate", startOfDay) .setParameter("endDate", endOfDay); return (Long) q.getSingleResult(); }  @Override Long execute(final Date inDay);  }