@Test public void testExecuteForPerson() { getEntityManager().createQuery("UPDATE StreamHashTag SET activityDate=:activityDate").setParameter( "activityDate", Calendar.getInstance().getTime()).executeUpdate(); StreamPopularHashTagsDbMapper sut = new StreamPopularHashTagsDbMapper(9, 9); sut.setEntityManager(getEntityManager()); StreamPopularHashTagsReportDTO tagsReport = sut.execute(new StreamPopularHashTagsRequest(ScopeType.PERSON, "smithers")); List<String> tags = tagsReport.getPopularHashTags(); assertEquals(2, tags.size()); assertEquals("#soda", tags.get(0)); assertEquals("#foo", tags.get(1)); }
public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR, 0 - popularHashTagWindowInHours); Date minActivityTime = calendar.getTime(); if (log.isDebugEnabled()) { log.debug("Looking for " + maxNumberOfPopularHashTags + " popular hashtags for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Query query = getEntityManager().createQuery( "SELECT hashTag.content FROM StreamHashTag WHERE streamScopeType = :streamScopeType " + "AND activityDate >= :activityDate AND streamEntityUniqueKey = :streamEntityUniqueKey " + "GROUP BY hashTag.content ORDER BY COUNT(hashTag.content) DESC, hashTag.content ASC") .setParameter("streamScopeType", inRequest.getStreamEntityScopeType()).setParameter("activityDate", minActivityTime).setParameter("streamEntityUniqueKey", inRequest.getStreamEntityUniqueKey()); query.setMaxResults(maxNumberOfPopularHashTags); List<String> hashTags = query.getResultList(); if (log.isDebugEnabled()) { log.debug("Found popular hashtags: " + hashTags + " for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Calendar now = Calendar.getInstance(); return new StreamPopularHashTagsReportDTO(hashTags, now.getTime()); }
StreamPopularHashTagsDbMapper extends
        BaseArgDomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> { public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR, 0 - popularHashTagWindowInHours); Date minActivityTime = calendar.getTime(); if (log.isDebugEnabled()) { log.debug("Looking for " + maxNumberOfPopularHashTags + " popular hashtags for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Query query = getEntityManager().createQuery( "SELECT hashTag.content FROM StreamHashTag WHERE streamScopeType = :streamScopeType " + "AND activityDate >= :activityDate AND streamEntityUniqueKey = :streamEntityUniqueKey " + "GROUP BY hashTag.content ORDER BY COUNT(hashTag.content) DESC, hashTag.content ASC") .setParameter("streamScopeType", inRequest.getStreamEntityScopeType()).setParameter("activityDate", minActivityTime).setParameter("streamEntityUniqueKey", inRequest.getStreamEntityUniqueKey()); query.setMaxResults(maxNumberOfPopularHashTags); List<String> hashTags = query.getResultList(); if (log.isDebugEnabled()) { log.debug("Found popular hashtags: " + hashTags + " for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Calendar now = Calendar.getInstance(); return new StreamPopularHashTagsReportDTO(hashTags, now.getTime()); } }
StreamPopularHashTagsDbMapper extends
        BaseArgDomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> { public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR, 0 - popularHashTagWindowInHours); Date minActivityTime = calendar.getTime(); if (log.isDebugEnabled()) { log.debug("Looking for " + maxNumberOfPopularHashTags + " popular hashtags for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Query query = getEntityManager().createQuery( "SELECT hashTag.content FROM StreamHashTag WHERE streamScopeType = :streamScopeType " + "AND activityDate >= :activityDate AND streamEntityUniqueKey = :streamEntityUniqueKey " + "GROUP BY hashTag.content ORDER BY COUNT(hashTag.content) DESC, hashTag.content ASC") .setParameter("streamScopeType", inRequest.getStreamEntityScopeType()).setParameter("activityDate", minActivityTime).setParameter("streamEntityUniqueKey", inRequest.getStreamEntityUniqueKey()); query.setMaxResults(maxNumberOfPopularHashTags); List<String> hashTags = query.getResultList(); if (log.isDebugEnabled()) { log.debug("Found popular hashtags: " + hashTags + " for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Calendar now = Calendar.getInstance(); return new StreamPopularHashTagsReportDTO(hashTags, now.getTime()); } StreamPopularHashTagsDbMapper(final Integer inPopularHashTagWindowInHours,
            final Integer inMaxNumberOfPopularHashTags); }
StreamPopularHashTagsDbMapper extends
        BaseArgDomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> { public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR, 0 - popularHashTagWindowInHours); Date minActivityTime = calendar.getTime(); if (log.isDebugEnabled()) { log.debug("Looking for " + maxNumberOfPopularHashTags + " popular hashtags for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Query query = getEntityManager().createQuery( "SELECT hashTag.content FROM StreamHashTag WHERE streamScopeType = :streamScopeType " + "AND activityDate >= :activityDate AND streamEntityUniqueKey = :streamEntityUniqueKey " + "GROUP BY hashTag.content ORDER BY COUNT(hashTag.content) DESC, hashTag.content ASC") .setParameter("streamScopeType", inRequest.getStreamEntityScopeType()).setParameter("activityDate", minActivityTime).setParameter("streamEntityUniqueKey", inRequest.getStreamEntityUniqueKey()); query.setMaxResults(maxNumberOfPopularHashTags); List<String> hashTags = query.getResultList(); if (log.isDebugEnabled()) { log.debug("Found popular hashtags: " + hashTags + " for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Calendar now = Calendar.getInstance(); return new StreamPopularHashTagsReportDTO(hashTags, now.getTime()); } StreamPopularHashTagsDbMapper(final Integer inPopularHashTagWindowInHours,
            final Integer inMaxNumberOfPopularHashTags); StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest); }
StreamPopularHashTagsDbMapper extends
        BaseArgDomainMapper<StreamPopularHashTagsRequest, StreamPopularHashTagsReportDTO> { public StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest) { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.HOUR, 0 - popularHashTagWindowInHours); Date minActivityTime = calendar.getTime(); if (log.isDebugEnabled()) { log.debug("Looking for " + maxNumberOfPopularHashTags + " popular hashtags for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Query query = getEntityManager().createQuery( "SELECT hashTag.content FROM StreamHashTag WHERE streamScopeType = :streamScopeType " + "AND activityDate >= :activityDate AND streamEntityUniqueKey = :streamEntityUniqueKey " + "GROUP BY hashTag.content ORDER BY COUNT(hashTag.content) DESC, hashTag.content ASC") .setParameter("streamScopeType", inRequest.getStreamEntityScopeType()).setParameter("activityDate", minActivityTime).setParameter("streamEntityUniqueKey", inRequest.getStreamEntityUniqueKey()); query.setMaxResults(maxNumberOfPopularHashTags); List<String> hashTags = query.getResultList(); if (log.isDebugEnabled()) { log.debug("Found popular hashtags: " + hashTags + " for " + inRequest.getStreamEntityScopeType() + " stream with id " + inRequest.getStreamEntityUniqueKey() + " and activity date >= " + minActivityTime.toString()); } Calendar now = Calendar.getInstance(); return new StreamPopularHashTagsReportDTO(hashTags, now.getTime()); } StreamPopularHashTagsDbMapper(final Integer inPopularHashTagWindowInHours,
            final Integer inMaxNumberOfPopularHashTags); StreamPopularHashTagsReportDTO execute(final StreamPopularHashTagsRequest inRequest);  }